summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorjoerg <joerg@pkgsrc.org>2007-05-09 23:33:51 +0000
committerjoerg <joerg@pkgsrc.org>2007-05-09 23:33:51 +0000
commit79cc54a7ec05ff1b8133a1bbfcd384822e836085 (patch)
tree05d9b67d8778e1265cbc2f4152928df22927e918 /mk
parent0159c64b22f5e3c0e33977383c9f967c7a144cab (diff)
downloadpkgsrc-79cc54a7ec05ff1b8133a1bbfcd384822e836085.tar.gz
Add two targets, pbulk-index and pbulk-index-item.
pbulk-index-item prints a number of variables used by the parallel bulk build code during either the build, the report or the upload phase. pbulk-index checks whether multiple versions of the current package could be build (e.g. because multiple Python versions are supported) and uses pbulk-index-item for each possible combination. Thanks to David Laight for explaining the different between using :[#] in the body of a make target and in a clause of an .if. Powered-by: Google SoC 2007.
Diffstat (limited to 'mk')
-rw-r--r--mk/bsd.pkg.mk6
-rw-r--r--mk/bsd.pkg.subdir.mk4
-rw-r--r--mk/pbulk/pbulk-index.mk101
3 files changed, 108 insertions, 3 deletions
diff --git a/mk/bsd.pkg.mk b/mk/bsd.pkg.mk
index 916e6d58637..88d8b65d1ed 100644
--- a/mk/bsd.pkg.mk
+++ b/mk/bsd.pkg.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.mk,v 1.1910 2007/04/01 19:02:14 kristerw Exp $
+# $NetBSD: bsd.pkg.mk,v 1.1911 2007/05/09 23:33:51 joerg Exp $
#
# This file is in the public domain.
#
@@ -812,6 +812,10 @@ ${_MAKEVARS_MK.${_phase_}}: ${WRKDIR}
${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_FLAGS} ${.TARGET}
.endfor
+.if make(pbulk-index) || make(pbulk-index-item)
+.include "${.PARSEDIR}/pbulk/pbulk-index.mk"
+.endif
+
.if defined(PKG_DEVELOPER)
. include "${.PARSEDIR}/misc/developer.mk"
.endif
diff --git a/mk/bsd.pkg.subdir.mk b/mk/bsd.pkg.subdir.mk
index 6fced25f361..86fa7851b61 100644
--- a/mk/bsd.pkg.subdir.mk
+++ b/mk/bsd.pkg.subdir.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.subdir.mk,v 1.65 2006/07/27 21:46:45 jlam Exp $
+# $NetBSD: bsd.pkg.subdir.mk,v 1.66 2007/05/09 23:33:52 joerg Exp $
# Derived from: FreeBSD Id: bsd.port.subdir.mk,v 1.19 1997/03/09 23:10:56 wosch Exp
# from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91
#
@@ -90,7 +90,7 @@ ${SUBDIR}::
show-downlevel show-pkgsrc-dir show-var show-vars \
bulk-install bulk-package fetch-list-one-pkg \
fetch-list-recursive update clean-update lint \
- check-vulnerable \
+ check-vulnerable pbulk-index \
${PKG_MISC_TARGETS}
.if !target(__target)
.PHONY: ${__target}
diff --git a/mk/pbulk/pbulk-index.mk b/mk/pbulk/pbulk-index.mk
new file mode 100644
index 00000000000..bc82591159c
--- /dev/null
+++ b/mk/pbulk/pbulk-index.mk
@@ -0,0 +1,101 @@
+# $NetBSD: pbulk-index.mk,v 1.1 2007/05/09 23:33:52 joerg Exp $
+
+# This Makefile fragment is included by bsd.pkg.mk and provides all
+# variables and targets related to the parallel bulk build
+# tree-scanning code.
+#
+# The following are the "public" targets provided by this module:
+#
+# pbulk-index
+# pbulk-index-item
+
+#
+# _PBULK_MULTI lists the multi-package variable.
+# For each class the following variables are provided:
+# _PBULK_MULTI_LIST.foo enumerates the supported settings
+# _PBULK_MULTI_VAR.foo forces a specific version
+# _PBULK_MULTI_DEFAULT.foo contains the default value
+
+_PBULK_MULTI= apache php python
+
+_PBULK_MULTI_LIST.apache= PKG_APACHE_ACCEPTED
+_PBULK_MULTI_VAR.apache= PKG_APACHE
+_PBULK_MULTI_DEFAULT.apache= PKG_APACHE_DEFAULT
+
+_PBULK_MULTI_LIST.php= PHP_VERSIONS_ACCEPTED
+_PBULK_MULTI_VAR.php= PHP_VERSION_REQD
+_PBULK_MULTI_DEFAULT.php= PHP_VERSION_DEFAULT
+
+_PBULK_MULTI_LIST.python= PYTHON_VERSIONS_ACCEPTED
+_PBULK_MULTI_VAR.python= PYTHON_VERSION_REQD
+_PBULK_MULTI_DEFAULT.python= PYTHON_VERSION_DEFAULT
+
+.PHONY: pbulk-index pbulk-index-item
+
+# Find all classes with more than one supported setting.
+# Undefined list variables are handled like a single default value,
+# empty list variables are checked afterwards.
+#
+# For each such class, reorder the supported values to list
+# the default value first. This is important for packages that
+# don't follow the module naming conventions.
+
+.for _t in ${_PBULK_MULTI}
+. if ${${_PBULK_MULTI_LIST.${_t}}:Unone:[\#]} != 1 && !empty(${_PBULK_MULTI_LIST.${_t}})
+_PBULK_MULTI_NEEDED:= ${_t} ${_PBULK_MULTI_NEEDED}
+_PBULK_SORTED_LIST.${_t}:= \
+ ${${_PBULK_MULTI_LIST.${_t}}:M${${_PBULK_MULTI_DEFAULT.${_t}}}} \
+ ${${_PBULK_MULTI_LIST.${_t}}:N${${_PBULK_MULTI_DEFAULT.${_t}}}}
+. endif
+.endfor
+
+.if !defined(_PBULK_MULTI_NEEDED)
+# No multi-package handling needed, directly print the item.
+pbulk-index: pbulk-index-item
+.else
+#
+# Use an ODE for loop to compute the carthesian product of
+# the support settings. This expands to something like
+#
+# for apache in apache13 apache2; do \
+# _PBULK_MULTI_VALUE.apache=$apache; \
+# export _PBULK_MULTI_VALUE.apache; \
+# PKG_APACHE=$apache; \
+# export PKG_APACHE; \
+# for php in 4 5; do \
+# _PBULK_MULTI_VALUE.php=$php; \
+# export _PBULK_MULTI_VALUE.php; \
+# PHP_VERSION_REQD=$php; \
+# export PHP_VERSION_REQD;
+#
+# Because the ODE expansion happens in the same shell instance,
+# make gets the environment variables in the inner-most loop.
+# A second ODE for loop is used to close the shell for loops.
+#
+pbulk-index:
+ @${_PBULK_MULTI_NEEDED:@._t.@\
+ for ${._t.} in ${_PBULK_SORTED_LIST.${._t.}}; do \
+ _PBULK_MULTI_VALUE_${._t.}=$$${._t.}; \
+ export _PBULK_MULTI_VALUE_${._t.}; \
+ ${_PBULK_MULTI_VAR.${._t.}}=$$${._t.}; \
+ export ${_PBULK_MULTI_VAR.${._t.}};@} \
+ ${MAKE} pbulk-index-item \
+ ${_PBULK_MULTI_NEEDED:@._t.@;done@}
+.endif
+
+pbulk-index-item:
+ @echo "PKGNAME="${PKGNAME:Q}
+ @echo "ALL_DEPENDS="${_ALL_DEPENDS:Q}
+ @echo "PKG_SKIP_REASON="${PKG_SKIP_REASON:Q}
+ @echo "PKG_FAIL_REASON="${PKG_FAIL_REASON:Q}
+ @echo "NO_BIN_ON_FTP="${NO_BIN_ON_FTP:Q}
+ @echo "RESTRICTED="${RESTRICTED:Q}
+ @echo "CATEGORIES="${CATEGORIES:Q}
+ @echo "MAINTAINER="${MAINTAINER:Q}
+.if defined(_PBULK_MULTI_NEEDED)
+ @printf "MULTI_VERSION="
+.for _t in ${_PBULK_MULTI_NEEDED}
+ @printf " %s=%s" ${_PBULK_MULTI_VAR.${_t}:Q} ${_PBULK_MULTI_VALUE_${_t}:Q}
+.endfor
+ @printf "\n"
+.endif