summaryrefslogtreecommitdiff
path: root/mk/pbulk/pbulk-index.mk
blob: 60d50e231984a6827d96f3653c3fad7e3a30cb63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#	$NetBSD: pbulk-index.mk,v 1.20 2014/06/10 15:22:14 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 lua mysql php postgresql python ruby

_PBULK_MULTI_LIST.apache=	PKG_APACHE_ACCEPTED
_PBULK_MULTI_VAR.apache=	PKG_APACHE
_PBULK_MULTI_DEFAULT.apache=	PKG_APACHE_DEFAULT

_PBULK_MULTI_LIST.lua=		_LUA_VERSIONS_ACCEPTED
_PBULK_MULTI_VAR.lua=		LUA_VERSION_REQD
_PBULK_MULTI_DEFAULT.lua=	LUA_VERSION_DEFAULT

_PBULK_MULTI_LIST.mysql=	MYSQL_VERSIONS_ACCEPTED
_PBULK_MULTI_VAR.mysql=		MYSQL_VERSION_REQD
_PBULK_MULTI_DEFAULT.mysql=	MYSQL_VERSION_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.postgresql=		PGSQL_VERSIONS_ACCEPTED
_PBULK_MULTI_VAR.postgresql=		PGSQL_VERSION_REQD
_PBULK_MULTI_DEFAULT.postgresql=	PGSQL_VERSION_DEFAULT

_PBULK_MULTI_LIST.python=	_PYTHON_VERSIONS_ACCEPTED
_PBULK_MULTI_VAR.python=	PYTHON_VERSION_REQD
_PBULK_MULTI_DEFAULT.python=	PYTHON_VERSION_DEFAULT

_PBULK_MULTI_LIST.ruby=		RUBY_VERSION_SUPPORTED
_PBULK_MULTI_VAR.ruby=		RUBY_VERSION_REQD
_PBULK_MULTI_DEFAULT.ruby=	RUBY_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.

.if !defined(NO_MULTI_PKG)
. for _t in ${_PBULK_MULTI}
.  if defined(${_PBULK_MULTI_LIST.${_t}}) && !empty(${_PBULK_MULTI_LIST.${_t}})
.    if ${${_PBULK_MULTI_LIST.${_t}}:[\#]} != 1 || \
        !empty(${_PBULK_MULTI_LIST.${_t}}:N${_PBULK_MULTI_DEFAULT.${_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
.  endif
. endfor
.endif

.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 apache22 apache24; 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:
	@set -e; ${_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}
	@echo "USE_DESTDIR="${_USE_DESTDIR:Q}
	@echo "BOOTSTRAP_PKG="${BOOTSTRAP_PKG}
	@echo "USERGROUP_PHASE="${USERGROUP_PHASE:Q}
	@echo "SCAN_DEPENDS="${.MAKE.MAKEFILES: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

pbulk-save-wrkdir:
	${RUN} [ ! -d ${WRKDIR} ] || cd ${WRKDIR} && ${TAR} cfz ${INTO:Q} .