[BACK]Return to bsd.pkg.clean.mk CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / pkgsrc / mk

File: [cvs.NetBSD.org] / pkgsrc / mk / bsd.pkg.clean.mk (download)

Revision 1.14, Sat Jun 1 19:31:52 2013 UTC (5 years, 9 months ago) by rillig
Branch: MAIN
CVS Tags: pkgsrc-2018Q4-base, pkgsrc-2018Q4, pkgsrc-2018Q3-base, pkgsrc-2018Q3, pkgsrc-2018Q2-base, pkgsrc-2018Q2, pkgsrc-2018Q1-base, pkgsrc-2018Q1, pkgsrc-2017Q4-base, pkgsrc-2017Q4, pkgsrc-2017Q3-base, pkgsrc-2017Q3, pkgsrc-2017Q2-base, pkgsrc-2017Q2, pkgsrc-2017Q1-base, pkgsrc-2017Q1, pkgsrc-2016Q4-base, pkgsrc-2016Q4, pkgsrc-2016Q3-base, pkgsrc-2016Q3, pkgsrc-2016Q2-base, pkgsrc-2016Q2, pkgsrc-2016Q1-base, pkgsrc-2016Q1, pkgsrc-2015Q4-base, pkgsrc-2015Q4, pkgsrc-2015Q3-base, pkgsrc-2015Q3, pkgsrc-2015Q2-base, pkgsrc-2015Q2, pkgsrc-2015Q1-base, pkgsrc-2015Q1, pkgsrc-2014Q4-base, pkgsrc-2014Q4, pkgsrc-2014Q3-base, pkgsrc-2014Q3, pkgsrc-2014Q2-base, pkgsrc-2014Q2, pkgsrc-2014Q1-base, pkgsrc-2014Q1, pkgsrc-2013Q4-base, pkgsrc-2013Q4, pkgsrc-2013Q3-base, pkgsrc-2013Q3, pkgsrc-2013Q2-base, pkgsrc-2013Q2, pkgsrc-, HEAD
Changes since 1.13: +12 -10 lines


# $NetBSD: bsd.pkg.clean.mk,v 1.14 2013/06/01 19:31:52 rillig Exp $
# 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:
#	descends into dependencies' package directories and invokes the
#	"clean" action.
# do-clean:
#	does the actual cleaning, which involves removing the work
#	directory and other temporary files used by the package.
# clean:
#	is invoked by the user to perform the "clean" action.
# cleandir:
#	an alias for "clean".


.if defined(PRIVILEGED_STAGES) && !empty(PRIVILEGED_STAGES:Mclean)

.PHONY: clean-depends
	${RUN}								\
	while read dir; do						\
		cd ${.CURDIR}/../../$$dir &&				\

.PHONY: pre-clean
.if !target(pre-clean)

.PHONY: post-clean
.if !target(post-clean)

.PHONY: do-clean
.if !target(do-clean)
.  if !empty(_MAKE_CLEAN_AS_ROOT:M[Yy][Ee][Ss])
do-clean: su-target
.  else
do-clean: su-do-clean
.  endif

su-do-clean: .PHONY
	@${PHASE_MSG} "Cleaning for ${PKGNAME}"
	${RUN}								\
	if ${TEST} -d ${WRKDIR}; then					\
		if ${TEST} -w ${WRKDIR}; then				\
			${RM} -fr ${WRKDIR};				\
		else							\
			${STEP_MSG} ${WRKDIR}" not writable, skipping";	\
		fi;							\
.if defined(WRKOBJDIR)
	${RUN}								\
	${RMDIR} ${BUILD_DIR} 2>/dev/null || ${TRUE};			\
	${RMDIR} ${BUILD_DIR:H} 2>/dev/null || ${TRUE};			\
	${RM} -f ${WRKDIR_BASENAME} 2>/dev/null || ${TRUE}

_CLEAN_TARGETS+=	pre-clean
.if empty(CLEANDEPENDS:M[nN][oO])
_CLEAN_TARGETS+=	clean-depends
_CLEAN_TARGETS+=	do-clean
_CLEAN_TARGETS+=	post-clean

.PHONY: clean
.if !target(clean)
clean: ${_CLEAN_TARGETS}

.PHONY: cleandir
cleandir: clean