1 # $NetBSD: bsd.pkg.clean.mk,v 1.12 2007/11/15 12:05:09 rillig Exp $
3 # This Makefile fragment is included to bsd.pkg.mk and defines the
4 # relevant variables and targets for the "clean" phase.
6 # The following variables may be set by the package Makefile and
7 # specify how cleaning happens:
9 # CLEANDEPENDS specifies the whether "cleaning" will also clean
10 # in all dependencies, implied and direct. CLEANDEPENDS
13 # The following targets are defined by bsd.pkg.clean.mk:
15 # clean-depends is the target which descends into dependencies'
16 # package directories and invokes the "clean" action.
18 # do-clean is the target that does the actual cleaning, which
19 # involves removing the work directory and other temporary
20 # files used by the package.
22 # clean is the target that is invoked by the user to perform
25 # cleandir is an alias for "clean".
30 .if defined(PRIVILEGED_STAGES) && !empty(PRIVILEGED_STAGES:Mclean)
31 _MAKE_CLEAN_AS_ROOT=yes
37 ${_DEPENDS_WALK_CMD} ${PKGPATH} | \
39 cd ${.CURDIR}/../../$$dir && \
40 ${RECURSIVE_MAKE} ${MAKEFLAGS} CLEANDEPENDS=no clean; \
44 .if !target(pre-clean)
50 .if !target(post-clean)
57 . if !empty(_MAKE_CLEAN_AS_ROOT:M[Yy][Ee][Ss])
65 @${PHASE_MSG} "Cleaning for ${PKGNAME}"
67 if ${TEST} -d ${WRKDIR}; then \
68 if ${TEST} -w ${WRKDIR}; then \
69 ${RM} -fr ${WRKDIR}; \
71 ${STEP_MSG} ${WRKDIR}" not writable, skipping"; \
74 .if defined(WRKOBJDIR)
76 ${RMDIR} ${BUILD_DIR} 2>/dev/null || ${TRUE}; \
77 ${RMDIR} ${BUILD_DIR:H} 2>/dev/null || ${TRUE}; \
78 ${RM} -f ${WRKDIR_BASENAME} 2>/dev/null || ${TRUE}
81 _CLEAN_TARGETS+= pre-clean
82 .if empty(CLEANDEPENDS:M[nN][oO])
83 _CLEAN_TARGETS+= clean-depends
85 _CLEAN_TARGETS+= do-clean
86 _CLEAN_TARGETS+= post-clean
90 clean: ${_CLEAN_TARGETS}