summaryrefslogtreecommitdiff
path: root/mk/tools.mk
diff options
context:
space:
mode:
authorjlam <jlam>2003-08-16 08:50:17 +0000
committerjlam <jlam>2003-08-16 08:50:17 +0000
commitfa151c5f4b7f8290ae61d4935123a4d8e7e380a7 (patch)
tree30ed6a009df883a6bc69e0407c4cf1a6b6bcbbdd /mk/tools.mk
parent1748faee10d53923bd8c7707f1b8e0d25421658d (diff)
downloadpkgsrc-fa151c5f4b7f8290ae61d4935123a4d8e7e380a7.tar.gz
Move the hide-tools portion of bsd.buildlink2.mk into tools.mk, and
put the tools in ${WRKDIR}/.tools/bin instead of in ${BUILDLINK_DIR}, and remove the need for buildlink2 to use USE_GNU_TOOLS. In the modified USE_GNU_TOOLS implementation, the following implementation- specific variables have the following meanings: _TOOLS_REPLACE.<tool> means that we want ${AWK}, ${SED}, etc. symlinked into ${TOOLS_DIR} as awk, sed, etc. _TOOLS_NEED_GNU.<tool> means that we want to use the pkgsrc version of <tool> symlinked info ${TOOLS_DIR} as awk, sed, etc. If this is "YES", then it always trumps _TOOLS_REPLACE.<tool>. And we want nothing to happen if we're building the pkgsrc GNU tool itself. The modified USE_GNU_TOOLS implementation should also hopefully fix the circular dependency problem. Create a new target "tools" that is run after "patch" and before "buildlink" that populates the ${TOOLS_DIR} directory. This ensures that it's always run at the right time, instead of relying on pre-buildlink or pre-configure, which may be cancelled by NO_BUILDLINK or NO_CONFIGURE. XXX There is some possible fallout in texinfo.mk with the MAKE_ENV and XXX CONFIGURE_ENV settings for INSTALL_INFO and MAKEINFO. It looks XXX like the MAKE_ENV and CONFIGURE_ENV settings should move from XXX tools.mk into texinfo.mk, and they no longer need to be XXX conditional on USE_BUILDLINK2. I'll leave it to the texinfo.mk XXX dude (Hi, Stoned!).
Diffstat (limited to 'mk/tools.mk')
-rw-r--r--mk/tools.mk316
1 files changed, 185 insertions, 131 deletions
diff --git a/mk/tools.mk b/mk/tools.mk
index f6993c991fd..be4410ad22a 100644
--- a/mk/tools.mk
+++ b/mk/tools.mk
@@ -1,175 +1,229 @@
-# $NetBSD: tools.mk,v 1.4 2003/08/12 11:39:46 grant Exp $
+# $NetBSD: tools.mk,v 1.5 2003/08/16 08:50:19 jlam Exp $
#
-# handle platforms with broken tools in the base system, such as sed
-# and awk.
-#
-# symlink the suitable versions of tools into .buildlink/bin (if they
-# exist in the base system) and allow packages to force the use of
-# pkgsrc GNU tools when they are not present in the base system by
-# defining e.g. USE_GNU_TOOLS+="awk sed". version numbers are not
-# considered.
+# This Makefile creates a ${TOOLS_DIR} directory and populates the bin
+# subdir with tools that hide the ones outside of ${TOOLS_DIR}.
+
+.if !defined(TOOLS_MK)
+TOOLS_MK= # defined
+
+# Prepend ${TOOLS_DIR}/bin to the PATH so that our scripts are found
+# first when search for executables.
#
-# this functionality is buildlink2 only.
+TOOLS_DIR= ${WRKDIR}/.tools
+PATH:= ${TOOLS_DIR}/bin:${PATH}
+
+TOOLS_SHELL?= ${SH}
+_TOOLS_WRAP_LOG= ${WRKLOG}
+
+.PHONY: do-tools
+.if !target(do-tools)
+do-tools: override-tools
+.endif
+
+.PHONY: override-tools
+override-tools: # empty
+
+# Create shell scripts in ${TOOLS_DIR}/bin that simply return an error
+# status for each of the GNU auto* tools, which should cause GNU configure
+# scripts to think that they can't be found.
#
-# packages should always use eg.
+AUTOMAKE_OVERRIDE?= yes
+_GNU_MISSING= ${.CURDIR}/../../mk/gnu-config/missing
+_HIDE_PROGS.autoconf= bin/autoconf bin/autoconf-2.13 \
+ bin/autoheader bin/autoheader-2.13 \
+ bin/autom4te \
+ bin/autoreconf bin/autoreconf-2.13 \
+ bin/autoscan bin/autoscan-2.13 \
+ bin/autoupdate bin/autoupdate-2.13 \
+ bin/ifnames bin/ifnames-2.13
+_HIDE_PROGS.automake= bin/aclocal bin/aclocal-1.4 \
+ bin/aclocal-1.5 \
+ bin/aclocal-1.6 \
+ bin/aclocal-1.7 \
+ bin/automake bin/automake-1.4 \
+ bin/automake-1.5 \
+ bin/automake-1.6 \
+ bin/automake-1.7
+
+.if empty(AUTOMAKE_OVERRIDE:M[nN][oO])
+. for _autotool_ in autoconf automake
+. for _prog_ in ${_HIDE_PROGS.${_autotool_}}
+override-tools: ${TOOLS_DIR}/${_prog_}
+${TOOLS_DIR}/${_prog_}: ${_GNU_MISSING}
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ( ${ECHO} '#!${TOOLS_SHELL}'; \
+ ${ECHO} 'exec ${_GNU_MISSING} ${_prog_:T:C/-[0-9].*$//}' \
+ ) > ${.TARGET}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CHMOD} +x ${.TARGET}
+. endfor
+. endfor
+.endif # AUTOMAKE_OVERRIDE != NO
+
+# Create an install-info script that is a "no operation" command,
+# as registration of info files is handled by the INSTALL script.
#
-# USE_GNU_TOOLS+= grep
+CONFIGURE_ENV+= INSTALL_INFO="${TOOLS_DIR}/bin/install-info"
+MAKE_ENV+= INSTALL_INFO="${TOOLS_DIR}/bin/install-info"
+
+override-tools: ${TOOLS_DIR}/bin/install-info
+${TOOLS_DIR}/bin/install-info:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ( ${ECHO} '#!${TOOLS_SHELL}'; \
+ ${ECHO} 'wrapperlog="$${TOOLS_WRAPPER_LOG-${_TOOLS_WRAP_LOG}}"'; \
+ ${ECHO} '${ECHO} "==> No-op install-info $$*" >> $$wrapperlog' \
+ ) > ${.TARGET}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CHMOD} +x ${.TARGET}
+
+# Create a makeinfo script that will invoke the right makeinfo
+# command if USE_MAKEINFO is 'yes' or will exit on error if not.
#
-# to be sure not to override the setting passed by the user.
+CONFIGURE_ENV+= MAKEINFO="${TOOLS_DIR}/bin/makeinfo"
+MAKE_ENV+= MAKEINFO="${TOOLS_DIR}/bin/makeinfo"
+
+override-tools: ${TOOLS_DIR}/bin/makeinfo
+.if empty(USE_MAKEINFO:M[nN][oO])
+${TOOLS_DIR}/bin/makeinfo:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ( ${ECHO} "#!${TOOLS_SHELL}"; \
+ ${ECHO} 'wrapperlog="$${TOOLS_WRAPPER_LOG-${_TOOLS_WRAP_LOG}}"'; \
+ ${ECHO} '${ECHO} "${MAKEINFO} $$*" >> $$wrapperlog'; \
+ ${ECHO} 'exec ${MAKEINFO} "$$@"' \
+ ) > ${.TARGET}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CHMOD} +x ${.TARGET}
+.else # !USE_MAKEINFO
+${TOOLS_DIR}/bin/makeinfo: ${_GNU_MISSING}
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ( ${ECHO} "#!${TOOLS_SHELL}"; \
+ ${ECHO} 'wrapperlog="$${TOOLS_WRAPPER_LOG-${_TOOLS_WRAP_LOG}}"'; \
+ ${ECHO} '${ECHO} "==> Error: makeinfo $$*" >> $$wrapperlog'; \
+ ${ECHO} 'exit 1' \
+ ) > ${.TARGET}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CHMOD} +x ${.TARGET}
+.endif # USE_MAKEINFO
+
+# Handle platforms with broken tools in the base system, e.g. sed, awk.
#
+# Symlink the suitable versions of tools into ${TOOLS_DIR}/bin (if they
+# exist in the base system) and allow packages to force the use of
+# pkgsrc GNU tools when they are not present in the base system by
+# defining e.g. USE_GNU_TOOLS+="awk sed". Version numbers are not
+# considered.
-.if !defined(TOOLS_MK)
-TOOLS_MK= # defined
-
-.if empty(USE_BUILDLINK2:M[nN][oO])
_TOOLS= awk grep sed
-# define which platforms already have GNU tools, so no need to pull in
-# the pkgsrc versions.
+# These platforms already have GNU versions of the tools in the base
+# system, so no need to pull in the pkgsrc versions; we will use these
+# instead.
+#
_TOOLS_OPSYS_HAS_GNU.awk+= FreeBSD-*-* Linux-*-* NetBSD-*-* OpenBSD-*-*
_TOOLS_OPSYS_HAS_GNU.grep+= Darwin-*-* FreeBSD-*-* Linux-*-*
_TOOLS_OPSYS_HAS_GNU.grep+= NetBSD-*-* OpenBSD-*-*
_TOOLS_OPSYS_HAS_GNU.sed+= Linux-*-*
-# where said tool is completely unusable, and no suitable replacement
-# is available.
+# These platforms have GNUish versions of the tools available in the base
+# system, which we already define as ${AWK}, ${SED}, etc. (refer to
+# defs.*.mk for the definitions), so no need to pull in the pkgsrc
+# versions; we will use these instead.
+#
+_TOOLS_REPLACE_OPSYS.awk+= SunOS-*-*
+_TOOLS_REPLACE_OPSYS.grep+= SunOS-*-*
+_TOOLS_REPLACE_OPSYS.sed+= # empty
+
+# These platforms have completely unusable versions of these tools, and
+# no suitable replacement is available.
+#
_TOOLS_OPSYS_INCOMPAT.awk+= # empty
_TOOLS_OPSYS_INCOMPAT.grep+= # empty
_TOOLS_OPSYS_INCOMPAT.sed+= # empty
-# a suitable alternative version is available in the base system, as
-# eg. ${AWK}, ${SED}, ... refer to defs.*.mk for the definitions.
-_TOOLS_REPLACE_OPSYS.awk+= SunOS-*-*
-_TOOLS_REPLACE_OPSYS.grep+= SunOS-*-*
-_TOOLS_REPLACE_OPSYS.sed+= # empty
+# Default to not requiring GNU tools.
+.for _tool_ in ${_TOOLS}
+_TOOLS_NEED_GNU.${_tool_}?= NO
+_TOOLS_REPLACE.${_tool_}?= NO
+_TOOLS_OVERRIDE.${_tool_}?= NO
+.endfor
-# what GNU tools did the package or user ask for, and does the OS
-# already have it?
.for _tool_ in ${USE_GNU_TOOLS}
-_TOOLS_NEED_GNU.${_tool_}= YES
+#
+# What GNU tools did the package or user ask for, and does the base
+# system already have it?
+#
+_TOOLS_NEED_GNU.${_tool_}= YES
. for _pattern_ in ${_TOOLS_OPSYS_HAS_GNU.${_tool_}}
. if !empty(MACHINE_PLATFORM:M${_pattern_})
-_TOOLS_NEED_GNU.${_tool_}= NO
+_TOOLS_NEED_GNU.${_tool_}= NO
. endif
. endfor
-.endfor
-
-# default to not requiring GNU tools.
-.for _tool_ in ${_TOOLS}
-_TOOLS_NEED_GNU.${_tool_}?= NO
-_TOOLS_REPLACE.${_tool_}?= NO
-
-# do we know it's broken?
+#
+# Do we know the base system tool is broken?
+#
. for _pattern_ in ${_TOOLS_OPSYS_INCOMPAT.${_tool_}}
. if !empty(MACHINE_PLATFORM:M${_pattern_})
-_TOOLS_NEED_GNU.${_tool_}= YES
+_TOOLS_NEED_GNU.${_tool_}= YES
. endif
. endfor
-
-# are we replacing it with a better version?
+#
+# Are we using a GNUish system tool in place of the needed GNU tool?
+#
. for _pattern_ in ${_TOOLS_REPLACE_OPSYS.${_tool_}}
. if !empty(MACHINE_PLATFORM:M${_pattern_})
-_TOOLS_REPLACE.${_tool_}= YES
+TOOLS_REPLACE.${_tool_}= YES
. endif
. endfor
+.endfor # USE_GNU_TOOLS
-.endfor # ${_TOOLS}
-
-.if ${_TOOLS_NEED_GNU.awk} == "YES" && empty(PKGPATH:Mlang/gawk)
-_TOOLS_PROGNAME.gawk= ${LOCALBASE}/bin/${GNU_PROGRAM_PREFIX}awk
-# catch the case where we are in between package installs, thus don't
-# have gawk available yet.
-. if exists(${_TOOLS_PROGNAME.gawk})
-AWK= ${_TOOLS_PROGNAME.gawk}
-. endif
-BUILDLINK_DEPENDS.gawk?= gawk>=3.1.1
-BUILDLINK_PKGSRCDIR.gawk?= ../../lang/gawk
-BUILDLINK_DEPMETHOD.gawk?= build
-BUILDLINK_PACKAGES+= gawk
-BUILDLINK_PREFIX.gawk_DEFAULT= ${LOCALBASE}
-BUILDLINK_FILES.gawk= bin/${GNU_PROGRAM_PREFIX}awk
-EVAL_PREFIX+= BUILDLINK_PREFIX.gawk=gawk
-.endif
-
-.if ${_TOOLS_NEED_GNU.awk} == "YES" || ${_TOOLS_REPLACE.awk} == "YES"
-BUILDLINK_TARGETS+= gawk-buildlink gawk-buildlink-bin
+.if ${_TOOLS_REPLACE.awk} == "YES"
+_TOOLS_OVERRIDE.awk= YES
+_TOOLS_PROGNAME.awk= ${AWK}
.endif
-
-.if ${_TOOLS_NEED_GNU.grep} == "YES" && empty(PKGPATH:Mtextproc/grep)
-_TOOLS_PROGNAME.grep= ${LOCALBASE}/bin/${GNU_PROGRAM_PREFIX}grep
-. if exists(${_TOOLS_PROGNAME.grep})
-GREP= ${_TOOLS_PROGNAME.grep}
-. endif
-BUILDLINK_DEPENDS.grep?= grep>=2.5.1
-BUILDLINK_PKGSRCDIR.grep?= ../../textproc/grep
-BUILDLINK_DEPMETHOD.grep?= build
-BUILDLINK_PACKAGES+= grep
-BUILDLINK_PREFIX.grep= ${LOCALBASE}
-BUILDLINK_FILES.grep= bin/${GNU_PROGRAM_PREFIX}grep
-EVAL_PREFIX+= BUILDLINK_PREFIX.grep=grep
+.if (${_TOOLS_NEED_GNU.awk} == "YES") && empty(PKGPATH:Mlang/gawk)
+BUILD_DEPENDS+= gawk>=3.1.1:../../lang/gawk
+_TOOLS_OVERRIDE.awk= YES
+_TOOLS_PROGNAME.awk= ${LOCALBASE}/bin/${GNU_PROGRAM_PREFIX}awk
+AWK:= ${_TOOLS_PROGNAME.awk}
.endif
-.if ${_TOOLS_NEED_GNU.grep} == "YES" || ${_TOOLS_REPLACE.grep} == "YES"
-BUILDLINK_TARGETS+= grep-buildlink grep-buildlink-bin
+.if ${_TOOLS_REPLACE.grep} == "YES"
+_TOOLS_OVERRIDE.grep= YES
+_TOOLS_PROGNAME.grep= ${GREP}
.endif
-
-.if ${_TOOLS_NEED_GNU.sed} == "YES" && empty(PKGPATH:Mtextproc/gsed)
-_TOOLS_PROGNAME.gsed= ${LOCALBASE}/bin/${GNU_PROGRAM_PREFIX}sed
-. if exists(${_TOOLS_PROGNAME.gsed})
-SED= ${_TOOLS_PROGNAME.gsed}
-. endif
-BUILDLINK_DEPENDS.gsed?= gsed>=3.0.2
-BUILDLINK_PKGSRCDIR.gsed?= ../../textproc/gsed
-BUILDLINK_DEPMETHOD.gsed?= build
-BUILDLINK_PACKAGES+= gsed
-BUILDLINK_PREFIX.gsed_DEFAULT= ${LOCALBASE}
-BUILDLINK_FILES.gsed= bin/${GNU_PROGRAM_PREFIX}sed
-EVAL_PREFIX+= BUILDLINK_PREFIX.gsed=gsed
+.if (${_TOOLS_NEED_GNU.grep} == "YES") && empty(PKGPATH:Mtextproc/grep)
+BUILD_DEPENDS+= grep>=2.5.1:../../textproc/grep
+_TOOLS_OVERRIDE.grep= YES
+_TOOLS_PROGNAME.grep= ${LOCALBASE}/bin/${GNU_PROGRAM_PREFIX}grep
+GREP:= ${_TOOLS_PROGNAME.grep}
.endif
-.if ${_TOOLS_NEED_GNU.sed} == "YES" || ${_TOOLS_REPLACE.sed} == "YES"
-BUILDLINK_TARGETS+= gsed-buildlink gsed-buildlink-bin
+.if ${_TOOLS_REPLACE.sed} == "YES"
+_TOOLS_OVERRIDE.sed= YES
+_TOOLS_PROGNAME.sed= ${SED}
.endif
-
-gawk-buildlink: _BUILDLINK_USE
-gawk-buildlink-bin:
-.if ${_TOOLS_NEED_GNU.awk} == "YES" && empty(PKGPATH:Mlang/gawk)
- ${_PKG_SILENT}${_PKG_DEBUG} \
- [ ! -f ${BUILDLINK_DIR}/bin/awk ] && \
- ${LN} -fs ${LOCALBASE}/bin/${GNU_PROGRAM_PREFIX}awk \
- ${BUILDLINK_DIR}/bin/awk
-.elif ${_TOOLS_REPLACE.awk} == "YES"
- ${_PKG_SILENT}${_PKG_DEBUG} \
- [ ! -f ${BUILDLINK_DIR}/bin/awk ] && \
- ${LN} -fs ${AWK} ${BUILDLINK_DIR}/bin/awk
+.if (${_TOOLS_NEED_GNU.sed} == "YES") && empty(PKGPATH:Mtextproc/gsed)
+BUILD_DEPENDS+= gsed>=3.0.2:../../textproc/gsed
+_TOOLS_OVERRIDE.sed= YES
+_TOOLS_PROGNAME.sed= ${LOCALBASE}/bin/${GNU_PROGRAM_PREFIX}sed
+SED:= ${_TOOLS_PROGNAME.sed}
.endif
-grep-buildlink: _BUILDLINK_USE
-grep-buildlink-bin:
-.if ${_TOOLS_NEED_GNU.grep} == "YES" && empty(PKGPATH:Mtextproc/grep)
- ${_PKG_SILENT}${_PKG_DEBUG} \
- [ ! -f ${BUILDLINK_DIR}/bin/grep ] && \
- ${LN} -fs ${LOCALBASE}/bin/${GNU_PROGRAM_PREFIX}grep \
- ${BUILDLINK_DIR}/bin/grep
-.elif ${_TOOLS_REPLACE.grep} == "YES"
- ${_PKG_SILENT}${_PKG_DEBUG} \
- [ ! -f ${BUILDLINK_DIR}/bin/grep ] && \
- ${LN} -fs ${GREP} ${BUILDLINK_DIR}/bin/grep
-.endif
-
-gsed-buildlink: _BUILDLINK_USE
-gsed-buildlink-bin:
-.if ${_TOOLS_NEED_GNU.sed} == "YES" && empty(PKGPATH:Mtextproc/gsed)
- ${_PKG_SILENT}${_PKG_DEBUG} \
- [ ! -f ${BUILDLINK_DIR}/bin/sed ] && \
- ${LN} -fs ${LOCALBASE}/bin/${GNU_PROGRAM_PREFIX}sed \
- ${BUILDLINK_DIR}/bin/sed
-.elif ${_TOOLS_REPLACE.sed} == "YES"
- ${_PKG_SILENT}${_PKG_DEBUG} \
- [ ! -f ${BUILDLINK_DIR}/bin/sed ] && \
- ${LN} -fs ${SED} ${BUILDLINK_DIR}/bin/sed
-.endif
-
-.endif # USE_BUILDLINK2
+# If _TOOLS_OVERRIDE.<tool> is actually set to "YES", then we override
+# the tool with the one specified in _TOOLS_PROGNAME.<tool>.
+#
+.for _tool_ in ${_TOOLS}
+. if ${_TOOLS_OVERRIDE.${_tool_}} == "YES"
+override-tools: ${TOOLS_DIR}/bin/${_tool_}
+
+${TOOLS_DIR}/bin/${_tool_}:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ src="${_TOOLS_PROGNAME.${_tool_}}"; \
+ if [ -x $$src -a ! -f ${.TARGET} ]; then \
+ ${MKDIR} ${.TARGET:H}; \
+ ${LN} -sf $$src ${.TARGET}; \
+ fi
+. endif
+.endfor
.endif # TOOLS_MK