pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc Teach bsd.pkg.mk to create a phase-specific "makevars....



details:   https://anonhg.NetBSD.org/pkgsrc/rev/a9addfe0b96d
branches:  trunk
changeset: 493537:a9addfe0b96d
user:      jlam <jlam%pkgsrc.org@localhost>
date:      Mon May 09 05:06:55 2005 +0000

description:
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:

 databases/openldap/buildlink3.mk |   6 +-
 devel/apr/buildlink3.mk          |   4 +-
 misc/kdepim3/buildlink3.mk       |   8 ++--
 mk/bsd.pkg.mk                    |  79 ++++++++++++++++++++++++++++++++-------
 mk/bsd.prefs.mk                  |   3 +-
 mk/buildlink3/bsd.buildlink3.mk  |  16 ++++----
 mk/wrapper/bsd.wrapper.mk        |  32 +--------------
 security/heimdal/buildlink3.mk   |   6 +-
 security/openssl/buildlink3.mk   |   6 +-
 x11/kdebase3/buildlink3.mk       |   6 +-
 x11/kdelibs3/buildlink3.mk       |   6 +-
 11 files changed, 98 insertions(+), 74 deletions(-)

diffs (truncated from 391 to 300 lines):

diff -r f89e868cb504 -r a9addfe0b96d databases/openldap/buildlink3.mk
--- a/databases/openldap/buildlink3.mk  Mon May 09 04:29:16 2005 +0000
+++ b/databases/openldap/buildlink3.mk  Mon May 09 05:06:55 2005 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: buildlink3.mk,v 1.16 2005/05/08 12:03:56 jlam Exp $
+# $NetBSD: buildlink3.mk,v 1.17 2005/05/09 05:06:55 jlam Exp $
 
 BUILDLINK_DEPTH:=              ${BUILDLINK_DEPTH}+
 OPENLDAP_BUILDLINK3_MK:=       ${OPENLDAP_BUILDLINK3_MK}+
@@ -22,9 +22,9 @@
 PKG_OPTIONS.openldap!=                                                 \
        cd ${BUILDLINK_PKGSRCDIR.openldap} &&                           \
        ${MAKE} show-var ${MAKE_FLAGS} VARNAME=PKG_OPTIONS
-MAKE_FLAGS+=                   PKG_OPTIONS.openldap=${PKG_OPTIONS.openldap:Q}
-WRAPPER_VARS+=                 PKG_OPTIONS.openldap
+MAKE_FLAGS+=           PKG_OPTIONS.openldap=${PKG_OPTIONS.openldap:Q}
 .endif
+MAKE_VARS+=            PKG_OPTIONS.openldap
 
 .if !empty(PKG_OPTIONS.openldap:Mkerberos) || \
     !empty(PKG_OPTIONS.openldap:Msasl)
diff -r f89e868cb504 -r a9addfe0b96d devel/apr/buildlink3.mk
--- a/devel/apr/buildlink3.mk   Mon May 09 04:29:16 2005 +0000
+++ b/devel/apr/buildlink3.mk   Mon May 09 05:06:55 2005 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: buildlink3.mk,v 1.14 2005/05/08 12:03:56 jlam Exp $
+# $NetBSD: buildlink3.mk,v 1.15 2005/05/09 05:06:55 jlam Exp $
 
 BUILDLINK_DEPTH:=      ${BUILDLINK_DEPTH}+
 APR_BUILDLINK3_MK:=    ${APR_BUILDLINK3_MK}+
@@ -28,8 +28,8 @@
 PKG_OPTIONS.apr!=      cd ${BUILDLINK_PKGSRCDIR.apr} && \
                        ${MAKE} show-var ${MAKE_FLAGS} VARNAME=PKG_OPTIONS
 MAKE_FLAGS+=           PKG_OPTIONS.apr=${PKG_OPTIONS.apr:Q}
-WRAPPER_VARS+=         PKG_OPTIONS.apr
 .endif
+MAKE_VARS+=            PKG_OPTIONS.apr
 
 .if !empty(PKG_OPTIONS.apr:Mdb4)
 .  include "../../databases/db4/buildlink3.mk"
diff -r f89e868cb504 -r a9addfe0b96d misc/kdepim3/buildlink3.mk
--- a/misc/kdepim3/buildlink3.mk        Mon May 09 04:29:16 2005 +0000
+++ b/misc/kdepim3/buildlink3.mk        Mon May 09 05:06:55 2005 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: buildlink3.mk,v 1.7 2005/05/08 12:03:56 jlam Exp $
+# $NetBSD: buildlink3.mk,v 1.8 2005/05/09 05:06:56 jlam Exp $
 
 BUILDLINK_DEPTH:=      ${BUILDLINK_DEPTH}+
 KDEPIM_BUILDLINK3_MK:= ${KDEPIM_BUILDLINK3_MK}+
@@ -20,9 +20,9 @@
 PKG_OPTIONS.kdepim!=                                                   \
        cd ${BUILDLINK_PKGSRCDIR.kdepim} &&                             \
        ${MAKE} show-var ${MAKE_FLAGS} VARNAME=PKG_OPTIONS
-MAKE_FLAGS+=                   PKG_OPTIONS.kdepim=${PKG_OPTIONS.kdepim:Q}
-WRAPPER_VARS+=                 PKG_OPTIONS.kdepim
+MAKE_FLAGS+=           PKG_OPTIONS.kdepim=${PKG_OPTIONS.kdepim:Q}
 .endif
+MAKE_VARS+=            PKG_OPTIONS.kdepim
 
 .include "../../comms/libmal/buildlink3.mk"
 .include "../../comms/pilot-link-libs/buildlink3.mk"
@@ -33,4 +33,4 @@
 .include "../../x11/kdebase3/buildlink3.mk"
 .include "../../x11/kdelibs3/buildlink3.mk"
 
-BUILDLINK_DEPTH:=     ${BUILDLINK_DEPTH:S/+$//}
+BUILDLINK_DEPTH:=      ${BUILDLINK_DEPTH:S/+$//}
diff -r f89e868cb504 -r a9addfe0b96d mk/bsd.pkg.mk
--- a/mk/bsd.pkg.mk     Mon May 09 04:29:16 2005 +0000
+++ b/mk/bsd.pkg.mk     Mon May 09 05:06:55 2005 +0000
@@ -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 @@
        ${_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 @@
 .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 @@
                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 -r f89e868cb504 -r a9addfe0b96d mk/bsd.prefs.mk
--- a/mk/bsd.prefs.mk   Mon May 09 04:29:16 2005 +0000
+++ b/mk/bsd.prefs.mk   Mon May 09 05:06:55 2005 +0000
@@ -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 @@
 # 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 -r f89e868cb504 -r a9addfe0b96d mk/buildlink3/bsd.buildlink3.mk
--- a/mk/buildlink3/bsd.buildlink3.mk   Mon May 09 04:29:16 2005 +0000
+++ b/mk/buildlink3/bsd.buildlink3.mk   Mon May 09 05:06:55 2005 +0000
@@ -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 @@
        ${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_}_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 @@
        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 -r f89e868cb504 -r a9addfe0b96d mk/wrapper/bsd.wrapper.mk
--- a/mk/wrapper/bsd.wrapper.mk Mon May 09 04:29:16 2005 +0000
+++ b/mk/wrapper/bsd.wrapper.mk Mon May 09 05:06:55 2005 +0000
@@ -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 @@
 .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 @@
 # 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 @@
 .  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;                                \



Home | Main Index | Thread Index | Old Index