2007-11-15 13:09:52 +01:00
|
|
|
# $NetBSD: bsd.pkg.clean.mk,v 1.13 2007/11/15 12:09:52 rillig Exp $
|
2006-01-19 17:11:10 +01:00
|
|
|
#
|
|
|
|
# This Makefile fragment is included to bsd.pkg.mk and defines the
|
|
|
|
# relevant variables and targets for the "clean" phase.
|
|
|
|
#
|
|
|
|
# The following variables may be set by the package Makefile and
|
|
|
|
# specify how cleaning happens:
|
|
|
|
#
|
|
|
|
# CLEANDEPENDS specifies the whether "cleaning" will also clean
|
|
|
|
# in all dependencies, implied and direct. CLEANDEPENDS
|
|
|
|
# defaults to "no".
|
|
|
|
#
|
|
|
|
# The following targets are defined by bsd.pkg.clean.mk:
|
|
|
|
#
|
|
|
|
# clean-depends is the target which descends into dependencies'
|
|
|
|
# package directories and invokes the "clean" action.
|
|
|
|
#
|
|
|
|
# do-clean is the target that does the actual cleaning, which
|
|
|
|
# involves removing the work directory and other temporary
|
|
|
|
# files used by the package.
|
|
|
|
#
|
|
|
|
# clean is the target that is invoked by the user to perform
|
|
|
|
# the "clean" action.
|
|
|
|
#
|
|
|
|
# cleandir is an alias for "clean".
|
|
|
|
#
|
|
|
|
|
|
|
|
CLEANDEPENDS?= no
|
|
|
|
|
2007-07-02 22:24:27 +02:00
|
|
|
.if defined(PRIVILEGED_STAGES) && !empty(PRIVILEGED_STAGES:Mclean)
|
2007-07-01 02:06:40 +02:00
|
|
|
_MAKE_CLEAN_AS_ROOT=yes
|
|
|
|
.endif
|
|
|
|
|
2006-01-19 17:11:10 +01:00
|
|
|
.PHONY: clean-depends
|
|
|
|
clean-depends:
|
2007-11-15 13:09:52 +01:00
|
|
|
${RUN} \
|
2006-01-19 17:11:10 +01:00
|
|
|
${_DEPENDS_WALK_CMD} ${PKGPATH} | \
|
|
|
|
while read dir; do \
|
|
|
|
cd ${.CURDIR}/../../$$dir && \
|
2006-07-27 23:46:45 +02:00
|
|
|
${RECURSIVE_MAKE} ${MAKEFLAGS} CLEANDEPENDS=no clean; \
|
2006-01-19 17:11:10 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
.PHONY: pre-clean
|
|
|
|
.if !target(pre-clean)
|
|
|
|
pre-clean:
|
|
|
|
@${DO_NADA}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.PHONY: post-clean
|
|
|
|
.if !target(post-clean)
|
|
|
|
post-clean:
|
|
|
|
@${DO_NADA}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.PHONY: do-clean
|
|
|
|
.if !target(do-clean)
|
2006-10-09 13:44:06 +02:00
|
|
|
. if !empty(_MAKE_CLEAN_AS_ROOT:M[Yy][Ee][Ss])
|
|
|
|
do-clean: su-target
|
|
|
|
. else
|
|
|
|
do-clean: su-do-clean
|
|
|
|
. endif
|
|
|
|
.endif
|
|
|
|
|
2007-11-15 13:09:52 +01:00
|
|
|
su-do-clean: .PHONY
|
2006-06-06 00:49:44 +02:00
|
|
|
@${PHASE_MSG} "Cleaning for ${PKGNAME}"
|
2007-11-15 13:09:52 +01:00
|
|
|
${RUN} \
|
|
|
|
if ${TEST} -d ${WRKDIR}; then \
|
|
|
|
if ${TEST} -w ${WRKDIR}; then \
|
|
|
|
${RM} -fr ${WRKDIR}; \
|
2006-01-19 17:11:10 +01:00
|
|
|
else \
|
2007-11-15 13:09:52 +01:00
|
|
|
${STEP_MSG} ${WRKDIR}" not writable, skipping"; \
|
2006-01-19 17:11:10 +01:00
|
|
|
fi; \
|
|
|
|
fi
|
2007-11-15 13:09:52 +01:00
|
|
|
.if defined(WRKOBJDIR)
|
|
|
|
${RUN} \
|
2006-08-02 18:53:00 +02:00
|
|
|
${RMDIR} ${BUILD_DIR} 2>/dev/null || ${TRUE}; \
|
2007-11-15 13:05:09 +01:00
|
|
|
${RMDIR} ${BUILD_DIR:H} 2>/dev/null || ${TRUE}; \
|
2006-08-02 18:53:00 +02:00
|
|
|
${RM} -f ${WRKDIR_BASENAME} 2>/dev/null || ${TRUE}
|
2007-11-15 13:09:52 +01:00
|
|
|
.endif
|
2006-01-19 17:11:10 +01:00
|
|
|
|
|
|
|
_CLEAN_TARGETS+= pre-clean
|
|
|
|
.if empty(CLEANDEPENDS:M[nN][oO])
|
|
|
|
_CLEAN_TARGETS+= clean-depends
|
|
|
|
.endif
|
|
|
|
_CLEAN_TARGETS+= do-clean
|
|
|
|
_CLEAN_TARGETS+= post-clean
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
.if !target(clean)
|
|
|
|
clean: ${_CLEAN_TARGETS}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.PHONY: cleandir
|
|
|
|
cleandir: clean
|