2d1ba244e9
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.
55 lines
1.7 KiB
Makefile
55 lines
1.7 KiB
Makefile
# $NetBSD: pkg-build-options.mk,v 1.8 2009/03/20 19:25:01 joerg 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, the current PKG_OPTIONS are queried.
|
|
#
|
|
# Parameters:
|
|
# pkgbase
|
|
# The basename of the package.
|
|
#
|
|
# Returns:
|
|
# PKG_BUILD_OPTIONS.${pkgbase}
|
|
# The build options of the package.
|
|
#
|
|
# Example:
|
|
# pkgbase := wine
|
|
# .include "../../mk/pkg-build-options.mk"
|
|
#
|
|
# Keywords: options pkg-build-options PKG_BUILD_OPTIONS
|
|
#
|
|
|
|
.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})
|
|
PKG_BUILD_OPTIONS.${b} != \
|
|
echo ""; \
|
|
${PKG_INFO} -Q PKG_OPTIONS ${pkgbase} 2>/dev/null \
|
|
|| { cd ${BUILDLINK_PKGSRCDIR.${b}} \
|
|
&& ${MAKE} ${MAKEFLAGS} show-var VARNAME=PKG_OPTIONS; }
|
|
|
|
MAKEFLAGS+= PKG_BUILD_OPTIONS.${b}=${PKG_BUILD_OPTIONS.${b}:Q}
|
|
. endif
|
|
|
|
MAKEVARS+= PKG_BUILD_OPTIONS.${b}
|
|
. endfor
|
|
.endif
|