blob: 0c4c5458ce8de942941b40d19f7b44e80680feb3 (
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
|
# $NetBSD: pkg-build-options.mk,v 1.16 2020/03/15 10:33:42 rillig Exp $
#
# This procedure determines the PKG_OPTIONS that have been in effect
# when the package ${pkgbase} has been built. When the package is not
# yet installed, its current PKG_OPTIONS are queried.
#
# Parameters:
# pkgbase
# The package identifier, as in the package's buildlink3.mk
# file.
#
# Returns:
# PKG_BUILD_OPTIONS.${pkgbase}
# The build options of the package.
#
# Example:
# # in emulators/wine/buildlink3.mk
# pkgbase := wine
# .include "../../mk/pkg-build-options.mk"
#
# Keywords: options pkg-build-options PKG_BUILD_OPTIONS
#
.if !defined(pkgbase)
. for including in ${.INCLUDEDFROMDIR}/${.INCLUDEDFROMFILE}
PKG_FAIL_REASON+= "[pkg-build-options.mk] ${including}: pkgbase must be set"
. endfor
.endif
.include "bsd.fast.prefs.mk"
# For the check for inclusion from non-buildlink3.mk, it is irrelevant
# whether BUILDLINK_TREE was empty or undefined, so defining it here
# avoids dealing one case.
BUILDLINK_TREE?=
# Counting words doesn't work as expected for empty strings, they
# still have one word. Older make doesn't like the code without
# variable assignment for unknown reasons.
_BUILDLINK_TREE_WITH:= ${BUILDLINK_TREE:M-*:[\#]}
_BUILDLINK_TREE_WITHOUT:= ${BUILDLINK_TREE:N-*:[\#]}
.if (empty(BUILDLINK_TREE:M-*) && empty(BUILDLINK_TREE:N-*)) || \
(!empty(BUILDLINK_TREE:M-*) && !empty(BUILDLINK_TREE:N-*) && \
${_BUILDLINK_TREE_WITH} == ${_BUILDLINK_TREE_WITHOUT})
. for b in ${pkgbase}
PKG_BUILD_OPTIONS.${b}=
PKG_FAIL_REASON+= "[pkg-build-options.mk] This file may only be included from a buildlink3.mk file (pkgbase=${b})."
. endfor
.else
. for b in ${pkgbase}
. if !defined(PKG_BUILD_OPTIONS.${b}) && defined(PBULK_CACHE_DIRECTORY)
.sinclude "${PBULK_CACHE_DIRECTORY}/build-options.${b}"
. endif
. if !defined(PKG_BUILD_OPTIONS.${b})
PKG_BUILD_OPTIONS.${b}!= \
echo ""; \
${PKG_INFO} -Q PKG_OPTIONS ${b} 2>/dev/null \
|| { cd ${BUILDLINK_PKGSRCDIR.${b}} \
&& ${MAKE} ${MAKEFLAGS} show-var VARNAME=PKG_OPTIONS; }
. if defined(PBULK_CACHE_DIRECTORY)
_PKG_BUILD_OPTIONS.${b}!= \
mkdir -p ${PBULK_CACHE_DIRECTORY:Q}; \
echo PKG_BUILD_OPTIONS.${b:Q}=${PKG_BUILD_OPTIONS.${b:Q}} > ${PBULK_CACHE_DIRECTORY:Q}/build-options.${pkgbase}.$$$$; \
mv ${PBULK_CACHE_DIRECTORY:Q}/build-options.${pkgbase}.$$$$ ${PBULK_CACHE_DIRECTORY:Q}/build-options.${pkgbase}
. endif
MAKEFLAGS+= PKG_BUILD_OPTIONS.${b}=${PKG_BUILD_OPTIONS.${b}:Q}
. endif
MAKEVARS+= PKG_BUILD_OPTIONS.${b}
. endfor
.endif
.undef pkgbase # prepare for the next invocation
|