Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / mk / pkg-build-options.mk
blob7d960b318f9992ea4ff6d4ae85a54c47cd26659b
1 # $NetBSD: pkg-build-options.mk,v 1.8 2009/03/20 19:25:01 joerg Exp $
3 # This procedure determines the PKG_OPTIONS that have been in effect
4 # when the package ${pkgbase} has been built. When the package is not
5 # yet installed, the current PKG_OPTIONS are queried.
7 # Parameters:
8 # pkgbase
9 # The basename of the package.
11 # Returns:
12 # PKG_BUILD_OPTIONS.${pkgbase}
13 # The build options of the package.
15 # Example:
16 # pkgbase := wine
17 # .include "../../mk/pkg-build-options.mk"
19 # Keywords: options pkg-build-options PKG_BUILD_OPTIONS
22 .include "bsd.fast.prefs.mk"
24 # For the check for inclusion from non-buildlink3.mk, it is irrelevant
25 # whether BUILDLINK_TREE was empty or undefined, so defining it here
26 # avoids dealing one case.
27 BUILDLINK_TREE?=
29 # Counting words doesn't work as expected for empty strings, they
30 # still have one word. Older make doesn't like the code without
31 # variable assignment for unknown reasons.
32 _BUILDLINK_TREE_WITH:= ${BUILDLINK_TREE:M-*:[\#]}
33 _BUILDLINK_TREE_WITHOUT:= ${BUILDLINK_TREE:N-*:[\#]}
34 .if (empty(BUILDLINK_TREE:M-*) && empty(BUILDLINK_TREE:N-*)) || \
35 (!empty(BUILDLINK_TREE:M-*) && !empty(BUILDLINK_TREE:N-*) && \
36 ${_BUILDLINK_TREE_WITH} == ${_BUILDLINK_TREE_WITHOUT})
37 . for b in ${pkgbase}
38 PKG_BUILD_OPTIONS.${b}=
39 PKG_FAIL_REASON+= "[pkg-build-options.mk] This file may only be included from a buildlink3.mk file (pkgbase=${b})."
40 . endfor
41 .else
42 . for b in ${pkgbase}
43 . if !defined(PKG_BUILD_OPTIONS.${b})
44 PKG_BUILD_OPTIONS.${b} != \
45 echo ""; \
46 ${PKG_INFO} -Q PKG_OPTIONS ${b} 2>/dev/null \
47 || { cd ${BUILDLINK_PKGSRCDIR.${b}} \
48 && ${MAKE} ${MAKEFLAGS} show-var VARNAME=PKG_OPTIONS; }
50 MAKEFLAGS+= PKG_BUILD_OPTIONS.${b}=${PKG_BUILD_OPTIONS.${b}:Q}
51 . endif
53 MAKEVARS+= PKG_BUILD_OPTIONS.${b}
54 . endfor
55 .endif