summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2006-01-19 16:11:10 +0000
committerjlam <jlam@pkgsrc.org>2006-01-19 16:11:10 +0000
commit15e61bbe84d19dd2c46d358cd759191aed079781 (patch)
tree057ea51b49839a244adf7ee593f25d87914c2248 /mk
parent9dd0764a8e8c556c702d1b7039db9537f9c1a353 (diff)
downloadpkgsrc-15e61bbe84d19dd2c46d358cd759191aed079781.tar.gz
* Split out the "clean" targets and variables and put them into a separate
file pkgsrc/mk/bsd.pkg.clean.mk. * Reimplement the clean target so that we don't need to invoke a separate make process just to do clean-depends. * Reimplement clean-depends using a pipe to avoid command-line length issues.
Diffstat (limited to 'mk')
-rw-r--r--mk/bsd.pkg.clean.mk85
-rw-r--r--mk/bsd.pkg.mk54
2 files changed, 89 insertions, 50 deletions
diff --git a/mk/bsd.pkg.clean.mk b/mk/bsd.pkg.clean.mk
new file mode 100644
index 00000000000..1defd501b11
--- /dev/null
+++ b/mk/bsd.pkg.clean.mk
@@ -0,0 +1,85 @@
+# $NetBSD: bsd.pkg.clean.mk,v 1.1 2006/01/19 16:11:10 jlam 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 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
+
+.PHONY: clean-depends
+clean-depends:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${_DEPENDS_WALK_CMD} ${PKGPATH} | \
+ while read dir; do \
+ cd ${.CURDIR}/../../$$dir && \
+ ${MAKE} ${MAKEFLAGS} CLEANDEPENDS=no clean; \
+ 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)
+do-clean:
+ @${ECHO_MSG} "${_PKGSRC_IN}> Cleaning for ${PKGNAME}"
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ if ${TEST} -d ${WRKDIR:Q}; then \
+ if ${TEST} -w ${WRKDIR:Q}; then \
+ ${RM} -fr ${WRKDIR:Q}; \
+ else \
+ ${ECHO_MSG} "${_PKGSRC_IN}> "${WRKDIR:Q}" not writable, skipping"; \
+ fi; \
+ fi
+. if defined(WRKOBJDIR)
+ -${_PKG_SILENT}${_PKG_DEBUG} \
+ ${RMDIR} ${BUILD_DIR} 2>/dev/null; \
+ ${RM} -f ${WRKDIR_BASENAME}
+. endif
+.endif
+
+_CLEAN_TARGETS+= pre-clean
+.if empty(CLEANDEPENDS:M[nN][oO])
+_CLEAN_TARGETS+= clean-depends
+.endif
+_CLEAN_TARGETS+= do-clean
+_CLEAN_TARGETS+= post-clean
+
+.ORDER: ${_CLEAN_TARGETS}
+
+.PHONY: clean
+.if !target(clean)
+clean: ${_CLEAN_TARGETS}
+.endif
+
+.PHONY: cleandir
+cleandir: clean
diff --git a/mk/bsd.pkg.mk b/mk/bsd.pkg.mk
index 1c75ca8c4ab..7de41e4725d 100644
--- a/mk/bsd.pkg.mk
+++ b/mk/bsd.pkg.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.mk,v 1.1791 2006/01/18 20:18:04 jlam Exp $
+# $NetBSD: bsd.pkg.mk,v 1.1792 2006/01/19 16:11:10 jlam Exp $
#
# This file is in the public domain.
#
@@ -59,7 +59,6 @@ build-defs-message: ${WRKDIR}
############################################################################
CHECK_SHLIBS?= YES # run check-shlibs after install
-CLEANDEPENDS?= NO
DEINSTALLDEPENDS?= NO # add -R to pkg_delete
MKCRYPTO?= YES # build crypto packages by default
NOCLEAN?= NO # don't clean up after update
@@ -830,6 +829,9 @@ USE_TOOLS+= gzip
# Check
.include "../../mk/bsd.pkg.check.mk"
+# Clean
+.include "../../mk/bsd.pkg.clean.mk"
+
# Tools
.include "../../mk/tools/bsd.tools.mk"
@@ -3090,60 +3092,12 @@ mirror-distfiles:
# Cleaning up
-.PHONY: pre-clean
-.if !target(pre-clean)
-pre-clean:
- @${DO_NADA}
-.endif
-
-.PHONY: clean
-.if !target(clean)
-clean: pre-clean
-. if (${CLEANDEPENDS} != "NO") && (!empty(BUILD_DEPENDS) || !empty(DEPENDS))
- ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} clean-depends
-. endif
- @${ECHO_MSG} "${_PKGSRC_IN}> Cleaning for ${PKGNAME}"
- ${_PKG_SILENT}${_PKG_DEBUG} \
- if [ -d ${WRKDIR} ]; then \
- if [ -w ${WRKDIR} ]; then \
- ${RM} -rf ${WRKDIR}; \
- else \
- ${ECHO_MSG} "${_PKGSRC_IN}> ${WRKDIR} not writable, skipping"; \
- fi; \
- fi
-. if defined(WRKOBJDIR)
- -${_PKG_SILENT}${_PKG_DEBUG} \
- ${RMDIR} ${BUILD_DIR} 2>/dev/null; \
- ${RM} -f ${WRKDIR_BASENAME}
-. endif
-.endif
-
-
-.PHONY: clean-depends
-.if !target(clean-depends)
-clean-depends:
-. if !empty(BUILD_DEPENDS) || !empty(DEPENDS)
- ${_PKG_SILENT}${_PKG_DEBUG} \
- for i in `${MAKE} ${MAKEFLAGS} show-all-depends-dirs-excl`; do \
- cd ${.CURDIR}/../../$$i && \
- ${MAKE} ${MAKEFLAGS} CLEANDEPENDS=NO clean; \
- done
-. endif
-.endif
-
.PHONY: pre-distclean
.if !target(pre-distclean)
pre-distclean:
@${DO_NADA}
.endif
-
-.PHONY: cleandir
-.if !target(cleandir)
-cleandir: clean
-.endif
-
-
.PHONY: distclean
.if !target(distclean)
distclean: pre-distclean clean