pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/mk We only prepend a directory to the PATH if we haven...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/765c0ff8757c
branches:  trunk
changeset: 467747:765c0ff8757c
user:      jlam <jlam%pkgsrc.org@localhost>
date:      Fri Feb 06 03:04:50 2004 +0000

description:
We only prepend a directory to the PATH if we haven't already done so
(by checking PREPEND_PATH) and only for those phases of the build that
care about the PATH (buildlink or later).  We also pass the PATH to
those same phases of the build so that executing ${CC} will work correctly
from custom {pre,do,post}-* targets that occur at buildlink time or
later.

diffstat:

 mk/bsd.pkg.mk                   |  21 ++++++++++++++-------
 mk/buildlink2/bsd.buildlink2.mk |   8 ++++++--
 mk/buildlink3/bsd.buildlink3.mk |  10 +++++++---
 mk/compiler/ccache.mk           |   8 ++++++--
 mk/compiler/distcc.mk           |   9 +++++++--
 mk/compiler/gcc.mk              |  32 ++++++++++++++++++++++----------
 mk/compiler/mipspro.mk          |   8 ++++++--
 mk/compiler/sunpro.mk           |   8 ++++++--
 mk/tools.mk                     |   8 +++++++-
 9 files changed, 81 insertions(+), 31 deletions(-)

diffs (299 lines):

diff -r c0b8b64a7611 -r 765c0ff8757c mk/bsd.pkg.mk
--- a/mk/bsd.pkg.mk     Fri Feb 06 02:50:57 2004 +0000
+++ b/mk/bsd.pkg.mk     Fri Feb 06 03:04:50 2004 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: bsd.pkg.mk,v 1.1373 2004/02/05 17:20:46 hubertf Exp $
+#      $NetBSD: bsd.pkg.mk,v 1.1374 2004/02/06 03:04:50 jlam Exp $
 #
 # This file is in the public domain.
 #
@@ -1319,6 +1319,11 @@
 SCRIPTS_ENV+=  BATCH=yes
 .endif
 
+# Initialize a variable used by Makefiles to check whether to prepend
+# to the PATH.
+#
+PREPEND_PATH=  # empty
+
 # Get the proper dependencies and set the PATH to use the compiler
 # named in PKGSRC_COMPILER.
 #
@@ -1337,6 +1342,8 @@
 
 .include "../../mk/tools.mk"
 
+MAKEFLAGS+=    PREPEND_PATH="${PREPEND_PATH}"
+
 .MAIN: all
 
 # Use aliases, so that all versions of English are acceptable
@@ -3142,7 +3149,7 @@
        ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} real-tools PKG_PHASE=tools
 
 ${BUILDLINK_COOKIE}:
-       ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} real-buildlink PKG_PHASE=buildlink
+       ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} PATH=${PATH} ${MAKE} ${MAKEFLAGS} real-buildlink PKG_PHASE=buildlink
 
 ${CONFIGURE_COOKIE}:
 .if ${INTERACTIVE_STAGE:Mconfigure} == "configure" && defined(BATCH)
@@ -3151,7 +3158,7 @@
        @${TOUCH} ${INTERACTIVE_COOKIE}
        @${FALSE}
 .else
-       ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} real-configure PKG_PHASE=configure
+       ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} PATH=${PATH} ${MAKE} ${MAKEFLAGS} real-configure PKG_PHASE=configure
 .endif
 
 ${BUILD_COOKIE}:
@@ -3161,11 +3168,11 @@
        @${TOUCH} ${INTERACTIVE_COOKIE}
        @${FALSE}
 .else
-       ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} real-build PKG_PHASE=build
+       ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} PATH=${PATH} ${MAKE} ${MAKEFLAGS} real-build PKG_PHASE=build
 .endif
 
 ${TEST_COOKIE}:
-       ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} real-test PKG_PHASE=test
+       ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} PATH=${PATH} ${MAKE} ${MAKEFLAGS} real-test PKG_PHASE=test
 
 ${INSTALL_COOKIE}:
 .if ${INTERACTIVE_STAGE:Minstall} == "install" && defined(BATCH)
@@ -3174,11 +3181,11 @@
        @${TOUCH} ${INTERACTIVE_COOKIE}
        @${FALSE}
 .else
-       ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} real-install PKG_PHASE=install
+       ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} PATH=${PATH} ${MAKE} ${MAKEFLAGS} real-install PKG_PHASE=install
 .endif
 
 ${PACKAGE_COOKIE}:
-       ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} real-package PKG_PHASE=package
+       ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} PATH=${PATH} ${MAKE} ${MAKEFLAGS} real-package PKG_PHASE=package
 
 .PHONY: extract-message patch-message tools-message buildlink-message
 .PHONY: configure-message build-message test-message
diff -r c0b8b64a7611 -r 765c0ff8757c mk/buildlink2/bsd.buildlink2.mk
--- a/mk/buildlink2/bsd.buildlink2.mk   Fri Feb 06 02:50:57 2004 +0000
+++ b/mk/buildlink2/bsd.buildlink2.mk   Fri Feb 06 03:04:50 2004 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.buildlink2.mk,v 1.110 2004/02/05 09:57:53 jlam Exp $
+# $NetBSD: bsd.buildlink2.mk,v 1.111 2004/02/06 03:04:50 jlam Exp $
 #
 # An example package buildlink2.mk file:
 #
@@ -125,7 +125,11 @@
 # Prepend ${BUILDLINK_DIR}/bin to the PATH so that the wrappers are found
 # first when searching for executables.
 #
-PATH:=                 ${BUILDLINK_DIR}/bin:${PATH}
+.if !empty(PHASES_AFTER_BUILDLINK:M${PKG_PHASE}) && \
+    empty(PREPEND_PATH:M${BUILDLINK_DIR}/bin)
+PREPEND_PATH+= ${BUILDLINK_DIR}/bin
+PATH:=         ${BUILDLINK_DIR}/bin:${PATH}
+.endif
 
 .for _pkg_ in ${BUILDLINK_PACKAGES}
 #
diff -r c0b8b64a7611 -r 765c0ff8757c mk/buildlink3/bsd.buildlink3.mk
--- a/mk/buildlink3/bsd.buildlink3.mk   Fri Feb 06 02:50:57 2004 +0000
+++ b/mk/buildlink3/bsd.buildlink3.mk   Fri Feb 06 03:04:50 2004 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.buildlink3.mk,v 1.75 2004/02/05 07:17:14 jlam Exp $
+# $NetBSD: bsd.buildlink3.mk,v 1.76 2004/02/06 03:04:50 jlam Exp $
 #
 # An example package buildlink3.mk file:
 #
@@ -54,10 +54,14 @@
 # Prepend ${BUILDLINK_DIR}/bin to the PATH so that the wrappers are found
 # first when searching for executables.
 #
-.if defined(_OPSYS_DEFAULT_PATH)
+.if !empty(PHASES_AFTER_BUILDLINK:M${PKG_PHASE}) && \
+    empty(PREPEND_PATH:M${BUILDLINK_DIR}/bin)
+PREPEND_PATH+= ${BUILDLINK_DIR}/bin
+.  if defined(_OPSYS_DEFAULT_PATH)
 PATH:=         ${BUILDLINK_DIR}/bin:${_OPSYS_DEFAULT_PATH}
-.else
+.  else
 PATH:=         ${BUILDLINK_DIR}/bin:${PATH}
+.  endif
 .endif
 
 # BUILDLINK_DEPENDS contains the list of packages for which we add
diff -r c0b8b64a7611 -r 765c0ff8757c mk/compiler/ccache.mk
--- a/mk/compiler/ccache.mk     Fri Feb 06 02:50:57 2004 +0000
+++ b/mk/compiler/ccache.mk     Fri Feb 06 03:04:50 2004 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: ccache.mk,v 1.8 2004/02/05 03:39:17 jlam Exp $
+# $NetBSD: ccache.mk,v 1.9 2004/02/06 03:04:50 jlam Exp $
 
 .if !defined(COMPILER_CCACHE_MK)
 COMPILER_CCACHE_MK=    one
@@ -58,7 +58,11 @@
 
 .    if !empty(_USE_CCACHE:M[yY][eE][sS])
 .      if !empty(_LANGUAGES.ccache)
-PATH:= ${_CCACHE_DIR}/bin:${PATH}
+.        if !empty(PHASES_AFTER_BUILDLINK:M${PKG_PHASE}) && \
+            empty(PREPEND_PATH:M${_CCACHE_DIR}/bin)
+PREPEND_PATH+= ${_CCACHE_DIR}/bin
+PATH:=         ${_CCACHE_DIR}/bin:${PATH}
+.        endif
 .      endif
 
 BUILD_DEPENDS+=        ccache-[0-9]*:../../devel/ccache
diff -r c0b8b64a7611 -r 765c0ff8757c mk/compiler/distcc.mk
--- a/mk/compiler/distcc.mk     Fri Feb 06 02:50:57 2004 +0000
+++ b/mk/compiler/distcc.mk     Fri Feb 06 03:04:50 2004 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: distcc.mk,v 1.11 2004/02/05 03:39:17 jlam Exp $
+# $NetBSD: distcc.mk,v 1.12 2004/02/06 03:04:50 jlam Exp $
 
 .if !defined(COMPILER_DISTCC_MK)
 COMPILER_DISTCC_MK=    one
@@ -58,8 +58,13 @@
 
 .    if !empty(_USE_DISTCC:M[yY][eE][sS])
 .      if !empty(_LANGUAGES.distcc)
-PATH:= ${_DISTCC_DIR}/bin:${PATH}
+.        if !empty(PHASES_AFTER_BUILDLINK:M${PKG_PHASE}) && \
+            empty(PREPEND_PATH:M${_DISTCC_DIR}/bin)
+PREPEND_PATH+= ${_DISTCC_DIR}/bin
+PATH:=         ${_DISTCC_DIR}/bin:${PATH}
+.        endif
 .      endif
+.    endif
 
 BUILD_DEPENDS+=        distcc-[0-9]*:../../devel/distcc
 
diff -r c0b8b64a7611 -r 765c0ff8757c mk/compiler/gcc.mk
--- a/mk/compiler/gcc.mk        Fri Feb 06 02:50:57 2004 +0000
+++ b/mk/compiler/gcc.mk        Fri Feb 06 03:04:50 2004 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: gcc.mk,v 1.37 2004/02/05 04:12:28 jlam Exp $
+# $NetBSD: gcc.mk,v 1.38 2004/02/06 03:04:50 jlam Exp $
 
 .if !defined(COMPILER_GCC_MK)
 COMPILER_GCC_MK=       one
@@ -18,14 +18,19 @@
 _GCC3_PATTERNS=        2.95.[4-9]* 2.95.[1-9][0-9]* 2.9[6-9] 2.9[6-9].*        \
                2.[1-9][0-9][0-9]* 3.* [4-9]*
 
+.  if !defined(_CC)
 _CC:=  ${CC:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//}
-.  for _dir_ in ${PATH:C/\:/ /g}
-.    if empty(_CC:M/*)
-.      if exists(${_dir_}/${CC:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//})
+.    for _dir_ in ${PATH:C/\:/ /g}
+.      if empty(_CC:M/*)
+.        if exists(${_dir_}/${CC:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//})
 _CC:=  ${_dir_}/${CC:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//}
+.        endif
 .      endif
+.    endfor
+.    if !empty(_CC:M/*)
+MAKEFLAGS+=    _CC="${_CC}"
 .    endif
-.  endfor
+.  endif
 
 .  if !defined(_GCC_VERSION)
 _GCC_VERSION_STRING!=  \
@@ -293,12 +298,19 @@
 # Prepend the path to the compiler to the PATH.
 .    if !empty(_USE_PKGSRC_GCC:M[yY][eE][sS])
 .      if exists(${_GCC_PREFIX}bin/gcc) && !empty(_LANGUAGES.gcc)
-PATH:= ${_GCC_PREFIX}bin:${PATH}
+.        if !empty(PHASES_AFTER_BUILDLINK:M${PKG_PHASE}) && \
+            empty(PREPEND_PATH:M${_GCC_PREFIX}bin)
+PREPEND_PATH+= ${GCC_PREFIX}bin
+PATH:=         ${_GCC_PREFIX}bin:${PATH}
+.        endif
 .      endif
-.    else
-.      if !empty(_IS_BUILTIN_GCC:M[yY][eE][sS])
-.        if !empty(_CC:M/*)
-PATH:= ${_CC:H}:${PATH}
+.    elif !empty(_IS_BUILTIN_GCC:M[yY][eE][sS])
+_CC_DIRPATH=   ${_CC:H}
+.      if !empty(_CC_DIRPATH:M/*)
+.        if !empty(PHASES_AFTER_BUILDLINK:M${PKG_PHASE}) && \
+            empty(PREPEND_PATH:M${_CC_DIRPATH})
+PREPEND_PATH+= ${_CC_DIRPATH}
+PATH:=         ${_CC_DIRPATH}:${PATH}
 .        endif
 .      endif
 .    endif
diff -r c0b8b64a7611 -r 765c0ff8757c mk/compiler/mipspro.mk
--- a/mk/compiler/mipspro.mk    Fri Feb 06 02:50:57 2004 +0000
+++ b/mk/compiler/mipspro.mk    Fri Feb 06 03:04:50 2004 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mipspro.mk,v 1.11 2004/02/05 22:05:42 jlam Exp $
+# $NetBSD: mipspro.mk,v 1.12 2004/02/06 03:04:50 jlam Exp $
 
 .if !defined(COMPILER_MIPSPRO_MK)
 COMPILER_MIPSPRO_MK=   one
@@ -40,7 +40,11 @@
 
 # Prepend the path to the compiler to the PATH.
 .    if !empty(_LANGUAGES.mipspro)
-PATH:= ${MIPSPROBASE}/bin:${PATH}
+.      if !empty(PHASES_AFTER_BUILDLINK:M${PKG_PHASE}) && \
+          empty(PREPEND_PATH:M${MIPSPROBASE}/bin)
+PREPEND_PATH+= ${MIPSPROBASE}/bin
+PATH:=         ${MIPSPROBASE}/bin:${PATH}
+.      endif
 .    endif
 .  endif # COMPILER_MIPSPRO_MK
 .endif  # BSD_PREFS_MK
diff -r c0b8b64a7611 -r 765c0ff8757c mk/compiler/sunpro.mk
--- a/mk/compiler/sunpro.mk     Fri Feb 06 02:50:57 2004 +0000
+++ b/mk/compiler/sunpro.mk     Fri Feb 06 03:04:50 2004 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: sunpro.mk,v 1.8 2004/02/05 03:39:17 jlam Exp $
+# $NetBSD: sunpro.mk,v 1.9 2004/02/06 03:04:50 jlam Exp $
 
 .if !defined(COMPILER_SUNPRO_MK)
 COMPILER_SUNPRO_MK=    one
@@ -41,7 +41,11 @@
 
 # Prepend the path to the compiler to the PATH.
 .    if !empty(_LANGUAGES.sunpro)
-PATH:= ${SUNWSPROBASE}/bin:${PATH}
+.      if !empty(PHASES_AFTER_BUILDLINK:M${PKG_PHASE}) && \
+          empty(PREPEND_PATH:M${SUNWSPROBASE}/bin)
+PREPEND_PATH+= ${SUNWSPROBASE}/bin
+PATH:=         ${SUNWSPROBASE}/bin:${PATH}
+.      endif
 .    endif
 .  endif # COMPILER_SUNPRO_MK
 .endif  # BSD_PREFS_MK
diff -r c0b8b64a7611 -r 765c0ff8757c mk/tools.mk
--- a/mk/tools.mk       Fri Feb 06 02:50:57 2004 +0000
+++ b/mk/tools.mk       Fri Feb 06 03:04:50 2004 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: tools.mk,v 1.23 2004/02/03 08:57:20 grant Exp $
+# $NetBSD: tools.mk,v 1.24 2004/02/06 03:04:50 jlam Exp $
 #
 # This Makefile creates a ${TOOLS_DIR} directory and populates the bin
 # subdir with tools that hide the ones outside of ${TOOLS_DIR}.
@@ -6,11 +6,17 @@
 .if !defined(TOOLS_MK)
 TOOLS_MK=      # defined
 
+.include "../../mk/bsd.prefs.mk"
+
 # Prepend ${TOOLS_DIR}/bin to the PATH so that our scripts are found
 # first when searching for executables.
 #
 TOOLS_DIR=     ${WRKDIR}/.tools
+.if !empty(PHASES_AFTER_BUILDLINK:M${PKG_PHASE}) && \
+    empty(PREPEND_PATH:M${TOOLS_DIR}/bin)
+PREPEND_PATH+= ${TOOLS_DIR}/bin
 PATH:=         ${TOOLS_DIR}/bin:${PATH}
+.endif
 
 TOOLS_SHELL?=          ${SH}
 _TOOLS_WRAP_LOG=       ${WRKLOG}



Home | Main Index | Thread Index | Old Index