summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorrillig <rillig>2007-03-18 11:09:32 +0000
committerrillig <rillig>2007-03-18 11:09:32 +0000
commitafdd3e2ce14518f18d9a2ad7ab9477f922f11048 (patch)
treeee4263efa481a87f25760744515bf1bbc5626113 /mk
parent2af19ad67bcf82469c2c36357cae26bd1507ec0a (diff)
downloadpkgsrc-afdd3e2ce14518f18d9a2ad7ab9477f922f11048.tar.gz
Added a procedure to determine the build options of a package. This file
can be used instead of writing the same code in every package.
Diffstat (limited to 'mk')
-rw-r--r--mk/pkg-build-options.mk39
1 files changed, 39 insertions, 0 deletions
diff --git a/mk/pkg-build-options.mk b/mk/pkg-build-options.mk
new file mode 100644
index 00000000000..e288e2bb243
--- /dev/null
+++ b/mk/pkg-build-options.mk
@@ -0,0 +1,39 @@
+# $NetBSD: pkg-build-options.mk,v 1.1 2007/03/18 11:09:32 rillig Exp $
+#
+# This procedure determines the PKG_OPTIONS that have been in effect
+# when the package ${pkg} 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"
+#
+# TODO: Query the installed package if it exists.
+#
+
+.if defined(BUILDLINK_DEPTH) && !empty(BUILDLINK_DEPTH)
+. for b in ${pkgbase}
+. if !defined(PKG_BUILD_OPTIONS.${b})
+PKG_BUILD_OPTIONS.${b} != \
+ 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
+.else
+. for b in ${pkgbase}
+PKG_FAIL_REASON+= "[pkg-build-options.mk] This file may only be included from a buildlink3.mk file (pkgbase=${b})."
+. endfor
+.endif