pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk Instead of structuring code so that variables defin...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/7c8e948e3a75
branches:  trunk
changeset: 493705:7c8e948e3a75
user:      jlam <jlam%pkgsrc.org@localhost>
date:      Thu May 12 20:41:10 2005 +0000

description:
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:

 mk/bsd.pkg.mk     |  12 +++---------
 mk/find-prefix.mk |  29 +++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 9 deletions(-)

diffs (59 lines):

diff -r 8411f785aaad -r 7c8e948e3a75 mk/bsd.pkg.mk
--- a/mk/bsd.pkg.mk     Thu May 12 20:31:56 2005 +0000
+++ b/mk/bsd.pkg.mk     Thu May 12 20:41:10 2005 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: bsd.pkg.mk,v 1.1641 2005/05/12 18:07:30 jlam Exp $
+#      $NetBSD: bsd.pkg.mk,v 1.1642 2005/05/12 20:41:10 jlam Exp $
 #
 # This file is in the public domain.
 #
@@ -999,14 +999,8 @@
 
 # Find out the PREFIX of dependencies where the PREFIX is needed at build time.
 .if defined(EVAL_PREFIX)
-.  for def in ${EVAL_PREFIX}
-.    if !defined(${def:C/=.*$//})
-${def:C/=.*$//}_DEFAULT?=${LOCALBASE}
-_${def:C/=.*$//}_CMD=  ${PKG_INFO} -qp ${def:C/^.*=//} 2>/dev/null | ${AWK} '{ print $$2; exit }' | ${GREP} . || ${ECHO} ${${def:C/=.*$//}_DEFAULT}
-${def:C/=.*$//}=       ${_${def:C/=.*$//}_CMD:sh}
-MAKEFLAGS+=            ${def:C/=.*//}=${_${def:C/=.*$//}_CMD:sh}
-.    endif
-.  endfor
+FIND_PREFIX:=  ${EVAL_PREFIX}
+.  include "../../mk/find-prefix.mk"
 .endif
 
 .if !defined(_PATH_ORIG)
diff -r 8411f785aaad -r 7c8e948e3a75 mk/find-prefix.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mk/find-prefix.mk Thu May 12 20:41:10 2005 +0000
@@ -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_



Home | Main Index | Thread Index | Old Index