summaryrefslogtreecommitdiff
path: root/mk/tools
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2006-06-06 06:30:29 +0000
committerjlam <jlam@pkgsrc.org>2006-06-06 06:30:29 +0000
commitcd1230e8e371554e309755e0e2d06433c1464941 (patch)
tree9920fd5c6fa218862616c8c8f878cd84172f09bb /mk/tools
parente3e58f764bb8893ee08bf872b5f8a89e3812e102 (diff)
downloadpkgsrc-cd1230e8e371554e309755e0e2d06433c1464941.tar.gz
Separate out the part of bsd.tools.mk that actually created the tools
into a new file pkgsrc/mk/tools/create.mk. This leaves bsd.tools.mk as a file that pulls in all of the other ones. Also move the tools-related targets from bsd.pkg.mk into bsd.tools.mk. The tools cookie file has been removed, as well as hooks for {pre,do,post}-tools. Instead, there is now only a single public target "tools" which may be invoked. Invoking "tools" will always cause all of the tools in ${TOOLS_DIR} to be created. The "tools" step has been moved and is now just after the "depends" step and before sources are extracted. This is the earliest place where the "tools" step can be taken, and it allows the created tools to be used in all steps/phases after it, starting with "extract". As a consequence, we should just invoke tools by their bare names in targets, e.g. awk, sed, patch, etc., instead of with the ${VARIABLE} names, e.g. ${AWK}, ${SED}, ${PATCH}, etc.
Diffstat (limited to 'mk/tools')
-rw-r--r--mk/tools/bsd.tools.mk212
-rw-r--r--mk/tools/create.mk180
-rw-r--r--mk/tools/replace.mk4
3 files changed, 233 insertions, 163 deletions
diff --git a/mk/tools/bsd.tools.mk b/mk/tools/bsd.tools.mk
index 8caeb10e7b6..1a555248e61 100644
--- a/mk/tools/bsd.tools.mk
+++ b/mk/tools/bsd.tools.mk
@@ -1,6 +1,6 @@
-# $NetBSD: bsd.tools.mk,v 1.34 2006/04/13 18:45:01 jlam Exp $
+# $NetBSD: bsd.tools.mk,v 1.35 2006/06/06 06:30:29 jlam Exp $
#
-# Copyright (c) 2005 The NetBSD Foundation, Inc.
+# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
@@ -35,60 +35,14 @@
# POSSIBILITY OF SUCH DAMAGE.
#
+# This Makefile fragment is included to bsd.pkg.mk and defines the
+# relevant variables and targets for the "tools" phase.
#
-# This Makefile fragment creates tools under ${TOOLS_DIR} that are
-# found before similarly-named tools in the system path.
+# The following are the "public" targets provided by this module:
#
-# TOOLS_CREATE is a whitespace-separated list of tools for which a
-# corresponding tool is created. Either a wrapper script or a
-# symlink is created depending on the tool that is being
-# overridden.
-#
-# The following variables specify the details of each <tool>:
-#
-# TOOLS_CMD.<tool> is the path to the tool under ${TOOLS_DIR}. This
-# variable is optional, and if left unspecified it defaults to
-# ${TOOLS_DIRS}/bin/<tool>.
-#
-# TOOLS_ALIASES.<tool> is a whitespace-separated list of names for
-# which <tool> should also be created under ${TOOLS_DIR}.
-#
-# TOOLS_PATH.<tool> is the path to the actual command that is
-# invoked when ${TOOLS_CMD.<tool>} is called. If <tool> should
-# be a symlink, then this variable is required and should be a
-# full path. If <tool> should be a wrapper, then this variable
-# is required unless TOOLS_SCRIPT.<tool> is defined (see below).
-#
-# The following variables specify further details of each <tool> and
-# if set, cause a wrapper script to be created.
-#
-# TOOLS_ARGS.<tool> additional arguments that are passed to the real
-# command ahead of any command-line arguments. This variable is
-# optional.
-#
-# TOOLS_SCRIPT.<tool> specifies the Bourne-shell scriptlet to embed
-# in the wrapper script that is executed when <tool> is called.
-# This variable is optional, and if left unspecified, then this
-# is built up from TOOLS_PATH.<tool> and TOOLS_ARGS.<tool> by
-# default.
-#
-# The following variables provide shortcuts for creating certain classes
-# of tools:
-#
-# TOOLS_NOOP is a list of tools that do nothing and return true.
-#
-# TOOLS_BROKEN is a list of tools that do nothing and return false.
-#
-# TOOLS_GNU_MISSING is a list of tools for which the GNU missing
-# script is invoked in place of the real tool. This is used
-# primarily to hide GNU auto* tools.
+# tools
#
-.if !defined(BSD_TOOLS_MK)
-BSD_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.
#
@@ -98,122 +52,58 @@ PREPEND_PATH+= ${TOOLS_DIR}/bin
TOOLS_SHELL?= ${SH}
_TOOLS_WRAP_LOG= ${WRKLOG}
-.PHONY: do-tools override-tools
-do-tools: override-tools
-override-tools: .OPTIONAL
-
USE_TOOLS?= # empty
-# Include the other mk/tools/*.mk files here that help specify the
-# wrappers and symlinks that will be created by this file. Order
-# matters!
-#
-.include "../../mk/tools/automake.mk"
-.include "../../mk/tools/autoconf.mk"
-.include "../../mk/tools/texinfo.mk"
-.include "../../mk/tools/gettext.mk"
-.include "../../mk/tools/ldconfig.mk"
-.include "../../mk/tools/rpcgen.mk"
-.include "../../mk/tools/strip.mk"
-.include "../../mk/tools/imake.mk"
-.include "../../mk/tools/replace.mk"
-.include "../../mk/tools/perl.mk"
-.include "../../mk/tools/pkg-config.mk"
-.include "../../mk/tools/make.mk"
-
######################################################################
-
-.for _t_ in ${TOOLS_NOOP}
-TOOLS_CREATE+= ${_t_}
-TOOLS_SCRIPT.${_t_}?= exit 0
-.endfor
-
-.for _t_ in ${TOOLS_BROKEN}
-TOOLS_CREATE+= ${_t_}
-TOOLS_SCRIPT.${_t_}?= exit 1
-.endfor
-
-.for _t_ in ${TOOLS_GNU_MISSING}
-TOOLS_CREATE+= ${_t_}
-TOOLS_PATH.${_t_}?= ${PKGSRCDIR}/mk/gnu-config/missing
-TOOLS_SCRIPT.${_t_}?= ${TOOLS_PATH.${_t_}} ${_t_:T:C/-[0-9].*$//}
-.endfor
-
+### tools (PUBLIC)
######################################################################
-
-# These tools are used in the targets that actually create the wrappers
-# and symlinks. We define them here so that as a fallback, we'll just
-# use the ones in the PATH. This makes the tools framework more
-# standalone.
-
-CHMOD?= chmod
-ECHO?= echo
-FALSE?= false
-LN?= ln
-MKDIR?= mkdir -p
+### tools is a public target to create a private directory of tools
+### specified by USE_TOOLS.
+###
+_TOOLS_TARGETS+= acquire-tools-lock
+_TOOLS_TARGETS+= real-tools
+_TOOLS_TARGETS+= release-tools-lock
+
+.PHONY: tools
+.if !target(tools)
+tools: ${_TOOLS_TARGETS}
+.endif
+
+.PHONY: acquire-tools-lock release-tools-lock
+acquire-tools-lock: acquire-lock
+release-tools-lock: release-lock
######################################################################
+### real-tools (PRIVATE)
+######################################################################
+### real-tools is a helper target onto which one can hook all of the
+### targets that do the actual tool creation.
+###
+_REAL_TOOLS_TARGETS+= tools-message
+_REAL_TOOLS_TARGETS+= tools-vars
+_REAL_TOOLS_TARGETS+= override-tools
-# If the command line was defined, then we create a wrapper.
-# If the real command isn't a full path, then we create a wrapper.
-# If some command arguments were given, then we create a wrapper.
-# Otherwise, we create a symlink.
-#
-# By default, the tool in ${TOOLS_DIR} will be in the "bin" directory
-# and will be called <tool>.
-#
-# The default wrapper script will invoke the real command, followed
-# by any arguments specified in TOOLS_ARGS.*, followed by any
-# command-line arguments passed to the wrapper script.
-#
-.for _t_ in ${TOOLS_CREATE}
-TOOLS_CMD.${_t_}?= ${TOOLS_DIR}/bin/${_t_}
-TOOLS_PATH.${_t_}?= ${FALSE}
-TOOLS_SCRIPT_DFLT.${_t_}= \
- ${TOOLS_PATH.${_t_}} ${TOOLS_ARGS.${_t_}} "$$@"
+.PHONY: real-tools
+real-tools: ${_REAL_TOOLS_TARGETS}
-override-tools: ${TOOLS_CMD.${_t_}}
+.PHONY: tools-message
+tools-message:
+ @${PHASE_MSG} "Overriding tools for ${PKGNAME}"
-${TOOLS_CMD.${_t_}}:
- ${_PKG_SILENT}${_PKG_DEBUG}${TEST} -d ${.TARGET:H:Q} || \
- ${MKDIR} ${.TARGET:H:Q}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- if ${TEST} -n ${TOOLS_SCRIPT.${_t_}:Q}""; then \
- create=wrapper; \
- script=${TOOLS_SCRIPT.${_t_}:Q}; \
- elif ${TEST} -n ${TOOLS_PATH.${_t_}:Q}""; then \
- if ${TEST} -n ${TOOLS_ARGS.${_t_}:Q}""; then \
- create=wrapper; \
- script=${TOOLS_SCRIPT_DFLT.${_t_}:Q}; \
- else \
- case ${TOOLS_PATH.${_t_}:Q}"" in \
- /*) create=symlink ;; \
- *) create=wrapper; \
- script=${TOOLS_SCRIPT_DFLT.${_t_}:Q}; \
- esac; \
- fi; \
- else \
- create=symlink; \
- fi; \
- case "$$create" in \
- wrapper) \
- { ${ECHO} '#!'${TOOLS_SHELL:Q}; \
- ${ECHO} 'wrapperlog="$${TOOLS_WRAPPER_LOG-'${_TOOLS_WRAP_LOG:Q}'}"'; \
- ${ECHO} '${ECHO} "[*] "'${.TARGET:Q}'" $$@" >> $$wrapperlog'; \
- ${ECHO} "${ECHO} \"<.> $$script\" >> \$$wrapperlog"; \
- ${ECHO} "$$script"; \
- } > ${.TARGET:Q}; \
- ${CHMOD} +x ${.TARGET:Q}; \
- ;; \
- *) \
- ${LN} -fs ${TOOLS_PATH.${_t_}:Q} ${.TARGET:Q}; \
- ;; \
- esac
-. for _a_ in ${TOOLS_ALIASES.${_t_}}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- ${TEST} ${.TARGET:Q} = ${.TARGET:H:Q}/${_a_} || \
- ${LN} -fs ${.TARGET:T:Q} ${.TARGET:H:Q}/${_a_}
-. endfor
-.endfor
+.PHONY: override-tools
+override-tools: .OPTIONAL
-.endif # BSD_TOOLS_MK
+.include "${PKGSRCDIR}/mk/tools/automake.mk"
+.include "${PKGSRCDIR}/mk/tools/autoconf.mk"
+.include "${PKGSRCDIR}/mk/tools/texinfo.mk"
+.include "${PKGSRCDIR}/mk/tools/gettext.mk"
+.include "${PKGSRCDIR}/mk/tools/ldconfig.mk"
+.include "${PKGSRCDIR}/mk/tools/rpcgen.mk"
+.include "${PKGSRCDIR}/mk/tools/strip.mk"
+.include "${PKGSRCDIR}/mk/tools/imake.mk"
+.include "${PKGSRCDIR}/mk/tools/replace.mk"
+.include "${PKGSRCDIR}/mk/tools/perl.mk"
+.include "${PKGSRCDIR}/mk/tools/pkg-config.mk"
+.include "${PKGSRCDIR}/mk/tools/make.mk"
+
+.include "${PKGSRCDIR}/mk/tools/create.mk"
diff --git a/mk/tools/create.mk b/mk/tools/create.mk
new file mode 100644
index 00000000000..f62e3e8d04b
--- /dev/null
+++ b/mk/tools/create.mk
@@ -0,0 +1,180 @@
+# $NetBSD: create.mk,v 1.1 2006/06/06 06:30:29 jlam Exp $
+#
+# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the NetBSD
+# Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+#
+# This Makefile fragment creates tools under ${TOOLS_DIR} that are
+# found before similarly-named tools in the system path.
+#
+# TOOLS_CREATE is a whitespace-separated list of tools for which a
+# corresponding tool is created. Either a wrapper script or a
+# symlink is created depending on the tool that is being
+# overridden.
+#
+# The following variables specify the details of each <tool>:
+#
+# TOOLS_CMD.<tool> is the path to the tool under ${TOOLS_DIR}. This
+# variable is optional, and if left unspecified it defaults to
+# ${TOOLS_DIRS}/bin/<tool>.
+#
+# TOOLS_ALIASES.<tool> is a whitespace-separated list of names for
+# which <tool> should also be created under ${TOOLS_DIR}.
+#
+# TOOLS_PATH.<tool> is the path to the actual command that is
+# invoked when ${TOOLS_CMD.<tool>} is called. If <tool> should
+# be a symlink, then this variable is required and should be a
+# full path. If <tool> should be a wrapper, then this variable
+# is required unless TOOLS_SCRIPT.<tool> is defined (see below).
+#
+# The following variables specify further details of each <tool> and
+# if set, cause a wrapper script to be created.
+#
+# TOOLS_ARGS.<tool> additional arguments that are passed to the real
+# command ahead of any command-line arguments. This variable is
+# optional.
+#
+# TOOLS_SCRIPT.<tool> specifies the Bourne-shell scriptlet to embed
+# in the wrapper script that is executed when <tool> is called.
+# This variable is optional, and if left unspecified, then this
+# is built up from TOOLS_PATH.<tool> and TOOLS_ARGS.<tool> by
+# default.
+#
+# The following variables provide shortcuts for creating certain classes
+# of tools:
+#
+# TOOLS_NOOP is a list of tools that do nothing and return true.
+#
+# TOOLS_BROKEN is a list of tools that do nothing and return false.
+#
+# TOOLS_GNU_MISSING is a list of tools for which the GNU missing
+# script is invoked in place of the real tool. This is used
+# primarily to hide GNU auto* tools.
+#
+
+######################################################################
+
+.for _t_ in ${TOOLS_NOOP}
+TOOLS_CREATE+= ${_t_}
+TOOLS_SCRIPT.${_t_}?= exit 0
+.endfor
+
+.for _t_ in ${TOOLS_BROKEN}
+TOOLS_CREATE+= ${_t_}
+TOOLS_SCRIPT.${_t_}?= exit 1
+.endfor
+
+.for _t_ in ${TOOLS_GNU_MISSING}
+TOOLS_CREATE+= ${_t_}
+TOOLS_PATH.${_t_}?= ${PKGSRCDIR}/mk/gnu-config/missing
+TOOLS_SCRIPT.${_t_}?= ${TOOLS_PATH.${_t_}} ${_t_:T:C/-[0-9].*$//}
+.endfor
+
+######################################################################
+
+# These tools are used in the targets that actually create the wrappers
+# and symlinks. We define them here so that as a fallback, we'll just
+# use the ones in the PATH. This makes the tools framework more
+# standalone.
+
+CHMOD?= chmod
+ECHO?= echo
+FALSE?= false
+LN?= ln
+MKDIR?= mkdir -p
+
+######################################################################
+
+# If the command line was defined, then we create a wrapper.
+# If the real command isn't a full path, then we create a wrapper.
+# If some command arguments were given, then we create a wrapper.
+# Otherwise, we create a symlink.
+#
+# By default, the tool in ${TOOLS_DIR} will be in the "bin" directory
+# and will be called <tool>.
+#
+# The default wrapper script will invoke the real command, followed
+# by any arguments specified in TOOLS_ARGS.*, followed by any
+# command-line arguments passed to the wrapper script.
+#
+.for _t_ in ${TOOLS_CREATE}
+TOOLS_CMD.${_t_}?= ${TOOLS_DIR}/bin/${_t_}
+TOOLS_PATH.${_t_}?= ${FALSE}
+TOOLS_SCRIPT_DFLT.${_t_}= \
+ ${TOOLS_PATH.${_t_}} ${TOOLS_ARGS.${_t_}} "$$@"
+
+override-tools: ${TOOLS_CMD.${_t_}}
+
+${TOOLS_CMD.${_t_}}:
+ ${_PKG_SILENT}${_PKG_DEBUG}${TEST} -d ${.TARGET:H:Q} || \
+ ${MKDIR} ${.TARGET:H:Q}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ if ${TEST} -n ${TOOLS_SCRIPT.${_t_}:Q}""; then \
+ create=wrapper; \
+ script=${TOOLS_SCRIPT.${_t_}:Q}; \
+ elif ${TEST} -n ${TOOLS_PATH.${_t_}:Q}""; then \
+ if ${TEST} -n ${TOOLS_ARGS.${_t_}:Q}""; then \
+ create=wrapper; \
+ script=${TOOLS_SCRIPT_DFLT.${_t_}:Q}; \
+ else \
+ case ${TOOLS_PATH.${_t_}:Q}"" in \
+ /*) create=symlink ;; \
+ *) create=wrapper; \
+ script=${TOOLS_SCRIPT_DFLT.${_t_}:Q}; \
+ esac; \
+ fi; \
+ else \
+ create=symlink; \
+ fi; \
+ case "$$create" in \
+ wrapper) \
+ { ${ECHO} '#!'${TOOLS_SHELL:Q}; \
+ ${ECHO} 'wrapperlog="$${TOOLS_WRAPPER_LOG-'${_TOOLS_WRAP_LOG:Q}'}"'; \
+ ${ECHO} '${ECHO} "[*] "'${.TARGET:Q}'" $$@" >> $$wrapperlog'; \
+ ${ECHO} "${ECHO} \"<.> $$script\" >> \$$wrapperlog"; \
+ ${ECHO} "$$script"; \
+ } > ${.TARGET:Q}; \
+ ${CHMOD} +x ${.TARGET:Q}; \
+ ;; \
+ *) \
+ ${LN} -fs ${TOOLS_PATH.${_t_}:Q} ${.TARGET:Q}; \
+ ;; \
+ esac
+. for _a_ in ${TOOLS_ALIASES.${_t_}}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${TEST} ${.TARGET:Q} = ${.TARGET:H:Q}/${_a_} || \
+ ${LN} -fs ${.TARGET:T:Q} ${.TARGET:H:Q}/${_a_}
+. endfor
+.endfor
diff --git a/mk/tools/replace.mk b/mk/tools/replace.mk
index f0bf259163f..06a4223c1b9 100644
--- a/mk/tools/replace.mk
+++ b/mk/tools/replace.mk
@@ -1,4 +1,4 @@
-# $NetBSD: replace.mk,v 1.167 2006/05/21 16:55:21 jlam Exp $
+# $NetBSD: replace.mk,v 1.168 2006/06/06 06:30:29 jlam Exp $
#
# Copyright (c) 2005 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -1011,7 +1011,7 @@ TOOLS_PATH.xmkmf= ${TOOLS_PREFIX.xpkgwedge}/bin/pkgxmkmf
# Compute the locations of the pkgsrc-supplied tools.
FIND_PREFIX:= ${TOOLS_FIND_PREFIX}
-.include "../../mk/find-prefix.mk"
+.include "${PKGSRCDIR}/mk/find-prefix.mk"
######################################################################