summaryrefslogtreecommitdiff
path: root/mk/find-prefix.mk
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2005-05-12 20:41:10 +0000
committerjlam <jlam@pkgsrc.org>2005-05-12 20:41:10 +0000
commit436d9bbbd50c986a0cfcf889569be7d2ea061274 (patch)
tree7590539f2c0f626590d6b59f11f3075d9d30f491 /mk/find-prefix.mk
parent69406c81f0832a975c91a7e8fb700f7499130e90 (diff)
downloadpkgsrc-436d9bbbd50c986a0cfcf889569be7d2ea061274.tar.gz
Instead of structuring code so that variables defined by the EVAL_PREFIX
loop are only used afterwards, split out the EVAL_PREFIX code into a separate file find-prefix.mk that can be included at any point to generate a prefix-computation for the variables specified by FIND_PREFIX at the inclusion point.
Diffstat (limited to 'mk/find-prefix.mk')
-rw-r--r--mk/find-prefix.mk29
1 files changed, 29 insertions, 0 deletions
diff --git a/mk/find-prefix.mk b/mk/find-prefix.mk
new file mode 100644
index 00000000000..796b46573a3
--- /dev/null
+++ b/mk/find-prefix.mk
@@ -0,0 +1,29 @@
+# $NetBSD: find-prefix.mk,v 1.1 2005/05/12 20:41:10 jlam Exp $
+#
+# This is a "subroutine" that can be included to find the installation
+# prefix of a package.
+#
+# The input variable is FIND_PREFIX, which is a list of VARNAME=<package>
+# pairs, where "VARNAME" is the variable that will be set to the
+# installation prefix for the package, and <package> is the ${PKGNAME}
+# for the package.
+#
+# An example use is:
+#
+# FIND_PREFIX:= M4DIR=gm4
+# .include "../../mk/find-prefix.mk"
+# # ${M4DIR} now contains the installation prefix for the "gm4" package
+#
+
+.for _def_ in ${FIND_PREFIX}
+. if !defined(_${_def_:C/=.*$//})
+${_def_:C/=.*$//}_DEFAULT?= ${LOCALBASE}
+_${_def_:C/=.*$//}_cmd= \
+ ${PKG_INFO} -qp ${_def_:C/^.*=//} 2>/dev/null | \
+ ${AWK} '{ print $$2; exit }' || \
+ ${ECHO} ${${_def_:C/=.*$//}_DEFAULT:Q}
+${_def_:C/=.*$//}= ${_${_def_:C/=.*$//}_cmd:sh}
+. endif
+MAKEVARS+= ${_def_:C/=.*$//}
+.endfor
+.undef _def_