summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorjlam <jlam>2005-05-09 05:06:55 +0000
committerjlam <jlam>2005-05-09 05:06:55 +0000
commitc34608ae916ed78ce7d48d4642faf538caec14e2 (patch)
tree3bff071687c8b973f251436d751c2dc954d88ba6 /mk
parent2fe098a1c1aa36d5b7c5ceafeb584a0208f9d74a (diff)
downloadpkgsrc-c34608ae916ed78ce7d48d4642faf538caec14e2.tar.gz
Teach bsd.pkg.mk to create a phase-specific "makevars.mk" file that
caches variable definitions that were computed by make. These variables are specified by listing them in MAKE_VARS, e.g., .if !defined(FOO) FOO!= very_time_consuming_command .endif MAKE_VARS+= FOO bsd.pkg.mk will include only the one generated during the most recent phase. A particular phase's makevars.mk file consists of variable definitions that are a superset of all of the ones produced in previous phases of the build. The caching is useful because bsd.pkg.mk invokes make recursively, which in the example above has the potential to run the very time-consuming command each time unless we cause FOO to be defined for the sub-make processes. We don't cache via MAKE_FLAGS because MAKE_FLAGS isn't consistently applied to every invocation of make, and also because MAKE_FLAGS can overflow the maximum length of a make variable very quickly if we add many values to it. One important and desirable property of variables cached via MAKE_VARS is that they only apply to the current package, and not to any dependencies whose builds may have been triggered by the current package. The makevars.mk files are generated by new targets fetch-vars, extract-vars, patch-vars, etc., and these targets are built during the corresponding real-* target to ensure that they are being invoked with PKG_PHASE set to the proper value. Also, remove the variables cache file that bsd.wrapper.mk was generating since the new makevars.mk files provide the same functionality at a higher level. Change all WRAPPER_VARS definitions that were used by the old wrapper-phase cache file into MAKE_VARS definitions.
Diffstat (limited to 'mk')
-rw-r--r--mk/bsd.pkg.mk79
-rw-r--r--mk/bsd.prefs.mk3
-rw-r--r--mk/buildlink3/bsd.buildlink3.mk16
-rw-r--r--mk/wrapper/bsd.wrapper.mk32
4 files changed, 77 insertions, 53 deletions
diff --git a/mk/bsd.pkg.mk b/mk/bsd.pkg.mk
index 2a26dbb8d49..f4d26c2635d 100644
--- a/mk/bsd.pkg.mk
+++ b/mk/bsd.pkg.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.mk,v 1.1630 2005/05/08 13:52:25 dillo Exp $
+# $NetBSD: bsd.pkg.mk,v 1.1631 2005/05/09 05:06:55 jlam Exp $
#
# This file is in the public domain.
#
@@ -21,6 +21,27 @@
.include "../../mk/bsd.prefs.mk"
.include "../../mk/bsd.hacks.mk"
+.if !defined(_REV_ALL_PHASES)
+_REV_ALL_PHASES= # empty
+. for _phase_ in ${ALL_PHASES}
+_REV_ALL_PHASES:= ${_phase_} ${_REV_ALL_PHASES}
+. endfor
+. undef _phase_
+.endif
+MAKE_VARS+= _REV_ALL_PHASES
+
+# Try including the .makevars.mk.* files in reverse order so that the
+# latest file is included and no more.
+#
+.for _phase_ in ${_REV_ALL_PHASES}
+_MAKE_VARS_MK.${_phase_}= ${WRKDIR}/.${_phase_}_makevars.mk
+${_phase_}-vars: ${_MAKE_VARS_MK.${_phase_}}
+. if !defined(_MAKE_VARS_MK)
+. sinclude "${_MAKE_VARS_MK.${_phase_}}"
+. endif
+.endfor
+.undef _phase_
+
# This has to come first to avoid showing all BUILD_DEFS added by this
# Makefile, which are usually not customizable.
.PHONY: pre-install-depends build-defs-message
@@ -3161,12 +3182,12 @@ test-cookie:
${_PKG_SILENT}${_PKG_DEBUG} ${TOUCH} ${TOUCH_FLAGS} ${TEST_COOKIE}
.ORDER: pre-fetch do-fetch post-fetch
-.ORDER: extract-message install-depends pre-extract do-extract post-extract extract-cookie
-.ORDER: patch-message pre-patch do-patch post-patch patch-cookie
-.ORDER: tools-message pre-tools do-tools post-tools tools-cookie
-.ORDER: wrapper-message pre-wrapper do-wrapper post-wrapper wrapper-cookie
-.ORDER: configure-message pre-configure pre-configure-override do-configure post-configure configure-cookie
-.ORDER: build-message pre-build do-build post-build build-cookie
+.ORDER: extract-message extract-vars install-depends pre-extract do-extract post-extract extract-cookie
+.ORDER: patch-message patch-vars pre-patch do-patch post-patch patch-cookie
+.ORDER: tools-message tools-vars pre-tools do-tools post-tools tools-cookie
+.ORDER: wrapper-message wrapper-vars pre-wrapper do-wrapper post-wrapper wrapper-cookie
+.ORDER: configure-message configure-vars pre-configure pre-configure-override do-configure post-configure configure-cookie
+.ORDER: build-message build-vars pre-build do-build post-build build-cookie
.ORDER: test-message pre-test do-test post-test test-cookie
# Please note that the order of the following targets is important, and
@@ -3177,15 +3198,15 @@ test-cookie:
.PHONY: real-configure real-build real-test real-install real-package
.PHONY: real-replace real-undo-replace
real-fetch: pre-fetch do-fetch post-fetch
-real-extract: extract-message install-depends pre-extract do-extract post-extract extract-cookie
-real-patch: patch-message pre-patch do-patch post-patch patch-cookie
-real-tools: tools-message pre-tools do-tools post-tools tools-cookie
-real-wrapper: wrapper-message pre-wrapper do-wrapper post-wrapper wrapper-cookie
-real-configure: configure-message pre-configure pre-configure-override do-configure post-configure configure-cookie
-real-build: build-message pre-build do-build post-build build-cookie
+real-extract: extract-message extract-vars install-depends pre-extract do-extract post-extract extract-cookie
+real-patch: patch-message patch-vars pre-patch do-patch post-patch patch-cookie
+real-tools: tools-message tools-vars pre-tools do-tools post-tools tools-cookie
+real-wrapper: wrapper-message wrapper-vars pre-wrapper do-wrapper post-wrapper wrapper-cookie
+real-configure: configure-message configure-vars pre-configure pre-configure-override do-configure post-configure configure-cookie
+real-build: build-message build-vars pre-build do-build post-build build-cookie
real-test: test-message pre-test do-test post-test test-cookie
-real-install: do-su-install
-real-package: do-su-package
+real-install: install-vars do-su-install
+real-package: package-vars do-su-package
real-replace: do-su-replace
real-undo-replace: do-su-undo-replace
@@ -5128,3 +5149,31 @@ PKG_ERROR_HANDLER.${_class_}?= { \
exit $$ec; \
}
.endfor
+
+# Cache variables listed in MAKE_VARS in a phase-specific "makevars.mk"
+# file. These variables are effectively passed to sub-make processes
+# that are invoked on the same Makefile.
+#
+.for _phase_ in ${ALL_PHASES}
+${_MAKE_VARS_MK.${_phase_}}: ${WRKDIR}
+. if !empty(PKG_PHASE:M${_phase_})
+ ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${.TARGET}.tmp
+. for _var_ in ${MAKE_VARS:O:u}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${ECHO} ${_var_}"= "${${_var_}:Q} >> ${.TARGET}.tmp
+. endfor
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ if ${TEST} -f ${.TARGET}.tmp; then \
+ ( ${ECHO} ".if !defined(_MAKE_VARS_MK)"; \
+ ${ECHO} "_MAKE_VARS_MK= defined"; \
+ ${ECHO} ""; \
+ ${CAT} ${.TARGET}.tmp; \
+ ${ECHO} ""; \
+ ${ECHO} ".endif # _MAKE_VARS_MK"; \
+ ) > ${.TARGET}; \
+ ${RM} -f ${.TARGET}.tmp; \
+ fi
+. endif
+ ${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_FLAGS} ${.TARGET}
+.endfor
+.undef _phase_
diff --git a/mk/bsd.prefs.mk b/mk/bsd.prefs.mk
index 0744a9c8ae9..d99e159b4f9 100644
--- a/mk/bsd.prefs.mk
+++ b/mk/bsd.prefs.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.prefs.mk,v 1.188 2005/05/02 21:10:02 jlam Exp $
+# $NetBSD: bsd.prefs.mk,v 1.189 2005/05/09 05:06:55 jlam Exp $
#
# Make file, included to get the site preferences, if any. Should
# only be included by package Makefiles before any .if defined()
@@ -324,6 +324,7 @@ PKG_PHASE?= none
# The PHASES_AFTER_<phase> variables list every phase "greater than or
# equal to" <phase>.
#
+ALL_PHASES= ${PHASES_AFTER_FETCH}
PHASES_AFTER_FETCH= fetch ${PHASES_AFTER_EXTRACT}
PHASES_AFTER_EXTRACT= extract ${PHASES_AFTER_PATCH}
PHASES_AFTER_PATCH= patch ${PHASES_AFTER_TOOLS}
diff --git a/mk/buildlink3/bsd.buildlink3.mk b/mk/buildlink3/bsd.buildlink3.mk
index 283c9ac1c27..4d47c72ea5b 100644
--- a/mk/buildlink3/bsd.buildlink3.mk
+++ b/mk/buildlink3/bsd.buildlink3.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.buildlink3.mk,v 1.168 2005/02/17 12:15:44 seb Exp $
+# $NetBSD: bsd.buildlink3.mk,v 1.169 2005/05/09 05:06:55 jlam Exp $
#
# Copyright (c) 2004 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -313,9 +313,9 @@ _BLNK_PKG_DBDIR.${_pkg_}!= \
${ECHO} $$dir
. endif
. endfor
-. if empty(_BLNK_PKG_DBDIR.${_pkg_}:M*not_found)
-WRAPPER_VARS+= _BLNK_PKG_DBDIR.${_pkg_}
-. endif
+. endif
+. if empty(_BLNK_PKG_DBDIR.${_pkg_}:M*not_found)
+MAKE_VARS+= _BLNK_PKG_DBDIR.${_pkg_}
. endif
. if empty(_BLNK_PKG_DBDIR.${_pkg_}:M*not_found)
@@ -344,9 +344,9 @@ BUILDLINK_PREFIX.${_pkg_}!= \
BUILDLINK_PREFIX.${_pkg_}= BUILDLINK_PREFIX.${_pkg_}_not_found
. endif
. endif
-. if empty(BUILDLINK_PREFIX.${_pkg_}:M*not_found)
-WRAPPER_VARS+= BUILDLINK_PREFIX.${_pkg_}
-. endif
+. endif
+. if empty(BUILDLINK_PREFIX.${_pkg_}:M*not_found)
+MAKE_VARS+= BUILDLINK_PREFIX.${_pkg_}
. endif
BUILDLINK_AUTO_VARS.${_pkg_}?= yes
@@ -865,8 +865,8 @@ _BLNK_PHYSICAL_PATH.${_var_}!= \
else \
${ECHO} ${${_var_}}; \
fi
-WRAPPER_VARS+= _BLNK_PHYSICAL_PATH.${_var_}
. endif
+MAKE_VARS+= _BLNK_PHYSICAL_PATH.${_var_}
.endfor
# Transform all references to the physical paths to some important
diff --git a/mk/wrapper/bsd.wrapper.mk b/mk/wrapper/bsd.wrapper.mk
index 83487b94157..bbcb337b72e 100644
--- a/mk/wrapper/bsd.wrapper.mk
+++ b/mk/wrapper/bsd.wrapper.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.wrapper.mk,v 1.28 2005/04/07 16:56:00 tv Exp $
+# $NetBSD: bsd.wrapper.mk,v 1.29 2005/05/09 05:06:56 jlam Exp $
#
# Copyright (c) 2004 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -44,21 +44,11 @@ ECHO_WRAPPER_MSG?= ${ECHO}
.else
ECHO_WRAPPER_MSG?= ${TRUE}
.endif
-_WRAP_VARS_MK= ${WRAPPER_DIR}/vars.mk
-
-.if exists(${_WRAP_VARS_MK})
-. include "${_WRAP_VARS_MK}"
-.endif
.PHONY: do-wrapper
.include "../../mk/buildlink3/bsd.buildlink3.mk"
-# Create the saved variables Makefile fragment to pass variables
-# through to sub-make processes invoked on the same Makefile.
-#
-do-wrapper: ${_WRAP_VARS_MK}
-
# Prepend ${WRAPPER_BINDIR} to the PATH so that the wrappers are found
# first when searching for executables.
#
@@ -111,9 +101,9 @@ _WRAP_TRANSFORM_CMDS+= ${WRAPPER_TRANSFORM_CMDS}
# are already being called with the correct arguments.
#
.if !defined(_WRAP_PATH)
-_WRAP_PATH= ${PATH:S/${WRAPPER_BINDIR}://:S/:${WRAPPER_BINDIR}//}
-WRAPPER_VARS+= _WRAP_PATH
+_WRAP_PATH= ${PATH:S/${WRAPPER_BINDIR}://:S/:${WRAPPER_BINDIR}//}
.endif
+MAKE_VARS+= _WRAP_PATH
# Generate wrapper scripts for the compiler tools. These wrapper
# scripts are to be used instead of the actual compiler tools when
@@ -697,22 +687,6 @@ ${_WRAP_SCAN.${_wrappee_}}: ${WRAPPER_SRCDIR}/scan
. endif
.endfor # _WRAPPEES
-.if !target(${_WRAP_VARS_MK})
-${_WRAP_VARS_MK}:
- ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
- ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${.TARGET}.tmp
-. for _var_ in ${WRAPPER_VARS}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- ${ECHO} "${_var_}= ${${_var_}}" >> ${.TARGET}.tmp
-. endfor
- ${_PKG_SILENT}${_PKG_DEBUG} \
- if [ -f ${.TARGET}.tmp ]; then \
- ${SORT} -u ${.TARGET}.tmp > ${.TARGET}; \
- ${RM} -f ${.TARGET}.tmp; \
- fi
- ${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_FLAGS} ${.TARGET}
-.endif
-
# UNWRAP_PATTERNS and UNWRAP_FILES list shell globs and files relative to
# ${WRKSRC} that need to be "unwrapped".
#