diff options
author | joerg <joerg@pkgsrc.org> | 2009-03-20 19:23:50 +0000 |
---|---|---|
committer | joerg <joerg@pkgsrc.org> | 2009-03-20 19:23:50 +0000 |
commit | 2d1ba244e90207d03eef397a99aa4091baeec5b3 (patch) | |
tree | 647e974495c5d41703d41ca2e71c9b6063b9153a /mk/buildlink3 | |
parent | 4bf0a20854ae9e07b7965977a713f2efee890976 (diff) | |
download | pkgsrc-2d1ba244e90207d03eef397a99aa4091baeec5b3.tar.gz |
Simply and speed up buildlink3.mk files and processing.
This changes the buildlink3.mk files to use an include guard for the
recursive include. The use of BUILDLINK_DEPTH, BUILDLINK_DEPENDS,
BUILDLINK_PACKAGES and BUILDLINK_ORDER is handled by a single new
variable BUILDLINK_TREE. Each buildlink3.mk file adds a pair of
enter/exit marker, which can be used to reconstruct the tree and
to determine first level includes. Avoiding := for large variables
(BUILDLINK_ORDER) speeds up parse time as += has linear complexity.
The include guard reduces system time by avoiding reading files over and
over again. For complex packages this reduces both %user and %sys time to
half of the former time.
Diffstat (limited to 'mk/buildlink3')
-rw-r--r-- | mk/buildlink3/bsd.buildlink3.mk | 67 | ||||
-rw-r--r-- | mk/buildlink3/bsd.builtin.mk | 6 | ||||
-rw-r--r-- | mk/buildlink3/show-buildlink3.sh | 24 |
3 files changed, 55 insertions, 42 deletions
diff --git a/mk/buildlink3/bsd.buildlink3.mk b/mk/buildlink3/bsd.buildlink3.mk index 6336939ab02..b8b1da459c3 100644 --- a/mk/buildlink3/bsd.buildlink3.mk +++ b/mk/buildlink3/bsd.buildlink3.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.buildlink3.mk,v 1.204 2009/03/16 18:37:07 joerg Exp $ +# $NetBSD: bsd.buildlink3.mk,v 1.205 2009/03/20 19:25:01 joerg Exp $ # # Copyright (c) 2004 The NetBSD Foundation, Inc. # All rights reserved. @@ -37,33 +37,26 @@ # An example package buildlink3.mk file: # # -------------8<-------------8<-------------8<-------------8<------------- -# BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+ -# FOO_BUILDLINK3_MK:= ${FOO_BUILDLINK3_MK}+ +# BUILDLINK_TREE+= foo # -# .if !empty(BUILDLINK_DEPTH:M+) -# BUILDLINK_DEPENDS+= foo -# .endif +# .if !defined(FOO_BUILDLINK3_MK) +# FOO_BUILDLINK3_MK:= # -# BUILDLINK_PACKAGES:= ${BUILDLINK_PACKAGES:Nfoo} -# BUILDLINK_PACKAGES+= foo -# -# .if !empty(FOO_BUILDLINK3_MK:M+) # BUILDLINK_API_DEPENDS.foo+= foo-lib>=1.0 # BUILDLINK_ABI_DEPENDS.foo?= foo-lib>=1.0nb1 # BUILDLINK_PKGSRCDIR.foo?= ../../category/foo-lib # # # We want "-lbar" to eventually resolve to "-lfoo". # BUILDLINK_TRANSFORM+= l:bar:foo -# .endif # FOO_BUILDLINK3_MK # # .include "../../category/baz/buildlink3.mk" +# .endif # FOO_BUILDLINK3_MK # -# BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/+$//} +# BUILDLINK_TREE+= -foo # -------------8<-------------8<-------------8<-------------8<------------- # # Most of the buildlink3.mk file is protected against multiple inclusion, -# except for the parts related to manipulating BUILDLINK_DEPTH and adding -# to BUILDLINK_DEPENDS. +# except for the parts related to manipulating BUILDLINK_TREE. # # Note that if a buildlink3.mk file is included, then the package Makefile # has the expectation that it can use the value of BUILDLINK_PREFIX.<pkg>. @@ -100,23 +93,42 @@ BUILDLINK_X11_DIR= ${BUILDLINK_DIR:H}/.x11-buildlink # Prepend ${BUILDLINK_BINDIR} to the PATH. PREPEND_PATH+= ${BUILDLINK_BINDIR} -# BUILDLINK_DEPENDS contains the list of packages for which we add -# dependencies. +# _BUILDLINK_DEPENDS contains the list of packages for which we add +# dependencies. This is only done for direct dependencies. # -BUILDLINK_DEPENDS?= # empty +_BUILDLINK_DEPENDS:= +_BUILDLINK_DEPTH:= +.for _pkg_ in ${BUILDLINK_TREE} +_BUILDLINK_pkg:= ${_pkg_:N-*} +. if empty(_BUILDLINK_pkg) +_BUILDLINK_DEPTH:= ${_BUILDLINK_DEPTH:S/+$//} +. else +. if empty(_BUILDLINK_DEPTH) +_BUILDLINK_DEPENDS+= ${_pkg_} +. endif +_BUILDLINK_DEPTH:= ${_BUILDLINK_DEPTH}+ +. endif +.endfor # For each package we use, check whether we are using the built-in # version of the package or if we are using the pkgsrc version. # -.for _pkg_ in ${BUILDLINK_PACKAGES} +.for _pkg_ in ${BUILDLINK_TREE:N-*} +.if !defined(_BUILDLINK_BUILTIN_MK_INCLUDED.${_pkg_}) +_BUILDLINK_BUILTIN_MK_INCLUDED.${_pkg_}= BUILDLINK_BUILTIN_MK.${_pkg_}?= ${BUILDLINK_PKGSRCDIR.${_pkg_}}/builtin.mk . sinclude "${BUILDLINK_BUILTIN_MK.${_pkg_}}" +.endif .endfor +# Sorted and unified version of BUILDLINK_TREE without recursion +# data. +_BUILDLINK_TREE:= ${BUILDLINK_TREE:N-*:O:u} + # Set IGNORE_PKG.<pkg> if <pkg> is the current package we're building. # We can then check for this value to avoid build loops. # -.for _pkg_ in ${BUILDLINK_PACKAGES} +.for _pkg_ in ${_BUILDLINK_TREE} . if defined(BUILDLINK_PKGSRCDIR.${_pkg_}) . if !defined(IGNORE_PKG.${_pkg_}) && \ (${BUILDLINK_PKGSRCDIR.${_pkg_}:C|.*/([^/]*/[^/]*)$|\1|} == ${PKGPATH}) @@ -126,12 +138,15 @@ MAKEFLAGS+= IGNORE_PKG.${_pkg_}=${IGNORE_PKG.${_pkg_}} . endif .endfor -# _BLNK_PACKAGES contains all of the unique elements of BUILDLINK_PACKAGES +# _BLNK_PACKAGES contains all of the unique elements of BUILDLINK_TREE # that shouldn't be skipped. # +# This does not use _BUILDLINK_TREE as the order matters. x11-links is +# sorted first to allow other packages to override the content. +# _BLNK_PACKAGES= # empty -.for _pkg_ in ${BUILDLINK_PACKAGES} -. if empty(_BLNK_PACKAGES:M${_pkg_}) && !defined(IGNORE_PKG.${_pkg_}) +.for _pkg_ in ${BUILDLINK_TREE:N-*:Mx11-links} ${BUILDLINK_TREE:N-*:Nx11-links} +. if !defined(IGNORE_PKG.${_pkg_}) _BLNK_PACKAGES+= ${_pkg_} . endif .endfor @@ -140,7 +155,7 @@ _VARGROUPS+= bl3 .for v in BINDIR CFLAGS CPPFLAGS DEPENDS LDFLAGS LIBS _SYS_VARS.bl3+= BUILDLINK_${v} .endfor -.for p in ${BUILDLINK_PACKAGES} +.for p in ${_BUILDLINK_TREE} . for v in AUTO_VARS BUILTIN_MK CONTENTS_FILTER CPPFLAGS DEPMETHOD FILES_CMD INCDIRS IS_DEPOT LDFLAGS LIBDIRS PKGNAME PREFIX RPATHDIRS _SYS_VARS.bl3+= BUILDLINK_${v}.${p} . endfor @@ -157,7 +172,7 @@ BUILDLINK_DEPMETHOD.${_pkg_}?= full # _BLNK_DEPENDS contains all of the elements of _BLNK_PACKAGES for which # we must add a dependency. We add a dependency if we aren't using the # built-in version of the package, and the package was either explicitly -# requested as a dependency (BUILDLINK_DEPENDS) or is a build dependency +# requested as a dependency (_BUILDLINK_DEPENDS) or is a build dependency # somewhere in the chain. # _BLNK_DEPENDS= # empty @@ -165,7 +180,7 @@ _BLNK_DEPENDS= # empty USE_BUILTIN.${_pkg_}?= no . if empty(_BLNK_DEPENDS:M${_pkg_}) && !defined(IGNORE_PKG.${_pkg_}) && \ !empty(USE_BUILTIN.${_pkg_}:M[nN][oO]) && \ - (!empty(BUILDLINK_DEPENDS:M${_pkg_}) || \ + (!empty(_BUILDLINK_DEPENDS:M${_pkg_}) || \ !empty(BUILDLINK_DEPMETHOD.${_pkg_}:Mbuild)) _BLNK_DEPENDS+= ${_pkg_} . endif @@ -1120,4 +1135,4 @@ do-buildlink: .PHONY: show-buildlink3 show-buildlink3: - @${SH} ${PKGSRCDIR}/mk/buildlink3/show-buildlink3.sh ${BUILDLINK_ORDER} + @${SH} ${PKGSRCDIR}/mk/buildlink3/show-buildlink3.sh ${BUILDLINK_TREE} diff --git a/mk/buildlink3/bsd.builtin.mk b/mk/buildlink3/bsd.builtin.mk index a614ac13920..578c84b81f4 100644 --- a/mk/buildlink3/bsd.builtin.mk +++ b/mk/buildlink3/bsd.builtin.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.builtin.mk,v 1.9 2008/01/23 17:35:20 tnn Exp $ +# $NetBSD: bsd.builtin.mk,v 1.10 2009/03/20 19:25:01 joerg Exp $ # # Copyright (c) 2004-2005 The NetBSD Foundation, Inc. # All rights reserved. @@ -35,8 +35,8 @@ # POSSIBILITY OF SUCH DAMAGE. # Include this file to set the value of USE_BUILTIN.<pkg> for each -# package listed in BUILDLINK_PACKAGES. Note that this file may -# indirectly add additional values to BUILDLINK_PACKAGES. +# package listed in BUILDLINK_TREE. Note that this file may +# indirectly add additional values to BUILDLINK_TREE. # # For each package which may duplicate built-in software on the system, # a builtin.mk file should be created. The only requirements of a diff --git a/mk/buildlink3/show-buildlink3.sh b/mk/buildlink3/show-buildlink3.sh index 1d2255158d2..1fa109ffdea 100644 --- a/mk/buildlink3/show-buildlink3.sh +++ b/mk/buildlink3/show-buildlink3.sh @@ -1,23 +1,21 @@ #!/bin/sh # -# $NetBSD: show-buildlink3.sh,v 1.1 2006/07/08 23:11:17 jlam Exp $ +# $NetBSD: show-buildlink3.sh,v 1.2 2009/03/20 19:25:01 joerg Exp $ # # This script is a helper for the show-buildlink3 target and outputs -# the arguments, each on a new line with any leading "+" signs replaced -# with four spaces. +# the arguments as tree. # while test $# -gt 0; do pkg="$1" - pkg="${pkg#+}" - prefix= - stripped=no - while test $stripped = no; do - case $pkg in - +*) prefix=" $prefix"; pkg="${pkg#+}"; stripped=no ;; - *) stripped=yes ;; - esac - done - echo "$prefix$pkg" + case $pkg in + -*) + indentation=${indendation# } + ;; + *) + echo "${indentation}${pkg}" + indentation="${indentation} " + ;; + esac shift done |