summaryrefslogtreecommitdiff
path: root/mk/wrapper
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2004-09-21 15:01:38 +0000
committerjlam <jlam@pkgsrc.org>2004-09-21 15:01:38 +0000
commit1d55af8fb22c7af54d865aef3f622a1aa67ea527 (patch)
treee090baf88a9c4da9d6fa5d6398e63775525f7060 /mk/wrapper
parent32f5d6191552a98bca6f3fe162d3ee07128f8f15 (diff)
downloadpkgsrc-1d55af8fb22c7af54d865aef3f622a1aa67ea527.tar.gz
Initial commit of a new wrapper script framework that encapsulates
the non-buildlink-related code and moves it out of mk/buildlink3 into mk/wrapper. The buildlink3 code is modified to simply hook its transformations into the wrapper script framework. The wrapper script framework has some new features: * Support automatically passing "ABI" flags to the compiler and linker depending on the value of ${ABI}. Currently supports the SunPro compiler with ${ABI} == 64 and the MIPSPro compiler with ${ABI} as any of 32, n32, o32, and 64. * making UnixWare GCC accept -rpath options and silently converting them into an appropriate LD_RUN_PATH * Add cmd-sink-interix-gcc and cmd-sink-interix-ld that errors out when it sees -fpic/-fPIC and -shared/-Bshareable, respectively (requested by <tv>). * Much improved debugging output. It's possible to output the wrapper work log in-line with normal output by setting WRAPPER_LOG to "stderr". Important differences in behaviour from the old buildlink3 code include: * Only move the -l options to the end of the command line, leaving the -L options in-place. * Extend the autodetection of the libtool mode to detect "compile" and "uninstall". * Fix problem noted in both PR pkg/24760 and PR pkg/25500, where -L/usr/lib/* was being mangled improperly. * Remove the top-level "buildlink" target; instead, make buildlinking occur as part of the "wrapper" target. * mangle and sub-mangle are only meant to transform directories in -I, -L, and rpath options, so remove the lines in buildlink3/gen-transform.sh that transformed bare directories. * Add the ability for the libtool wrapper to be called just to unwrap an existing libtool archive by running: libtool --mode=unwrap -o libfoo.la The old --fix-la syntax no longer works. 20040818 ======== * Initial release of a new wrapper script framework that encapsulates the non-buildlink-related code and moves it out of mk/buildlink3. These features include: * making MIPSpro accept GCC options * making MIPSpro "ucode" accept GCC options * making SunPro accept GCC options * making "ld" accept -Wl,* options and silently removing the "-Wl," * (NEW) making UnixWare GCC accept -rpath options and silently converting them into an appropriate LD_RUN_PATH One major benefit of this is that the buildlink3 code is now much tighter and easier to understand since it concerns itself solely with buildlink-related details. I haven't yet optimized the wrapper cache, so the new wrapper scripts may take slightly longer to execute than the old buildlink3 wrapper scripts, but I'll be improving this over time. 20040821 ======== * Move the inclusion of $cmd_sink outside of the main loop in wrapper.sh so that the $cmd_sink script can be used to globally scan and process the arguments. Move the LD_RUN_PATH code to a cmd-sink-unixware-gcc script. Garbage-collect the now unused export_vars-related code. * Add cmd-sink-aix-xlc for AIX xlc that munges -Wl,-R* into an appropriate -blibpath option. * Add cmd-sink-interix-gcc and cmd-sink-interix-ld that errors out when it sees -fpic/-fPIC and -shared/-Bshareable, respectively (requested by <tv>). * Move the code that converts full paths to shared libraries into the "-Ldir -llib" equivalents from the buildlink3 code into wrapper/logic. Remove the same from bsd.buildlink3.mk and gen-transform.sh. * Move the code that checks for absolute rpaths from the buildlink3 code into wrapper/arg-source. Remove the same from bsd.buildlink3.mk and gen-transform.sh. * Only move the -l options to the end of the command line, leaving the -L options in-place. * Add more debugging code. 20040824 ======== * Fix quoting problems after arguments are transformed. Remove the hack that was inserted that magically made almost everything work because we do it the right way now. * Move the inclusion of $logic outside of the main loop in wrapper.sh so that the $logic script doesn't have to worry about underflowing the argument buffer. * Encapsulate the loop in wrapper.sh that fills the argument buffer entirely within the arg-source script. * Move from the logic script into the arg-source script the transformations that merge or split arguments. * Fix bug where skipargs was effectively being ignored if it was more than 1. * Handle the whitespace in transformations in the logic script that turn one library option into multiple library options, e.g. "-lreadline" -> "-ledit -ltermcap". * Allow you to specify an environment variable WRAPPER_SKIP_TRANSFORM for whether you wish to skip the transformation step in the logic script. This is intended for testing purposes. * Added check_prog() and init_lib() functions to the shell code library to make it more reusable outside of the wrapper framework. * Allow the msg_log() function to output to "stdout" or "stderr". If you want to have all of the logging appear on the screen, then you can now set WRAPPER_LOG=stderr. * Make some of the script components not overridable on a per-wrapper basis. * Add a gen-transform.sh script that generates transformation sedfiles. The "transform" script is used to transform arguments, while the "untransform" script is used to unwrap files. Move the no-rpath logic from buildlink3/gen-transform.sh into wrapper/gen-transform.sh since it's not buildlink3-specific. * Check for a non-empty blibpath before adding the option in cmd-sink-aix-xlc. * Extend the autodetection of the libtool mode to detect "compile" and "uninstall". * Add a cmd-sink-libtool script that doesn't pass linker options to libtool unless we're in "link" mode. * Set _USE_RPATH to "yes" for UnixWare so that the wrappers will see the rpath options and convert them to a LD_RUN_PATH definition. * Add more debugging code. 20040826 ======== * Rewrite buildlink3/gen-transform.sh to produce more precise sed commands. Drop some unused commands from the mini-language, and add a few more that are more restrictive in their scope. * Fix problem where repeated options weren't properly handled by some of sed commands. It's not enough that they're "global replace", since some patterns match separator characters before and after each option. We must repeat those patterns twice to catch all instances correctly. * Fix problem noted in both PR pkg/24760 and PR pkg/25500, where -L/usr/lib/* was being mangled improperly. * Remove the top-level "buildlink" target; instead, make buildlinking occur as part of the "wrapper" target. * Add more debugging code. 20040828 ======== * Added a head_queue function to shell-lib that returns the head of the named queue without popping it off the front of the queue. * Strip consecutive, repeated library options from the command line when we read it in the logic script. * Be more careful about not underflowing the argument buffer. 20040906 ======== * shell-lib was moved into pkgsrc/mk/scripts; correct references to that file in the wrapper code. * Use opt-sub instead of sub-mangle when protecting -I/usr/include/* and -L/usr/lib/* from buildlink transformations. This avoids adding lines that look like "-I-I..." in the transformation sedfiles. * mangle and sub-mangle are only meant to transform directories in -I, -L, and rpath options, so remove the lines in buildlink3/gen-transform.sh that transformed bare directories. * Fix bug in strip-slashdot where the "." wasn't backquoted and thus matched all characters instead of only the "." character. * Change the libtool wrapper to use a modified buildcmd script that doesn't rearrange any of the arguments. This should fix spurious problems where libtool doesn't understand how to parse the command line when the -l options are moved to the end of the argument list. * Fix bug in the logic script where the $cachearg and $cachedarg weren't being properly set at all times, which caused the cache to contain the wrong transformed argument. 20040907 ======== * Support automatically passing "ABI" flags to the compiler and linker depending on the value of ${ABI}. Currently supports the SunPro compiler with ${ABI} == 64 and the MIPSPro compiler with ${ABI} as any of 32, n32, o32, and 64. * Move back the code that splits absolute paths to shared libraries from arg-source back into logic. This allows us to correctly skip splitting those paths based on the previous option. Also add a sanity check that the library name in the split argument doesn't contain a "/" since shell globs are not as precise as REs. * Don't transform the path given after --dynamic-linker (used by GNU ld for ELF linkage). * Add the ability for the libtool wrapper to be called just to unwrap an existing libtool archive by running: libtool --mode=unwrap -o libfoo.la 20040914 ======== * Add a loop in libtool-fix-la to ensure that all of the options listed in the dependency_libs lines of *.lai files are processed. This fixes a buildlink3 leakage bug. * Merge the gen-transform.sh scripts between buildlink3 and wrapper and place them all in wrapper. This makes sense since the commands simply allow for many types of transformations, which buildlink3 takes advantage of, but there is nothing inherently buildlink-ish about those commands. * Don't directly manipulate SUBST_SED.unwrap. Instead, create the value of SUBST_SED.unwrap by combining several other variables (currently just _UNWRAP_SED) to ensure that the correct ordering is preserved. * Correct some confusing debugging messages.
Diffstat (limited to 'mk/wrapper')
-rw-r--r--mk/wrapper/NOTES31
-rw-r--r--mk/wrapper/arg-source113
-rw-r--r--mk/wrapper/bsd.wrapper.mk589
-rw-r--r--mk/wrapper/buildcmd75
-rw-r--r--mk/wrapper/cache-footer38
-rw-r--r--mk/wrapper/cache-header37
-rw-r--r--mk/wrapper/cmd-sink42
-rw-r--r--mk/wrapper/cmd-sink-aix-xlc74
-rw-r--r--mk/wrapper/cmd-sink-interix-gcc50
-rw-r--r--mk/wrapper/cmd-sink-interix-ld50
-rw-r--r--mk/wrapper/cmd-sink-ld67
-rw-r--r--mk/wrapper/cmd-sink-unixware-gcc72
-rw-r--r--mk/wrapper/gen-reorder.sh142
-rw-r--r--mk/wrapper/gen-transform.sh466
-rw-r--r--mk/wrapper/logic270
-rw-r--r--mk/wrapper/transform-mipspro-cc78
-rw-r--r--mk/wrapper/transform-mipspro-ucode-cc84
-rw-r--r--mk/wrapper/transform-sunpro-cc115
-rw-r--r--mk/wrapper/wrapper.sh107
19 files changed, 2500 insertions, 0 deletions
diff --git a/mk/wrapper/NOTES b/mk/wrapper/NOTES
new file mode 100644
index 00000000000..0a84bf22672
--- /dev/null
+++ b/mk/wrapper/NOTES
@@ -0,0 +1,31 @@
+$NetBSD: NOTES,v 1.1 2004/09/21 15:01:41 jlam Exp $
+
+
+ ==> {"$@"} ,--> {argbuf} ,--> {cmdbuf}
+ | |
+ ^ | | | | |
+ | `------. | | | |
+ | | | | | |
+ v v | | | |
+ | |
+ [scan] [arg-source] `--> [logic] `--> [cmd-sink]
+
+ ^ ^ ^ ^
+ | | | |
+ ,-----------------' | | |
+ | ,-------' `---. |
+ | | | |
+ v v v v
+
+ [cache] [transform.sed] [transform] [buildcmd]
+
+ |
+ ,-- {cmd} <--|
+ {cmd} <===| |
+ `-- {libs} <--'
+
+ ^
+ |
+ v
+
+ [reorderlibs]
diff --git a/mk/wrapper/arg-source b/mk/wrapper/arg-source
new file mode 100644
index 00000000000..bcd148f690b
--- /dev/null
+++ b/mk/wrapper/arg-source
@@ -0,0 +1,113 @@
+# $NetBSD: arg-source,v 1.1 2004/09/21 15:01:41 jlam Exp $
+#
+# Copyright (c) 2004 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 script manages a buffer through which arguments from the command
+# line are funneled. Along the way, the arguments are potentially
+# merged and split an various ways to canonicalize their representation.
+# This script should be sourced within a loop and upon exiting returns
+# an argument in $arg.
+#
+# This is done by pushing the next command-line argument onto a queue,
+# then using a processing loop to pop an argument off of the top of
+# the queue, transform it, and possibly push more arguments back onto
+# the queue.
+
+# Push arguments from the command line into the argument buffer.
+skipargs=0
+while $test $# -gt 0; do
+ arg="$1"; shift
+ case $arg in
+ ##############################################################
+ # Merge "-I /dir" into a single "-I/dir". Same for -L, -R.
+ ##############################################################
+ -[ILR])
+ nextarg="$1"; shift
+ shquote "$nextarg"; nextarg="$shquoted"
+ append_queue argbuf "$arg$nextarg"
+ $debug_log $wrapperlog " (arg-source) push: $arg$nextarg"
+ ;;
+ ##############################################################
+ # Split "-Wl,-R/dir1:/dir2" into "-Wl,-R/dir1 -Wl,-R/dir2".
+ # Same for -Wl,-rpath and -Wl,-rpath-link.
+ ##############################################################
+ -R*:*|-Wl,-R*:*|\
+ -Wl,-rpath,*:*|-Wl,-rpath-link,*:*|-Wl,--rpath,*:*)
+ case $arg in
+ -R*) R="-R" ;;
+ -Wl,-R*) R="-Wl,-R" ;;
+ -Wl,-rpath,*) R="-Wl,-rpath," ;;
+ -Wl,-rpath-link,*) R="-Wl,-rpath-link," ;;
+ -Wl,--rpath,*) R="-Wl,--rpath," ;;
+ esac
+ list="${arg#$R}"
+ save_IFS="${IFS}"; IFS=":"
+ for dir in $list; do
+ shquote "$dir"; dir="$shquoted"
+ append_queue argbuf "$R$dir"
+ $debug_log $wrapperlog " (arg-source) push: $R$dir"
+ done
+ IFS="${save_IFS}"
+ ;;
+ ##############################################################
+ # "-Xlinker arg" is the equivalent of "-Wl,arg" so convert it
+ # here before queueing it up. We also need to keep converting
+ # as long as there are consecutive "-Xlinker ..." options
+ # because they are most likely part of the same long option
+ # list for the linker.
+ ##############################################################
+ -Xlinker)
+ nextarg="$1"; shift
+ case $nextarg in
+ -Wl,*)
+ append_queue argbuf "$nextarg"
+ $debug_log $wrapperlog " (arg-source) push: $nextarg"
+ ;;
+ *)
+ shquote "$nextarg"; nextarg="$shquoted"
+ append_queue argbuf "-Wl,$nextarg"
+ $debug_log $wrapperlog " (arg-source) push: -Wl,$nextarg"
+ ;;
+ esac
+ ;;
+ ##############################################################
+ # For everything else, just queue it up.
+ ##############################################################
+ *)
+ append_queue argbuf "$arg"
+ $debug_log $wrapperlog " (arg-source) push: $arg"
+ ;;
+ esac
+done
diff --git a/mk/wrapper/bsd.wrapper.mk b/mk/wrapper/bsd.wrapper.mk
new file mode 100644
index 00000000000..9450dea4756
--- /dev/null
+++ b/mk/wrapper/bsd.wrapper.mk
@@ -0,0 +1,589 @@
+# $NetBSD: bsd.wrapper.mk,v 1.1 2004/09/21 15:01:41 jlam Exp $
+#
+# Copyright (c) 2004 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.
+
+.if ${PKG_DEBUG_LEVEL} > 0
+ECHO_WRAPPER_MSG?= ${ECHO}
+.else
+ECHO_WRAPPER_MSG?= ${TRUE}
+.endif
+WRAPPER_DIR= ${WRKDIR}/.wrapper
+WRAPPER_BINDIR= ${WRAPPER_DIR}/bin
+WRAPPER_TMPDIR= ${WRAPPER_DIR}/tmp
+WRAPPER_SRCDIR= ${.CURDIR}/../../mk/wrapper
+WRAPPER_SHELL= ${SH}
+_WRAP_VARS_MK= ${WRAPPER_DIR}/vars.mk
+
+.if exists(${_WRAP_VARS_MK})
+. include "${_WRAP_VARS_MK}"
+.endif
+
+.PHONY: do-wrapper
+
+# USE_BUILDLINK3 == "no" implies NO_BUILDLINK
+.if !empty(USE_BUILDLINK3:M[nN][oO])
+NO_BUILDLINK= yes
+.endif
+.if !defined(NO_BUILDLINK)
+. include "../../mk/buildlink3/bsd.buildlink3.mk"
+.endif
+
+# Create the saved variables Makefile fragment to pass variables
+# through to sub-make processes invoked on the same Makefile.
+#
+do-wrapper: ${_WRAP_VARS_MK}
+
+# Prepend ${WRAPPER_BINDIR} to the PATH so that the wrappers are found
+# first when searching for executables.
+#
+PREPEND_PATH+= ${WRAPPER_BINDIR}
+
+###
+### BEGIN: after "wrapper" phase
+###
+.if !empty(PHASES_AFTER_WRAPPER:M${PKG_PHASE})
+
+WRAPPER_DEBUG?= yes
+CONFIGURE_ENV+= WRAPPER_DEBUG="${WRAPPER_DEBUG}"
+MAKE_ENV+= WRAPPER_DEBUG="${WRAPPER_DEBUG}"
+
+# The caching code, which greatly speeds up the build process, doesn't
+# work correctly on certain platforms.
+#
+_WRAP_BROKEN_CACHE= Darwin-5.*-*
+
+.if !defined(WRAPPER_UPDATE_CACHE)
+WRAPPER_UPDATE_CACHE?= yes
+. for _pattern_ in ${_WRAP_BROKEN_CACHE}
+. if !empty(MACHINE_PLATFORM:M${_pattern_})
+WRAPPER_UPDATE_CACHE= no
+. endif
+. endfor
+.endif
+CONFIGURE_ENV+= WRAPPER_UPDATE_CACHE="${WRAPPER_UPDATE_CACHE}"
+MAKE_ENV+= WRAPPER_UPDATE_CACHE="${WRAPPER_UPDATE_CACHE}"
+
+# Only do the (expensive) reordering step if we have reordering
+# transformations.
+#
+WRAPPER_REORDER_CMDS?= # empty
+.if !empty(WRAPPER_REORDER_CMDS)
+MAKE_ENV+= WRAPPER_REORDER=yes
+.endif
+
+# Remove rpath options if _USE_RPATH is "no".
+.if defined(_USE_RPATH) && !empty(_USE_RPATH:M[nN][oO])
+_WRAP_TRANSFORM_CMDS+= no-rpath
+.endif
+
+# Add any package-specified transformations.
+_WRAP_TRANSFORM_CMDS+= ${WRAPPER_TRANSFORM_CMDS}
+
+# _WRAP_PATH is the path we embed in the wrapper scripts for subsequent
+# calls to the toolchain. We don't need to wrap them again because they
+# are already being called with the correct arguments.
+#
+.if !defined(_WRAP_PATH)
+_WRAP_PATH= ${PATH:S/${WRAPPER_BINDIR}://:S/:${WRAPPER_BINDIR}//}
+WRAPPER_VARS+= _WRAP_PATH
+.endif
+
+# Generate wrapper scripts for the compiler tools. These wrapper
+# scripts are to be used instead of the actual compiler tools when
+# building software.
+#
+# WRAPPER_CC, WRAPPER_LD, etc. are the full paths to the wrapper
+# scripts.
+#
+# _WRAP_ALIASES.CC, _WRAP_ALIASES.LD, etc. are the other names by
+# which each wrapper may be invoked.
+#
+_WRAPPEES+= AS
+_WRAPPEES+= CC
+_WRAPPEES+= CPP
+_WRAPPEES+= CXX
+_WRAPPEES+= FC
+.if defined(USE_X11)
+IMAKE?= ${X11BASE}/bin/imake
+_WRAPPEES+= IMAKE
+.endif
+_WRAPPEES+= LD
+
+_WRAP_ALIASES.AS= as
+_WRAP_ALIASES.CC= cc gcc
+_WRAP_ALIASES.CXX= c++ g++ CC
+_WRAP_ALIASES.CPP= cpp
+_WRAP_ALIASES.FC= f77 g77
+_WRAP_ALIASES.IMAKE= imake
+_WRAP_ALIASES.LD= ld
+
+# _WRAP_*.<wrappee> variables represent "template methods" of the main
+# wrapper script. This allows individual wrappers to be customized to
+# some degree:
+#
+_WRAP_ENV?= PATH="${_WRAP_PATH}"; export PATH
+_WRAP_EMPTY_FILE?= ${WRAPPER_TMPDIR}/empty
+_WRAP_ARG_SOURCE?= ${WRAPPER_TMPDIR}/arg-source
+_WRAP_BUILDCMD?= ${WRAPPER_TMPDIR}/buildcmd
+_WRAP_CACHE?= ${WRAPPER_TMPDIR}/cache
+_WRAP_CACHE_HEADER?= ${WRAPPER_TMPDIR}/cache-header
+_WRAP_CACHE_BODY?= ${WRAPPER_TMPDIR}/cache-body
+_WRAP_CACHE_FOOTER?= ${WRAPPER_TMPDIR}/cache-footer
+_WRAP_CLEANUP?= ${_WRAP_EMPTY_FILE}
+_WRAP_CMD_SINK?= ${WRAPPER_TMPDIR}/cmd-sink
+_WRAP_GEN_REORDER?= ${WRAPPER_TMPDIR}/gen-reorder
+_WRAP_GEN_TRANSFORM?= ${WRAPPER_TMPDIR}/gen-transform
+_WRAP_LOG?= ${WRKLOG}
+_WRAP_LOGIC?= ${WRAPPER_TMPDIR}/logic
+_WRAP_REORDERLIBS?= ${WRAPPER_TMPDIR}/reorderlibs
+_WRAP_SCAN?= ${_WRAP_EMPTY_FILE}
+_WRAP_SHELL_LIB?= ${WRAPPER_TMPDIR}/shell-lib
+_WRAP_SKIP_TRANSFORM?= yes
+_WRAP_TRANSFORM?= ${_WRAP_EMPTY_FILE}
+_WRAP_TRANSFORM_SED?= # empty
+_WRAP_TRANSFORM_SEDFILE?= ${WRAPPER_TMPDIR}/transform.sed
+_WRAP_UNTRANSFORM_SEDFILE?= ${WRAPPER_TMPDIR}/untransform.sed
+
+# Generate the transformation sedfiles if we need them.
+.if !empty(_WRAP_TRANSFORM_CMDS)
+do-wrapper: ${_WRAP_TRANSFORM_SEDFILE} ${_WRAP_UNTRANSFORM_SEDFILE}
+_WRAP_TRANSFORM_SED+= -f ${_WRAP_TRANSFORM_SEDFILE}
+_UNWRAP_SED= -f ${_WRAP_UNTRANSFORM_SEDFILE}
+.endif
+
+.for _wrappee_ in ${_WRAPPEES}
+_WRAPPER_SH.${_wrappee_}= ${WRAPPER_SRCDIR}/wrapper.sh
+_WRAP_ENV.${_wrappee_}?= ${_WRAP_ENV}
+_WRAP_EXTRA_ARGS.${_wrappee_}?= # empty
+_WRAP_ARG_SOURCE.${_wrappee_}?= ${_WRAP_ARG_SOURCE}
+_WRAP_BUILDCMD.${_wrappee_}?= ${_WRAP_BUILDCMD}
+_WRAP_CACHE.${_wrappee_}?= ${_WRAP_CACHE}
+_WRAP_CACHE_HEADER.${_wrappee_}?= ${_WRAP_CACHE_HEADER}
+_WRAP_CACHE_BODY.${_wrappee_}?= ${_WRAP_CACHE_BODY}
+_WRAP_CACHE_FOOTER.${_wrappee_}?= ${_WRAP_CACHE_FOOTER}
+_WRAP_CLEANUP.${_wrappee_}?= ${_WRAP_CLEANUP}
+_WRAP_CMD_SINK.${_wrappee_}?= ${_WRAP_CMD_SINK}
+_WRAP_LOG.${_wrappee_}?= ${_WRAP_LOG}
+_WRAP_LOGIC.${_wrappee_}?= ${_WRAP_LOGIC}
+_WRAP_SCAN.${_wrappee_}?= ${_WRAP_SCAN}
+_WRAP_TRANSFORM.${_wrappee_}?= ${_WRAP_TRANSFORM}
+_WRAP_TRANSFORM_SED.${_wrappee_}?= ${_WRAP_TRANSFORM_SED}
+. if !empty(_WRAP_TRANSFORM_SED.${_wrappee_})
+_WRAP_SKIP_TRANSFORM.${_wrappee_}?= no
+. else
+_WRAP_SKIP_TRANSFORM.${_wrappee_}?= ${_WRAP_SKIP_TRANSFORM}
+. endif
+.endfor
+
+.if !empty(PKGSRC_COMPILER:Maix-xlc)
+_WRAP_CMD_SINK.CC= ${WRAPPER_TMPDIR}/cmd-sink-aix-xlc
+_WRAP_CMD_SINK.CXX= ${_WRAP_CMD_SINK.CC}
+_WRAP_CMD_SINK.LD= ${_WRAP_CMD_SINK.CC}
+.endif
+
+.if !empty(PKGSRC_COMPILER:Mmipspro)
+_WRAP_CACHE_BODY.CC= ${WRAPPER_TMPDIR}/cache-body-mipspro-cc
+_WRAP_TRANSFORM.CC= ${WRAPPER_TMPDIR}/transform-mipspro-cc
+_WRAP_CACHE_BODY.CXX= ${_WRAP_CACHE_BODY.CC}
+_WRAP_TRANSFORM.CXX= ${_WRAP_TRANSFORM.CC}
+.endif
+
+.if !empty(PKGSRC_COMPILER:Mmipspro-ucode)
+_WRAP_CACHE_BODY.CC= ${WRAPPER_TMPDIR}/cache-body-mipspro-ucode-cc
+_WRAP_TRANSFORM.CC= ${WRAPPER_TMPDIR}/transform-mipspro-ucode-cc
+_WRAP_CACHE_BODY.CXX= ${_WRAP_CACHE_BODY.CC}
+_WRAP_TRANSFORM.CXX= ${_WRAP_TRANSFORM.CC}
+.endif
+
+.if !empty(PKGSRC_COMPILER:Msunpro)
+_WRAP_CACHE_BODY.CC= ${WRAPPER_TMPDIR}/cache-body-sunpro-cc
+_WRAP_TRANSFORM.CC= ${WRAPPER_TMPDIR}/transform-sunpro-cc
+_WRAP_CACHE_BODY.CXX= ${_WRAP_CACHE_BODY.CC}
+_WRAP_TRANSFORM.CXX= ${_WRAP_TRANSFORM.CC}
+.endif
+
+_WRAP_CMD_SINK.LD= ${WRAPPER_TMPDIR}/cmd-sink-ld
+_WRAP_TRANSFORM_SED.IMAKE= # empty
+
+# XXX
+# XXX This section is ${OPSYS}-specific and shouldn't be here.
+# XXX
+.if ${OPSYS} == "Interix"
+_WRAP_CMD_SINK.CC= ${WRAPPER_TMPDIR}/cmd-sink-interix-gcc
+_WRAP_CMD_SINK.CXX= ${_WRAP_CMD_SINK.CC}
+_WRAP_CMD_SINK.LD= ${WRAPPER_TMPDIR}/cmd-sink-interix-ld
+.elif ${OPSYS} == "UnixWare"
+_WRAP_CMD_SINK.CC= ${WRAPPER_TMPDIR}/cmd-sink-unixware-gcc
+_WRAP_CMD_SINK.CXX= ${_WRAP_CMD_SINK.CC}
+_WRAP_CMD_SINK.LD= ${_WRAP_CMD_SINK.CC}
+.endif
+
+# Filter to scrunch shell scripts by removing comments and empty lines.
+_WRAP_SH_CRUNCH_FILTER= \
+ ${GREP} -v "^\#[^!]" | ${GREP} -v "^[ ][ ]*\#" | \
+ ${GREP} -v "^\#$$" | ${GREP} -v "^[ ]*$$"
+
+_WRAP_SUBST_SED= \
+ -e "s|@CAT@|${CAT:Q}|g" \
+ -e "s|@ECHO@|${ECHO:Q}|g" \
+ -e "s|@EXPR@|${EXPR:Q}|g" \
+ -e "s|@SED@|${SED:Q}|g" \
+ -e "s|@TEST@|${TEST:Q}|g" \
+ -e "s|@WRAPPER_SHELL@|${WRAPPER_SHELL:Q}|g" \
+ -e "s|@_WRAP_LOG@|${_WRAP_LOG:Q}|g" \
+ -e "s|@_WRAP_REORDERLIBS@|${_WRAP_REORDERLIBS:Q}|g" \
+ -e "s|@_WRAP_SHELL_LIB@|${_WRAP_SHELL_LIB:Q}|g"
+
+.for _wrappee_ in ${_WRAPPEES}
+. if defined(PKG_${_wrappee_})
+_WRAP_PKG_${_wrappee_}= ${PKG_${_wrappee_}}
+. else
+_WRAP_PKG_${_wrappee_}= ${${_wrappee_}}
+. endif
+
+WRAPPER_${_wrappee_}= \
+ ${WRAPPER_BINDIR}/${_WRAP_PKG_${_wrappee_}:T:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//}
+${_wrappee_}:= ${WRAPPER_${_wrappee_}:T}
+
+_WRAP_SUBST_SED.${_wrappee_}= \
+ -e "s|@_WRAP_ENV@|${_WRAP_ENV.${_wrappee_}:Q}|g" \
+ -e "s|@_WRAP_EXTRA_ARGS@|${_WRAP_EXTRA_ARGS.${_wrappee_}:Q}|g" \
+ -e "s|@_WRAP_ARG_SOURCE@|${_WRAP_ARG_SOURCE.${_wrappee_}:Q}|g" \
+ -e "s|@_WRAP_BUILDCMD@|${_WRAP_BUILDCMD.${_wrappee_}:Q}|g" \
+ -e "s|@_WRAP_CACHE@|${_WRAP_CACHE.${_wrappee_}:Q}|g" \
+ -e "s|@_WRAP_CACHE_HEADER@|${_WRAP_CACHE_HEADER.${_wrappee_}:Q}|g" \
+ -e "s|@_WRAP_CACHE_BODY@|${_WRAP_CACHE_BODY.${_wrappee_}:Q}|g" \
+ -e "s|@_WRAP_CACHE_FOOTER@|${_WRAP_CACHE_FOOTER.${_wrappee_}:Q}|g" \
+ -e "s|@_WRAP_CLEANUP@|${_WRAP_CLEANUP.${_wrappee_}:Q}|g" \
+ -e "s|@_WRAP_CMD_SINK@|${_WRAP_CMD_SINK.${_wrappee_}:Q}|g" \
+ -e "s|@_WRAP_LOG@|${_WRAP_LOG.${_wrappee_}:Q}|g" \
+ -e "s|@_WRAP_LOGIC@|${_WRAP_LOGIC.${_wrappee_}:Q}|g" \
+ -e "s|@_WRAP_SCAN@|${_WRAP_SCAN.${_wrappee_}:Q}|g" \
+ -e "s|@_WRAP_SKIP_TRANSFORM@|${_WRAP_SKIP_TRANSFORM.${_wrappee_}:Q}|g" \
+ -e "s|@_WRAP_TRANSFORM@|${_WRAP_TRANSFORM.${_wrappee_}:Q}|g" \
+ ${_WRAP_SUBST_SED}
+
+_WRAP_COOKIE.${_wrappee_}= ${WRAPPER_DIR}/.wrapper_${_wrappee_}_done
+
+do-wrapper: ${_WRAP_COOKIE.${_wrappee_}}
+${_WRAP_COOKIE.${_wrappee_}}: \
+ ${_WRAPPER_SH.${_wrappee_}} \
+ ${_WRAP_ARG_SOURCE.${_wrappee_}} \
+ ${_WRAP_BUILDCMD.${_wrappee_}} \
+ ${_WRAP_CACHE.${_wrappee_}} \
+ ${_WRAP_CLEANUP.${_wrappee_}} \
+ ${_WRAP_CMD_SINK.${_wrappee_}} \
+ ${_WRAP_LOGIC.${_wrappee_}} \
+ ${_WRAP_REORDERLIBS} \
+ ${_WRAP_SCAN.${_wrappee_}} \
+ ${_WRAP_SHELL_LIB} \
+ ${_WRAP_TRANSFORM.${_wrappee_}}
+ ${_PKG_SILENT}${_PKG_DEBUG}${ECHO_WRAPPER_MSG} \
+ "=> Creating wrapper: ${WRAPPER_${_wrappee_}}"
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ wrappee="${_WRAP_PKG_${_wrappee_}:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//}"; \
+ gen_wrapper=yes; \
+ case $${wrappee} in \
+ /*) \
+ absdir=; \
+ ;; \
+ *) \
+ save_IFS="$$IFS"; \
+ IFS=":"; \
+ for dir in $${PATH}; do \
+ case $${dir} in \
+ *${BUILDLINK_DIR}*) \
+ ;; \
+ *) \
+ if [ -f $${dir}/$${wrappee} ] || \
+ [ -h $${dir}/$${wrappee} ] && \
+ [ -x $${dir}/$${wrappee} ]; then \
+ absdir=$${dir}/; \
+ wrappee=$${absdir}$${wrappee}; \
+ break; \
+ fi; \
+ ;; \
+ esac; \
+ done; \
+ IFS="$$save_IFS"; \
+ if [ ! -x "$${wrappee}" ]; then \
+ gen_wrapper=no; \
+ ${ECHO_WRAPPER_MSG} "Warning: unable to create \`$${wrappee}' wrapper script"; \
+ fi; \
+ ;; \
+ esac; \
+ case $$gen_wrapper in \
+ yes) \
+ ${MKDIR} ${WRAPPER_${_wrappee_}:H}; \
+ ${CAT} ${_WRAPPER_SH.${_wrappee_}} | \
+ ${SED} ${_WRAP_SUBST_SED.${_wrappee_}} \
+ -e "s|@WRAPPEE@|$${absdir}${_WRAP_PKG_${_wrappee_}:Q}|g" | \
+ ${_WRAP_SH_CRUNCH_FILTER} \
+ > ${WRAPPER_${_wrappee_}}; \
+ ${CHMOD} +x ${WRAPPER_${_wrappee_}}; \
+ ;; \
+ esac
+ ${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_FLAGS} ${.TARGET}
+
+. for _alias_ in ${_WRAP_ALIASES.${_wrappee_}:S/^/${WRAPPER_BINDIR}\//}
+. if !target(${_alias_})
+do-wrapper: ${_alias_}
+${_alias_}: ${_WRAP_COOKIE.${_wrappee_}}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ if [ ! -x ${_alias_} -a -x ${WRAPPER_${_wrappee_}} ]; then \
+ ${ECHO_WRAPPER_MSG} "=> Linking wrapper: ${_alias_}"; \
+ ${LN} -f ${WRAPPER_${_wrappee_}} ${_alias_}; \
+ fi
+. endif
+. endfor
+.endfor # _WRAPPEES
+
+.for _target_ in ${WRAPPER_TARGETS}
+do-wrapper: ${_target_}
+.endfor
+
+${WRAPPER_TMPDIR}/cmd-sink-aix-xlc: \
+ ${WRAPPER_SRCDIR}/cmd-sink-aix-xlc
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
+
+${WRAPPER_TMPDIR}/cmd-sink-interix-gcc: \
+ ${WRAPPER_SRCDIR}/cmd-sink-interix-gcc
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
+
+${WRAPPER_TMPDIR}/cmd-sink-ld: \
+ ${WRAPPER_SRCDIR}/cmd-sink-ld
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
+
+${WRAPPER_TMPDIR}/cmd-sink-unixware-gcc: \
+ ${WRAPPER_SRCDIR}/cmd-sink-unixware-gcc
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
+
+${WRAPPER_TMPDIR}/transform-mipspro-cc: \
+ ${WRAPPER_SRCDIR}/transform-mipspro-cc
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
+
+${WRAPPER_TMPDIR}/transform-mipspro-ucode-cc: \
+ ${WRAPPER_SRCDIR}/transform-mipspro-ucode-cc
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
+
+${WRAPPER_TMPDIR}/transform-sunpro-cc: \
+ ${WRAPPER_SRCDIR}/transform-sunpro-cc
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
+
+.if !target(${_WRAP_GEN_REORDER})
+${_WRAP_GEN_REORDER}: \
+ ${_WRAP_SHELL_LIB} \
+ ${WRAPPER_SRCDIR}/gen-reorder.sh
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${CAT} ${WRAPPER_SRCDIR}/gen-reorder.sh \
+ | ${SED} ${_WRAP_SUBST_SED} \
+ | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CHMOD} +x ${.TARGET}
+.endif
+
+.if !target(${_WRAP_GEN_TRANSFORM})
+${_WRAP_GEN_TRANSFORM}: \
+ ${_WRAP_SHELL_LIB} \
+ ${WRAPPER_SRCDIR}/gen-transform.sh
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${CAT} ${WRAPPER_SRCDIR}/gen-transform.sh \
+ | ${SED} ${_WRAP_SUBST_SED} \
+ | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CHMOD} +x ${.TARGET}
+.endif
+
+.if !target(${_WRAP_REORDERLIBS})
+${_WRAP_REORDERLIBS}: ${_WRAP_GEN_REORDER}
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${_WRAP_GEN_REORDER} ${WRAPPER_REORDER_CMDS} > ${.TARGET}
+.endif
+
+. if !target(${_WRAP_SHELL_LIB})
+${_WRAP_SHELL_LIB}: ${.CURDIR}/../../mk/scripts/shell-lib
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
+. endif
+
+.if !target(${_WRAP_TRANSFORM_SEDFILE})
+${_WRAP_TRANSFORM_SEDFILE}: ${_WRAP_GEN_TRANSFORM}
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${_WRAP_GEN_TRANSFORM} transform ${_WRAP_TRANSFORM_CMDS} \
+ > ${.TARGET}
+.endif
+
+.if !target(${_WRAP_UNTRANSFORM_SEDFILE})
+${_WRAP_UNTRANSFORM_SEDFILE}: ${_WRAP_GEN_TRANSFORM}
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${_WRAP_GEN_TRANSFORM} untransform ${_WRAP_TRANSFORM_CMDS} \
+ > ${.TARGET}
+.endif
+
+.for _wrappee_ in ${_WRAPPEES}
+. if !target$(${_WRAP_EMPTY_FILE})
+${_WRAP_EMPTY_FILE}:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_ARGS} ${.TARGET}
+. endif
+
+. if !target(${_WRAP_ARG_SOURCE.${_wrappee_}})
+${_WRAP_ARG_SOURCE.${_wrappee_}}: ${WRAPPER_SRCDIR}/arg-source
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
+. endif
+
+. if !target(${_WRAP_BUILDCMD.${_wrappee_}})
+${_WRAP_BUILDCMD.${_wrappee_}}: ${WRAPPER_SRCDIR}/buildcmd
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
+. endif
+
+. if !target(${_WRAP_CACHE.${_wrappee_}})
+${_WRAP_CACHE.${_wrappee_}}: \
+ ${_WRAP_CACHE_HEADER.${_wrappee_}} \
+ ${_WRAP_CACHE_BODY.${_wrappee_}} \
+ ${_WRAP_CACHE_FOOTER.${_wrappee_}}
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
+. endif
+
+. if !target(${_WRAP_CACHE_HEADER.${_wrappee_}})
+${_WRAP_CACHE_HEADER.${_wrappee_}}: ${WRAPPER_SRCDIR}/cache-header
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
+. endif
+
+. if !target(${_WRAP_CACHE_BODY.${_wrappee_}})
+${_WRAP_CACHE_BODY.${_wrappee_}}:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_ARGS} ${.TARGET}
+. endif
+
+. if !target(${_WRAP_CACHE_FOOTER.${_wrappee_}})
+${_WRAP_CACHE_FOOTER.${_wrappee_}}: ${WRAPPER_SRCDIR}/cache-footer
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
+. endif
+
+. if !target(${_WRAP_CMD_SINK.${_wrappee_}})
+${_WRAP_CMD_SINK.${_wrappee_}}: ${WRAPPER_SRCDIR}/cmd-sink
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
+. endif
+
+. if !target(${_WRAP_LOGIC.${_wrappee_}})
+${_WRAP_LOGIC.${_wrappee_}}: ${WRAPPER_SRCDIR}/logic
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${SED} -e "s|@_WRAP_TRANSFORM_SED@|${_WRAP_TRANSFORM_SED.${_wrappee_}:Q}|g" \
+ | ${_WRAP_SH_CRUNCH_FILTER} > ${.TARGET}
+. endif
+.endfor # _WRAPPEES
+
+.if !target(${_WRAP_VARS_MK})
+${_WRAP_VARS_MK}:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${.TARGET}.tmp
+. for _var_ in ${WRAPPER_VARS}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${ECHO} "${_var_}= ${${_var_}}" >> ${.TARGET}.tmp
+. endfor
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ if [ -f ${.TARGET}.tmp ]; then \
+ ${SORT} -u ${.TARGET}.tmp > ${.TARGET}; \
+ ${RM} -f ${.TARGET}.tmp; \
+ fi
+ ${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_FLAGS} ${.TARGET}
+.endif
+
+# UNWRAP_PATTERNS and UNWRAP_FILES list shell globs and files relative to
+# ${WRKSRC} that need to be "unwrapped".
+#
+UNWRAP_PATTERNS?= # empty
+_UNWRAP_PATTERNS= ${UNWRAP_PATTERNS}
+_UNWRAP_PATTERNS+= *-config
+_UNWRAP_PATTERNS+= *Conf.sh
+_UNWRAP_PATTERNS+= *.pc
+_UNWRAP_PATTERNS_FIND= \
+ \( ${_UNWRAP_PATTERNS:S/$/!/:S/^/-o -name !/:S/!/"/g:S/-o//1} \)
+UNWRAP_FILES?= # empty
+_UNWRAP_FILES= \
+ ${UNWRAP_FILES} \
+ `${FIND} . ${_UNWRAP_PATTERNS_FIND} -print | ${SED} -e 's|^\./||' | ${SORT} -u`
+_UNWRAP_SED?= # empty
+
+SUBST_CLASSES+= unwrap
+SUBST_STAGE.unwrap= post-build
+SUBST_MESSAGE.unwrap= "Unwrapping files-to-be-installed."
+SUBST_FILES.unwrap= ${_UNWRAP_FILES}
+SUBST_SED.unwrap= ${_UNWRAP_SED}
+.if defined(WRAPPER_DEBUG) && !empty(WRAPPER_DEBUG:M[yY][eE][sS])
+SUBST_POSTCMD.unwrap= ${DO_NADA}
+.endif
+
+.endif # PHASES_AFTER_WRAPPER
+###
+### END: after "wrapper" phase
+###
+
+.if !target(do-wrapper)
+do-wrapper:
+ @${DO_NADA}
+.endif
diff --git a/mk/wrapper/buildcmd b/mk/wrapper/buildcmd
new file mode 100644
index 00000000000..42fb3575857
--- /dev/null
+++ b/mk/wrapper/buildcmd
@@ -0,0 +1,75 @@
+# $NetBSD: buildcmd,v 1.1 2004/09/21 15:01:41 jlam Exp $
+#
+# Copyright (c) 2004 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.
+
+case $arg in
+######################################################################
+# Don't append empty arguments to the command line.
+######################################################################
+"")
+ ;;
+######################################################################
+# Reduce command length by not appending options that we've already
+# seen. We also ensure that all of the -l options come after the -L
+# options, and suppress consecutive repeated libraries.
+######################################################################
+-[DILR]*|-Wl,-R*|-Wl,-*,/*)
+ case $cmd in
+ *" "$arg|*" "$arg" "*)
+ ;;
+ *)
+ shquote "$arg"; arg="$shquoted"
+ cmd="$cmd $arg"
+ ;;
+ esac
+ ;;
+-l*)
+ case $libs in
+ *" "$arg)
+ ;;
+ *)
+ shquote "$arg"; arg="$shquoted"
+ libs="$libs $arg"
+ ;;
+ esac
+ ;;
+######################################################################
+# Append $arg to $cmd to build up the command line to be executed.
+######################################################################
+*)
+ shquote "$arg"; arg="$shquoted"
+ cmd="$cmd $arg"
+ ;;
+esac
diff --git a/mk/wrapper/cache-footer b/mk/wrapper/cache-footer
new file mode 100644
index 00000000000..4af7e981975
--- /dev/null
+++ b/mk/wrapper/cache-footer
@@ -0,0 +1,38 @@
+# $NetBSD: cache-footer,v 1.1 2004/09/21 15:01:41 jlam Exp $
+#
+# Copyright (c) 2004 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.
+
+*) cachehit=no ;;
+esac
diff --git a/mk/wrapper/cache-header b/mk/wrapper/cache-header
new file mode 100644
index 00000000000..fa4200e56b0
--- /dev/null
+++ b/mk/wrapper/cache-header
@@ -0,0 +1,37 @@
+# $NetBSD: cache-header,v 1.1 2004/09/21 15:01:41 jlam Exp $
+#
+# Copyright (c) 2004 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.
+
+case $arg in
diff --git a/mk/wrapper/cmd-sink b/mk/wrapper/cmd-sink
new file mode 100644
index 00000000000..94f25d4ac63
--- /dev/null
+++ b/mk/wrapper/cmd-sink
@@ -0,0 +1,42 @@
+# $NetBSD: cmd-sink,v 1.1 2004/09/21 15:01:41 jlam Exp $
+#
+# Copyright (c) 2004 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.
+
+# Empty out the command buffer and build up the command line in $cmd.
+while ! queue_is_empty cmdbuf; do
+ pop_queue cmdbuf arg
+ $debug_log $wrapperlog " (cmd-sink) pop: $arg"
+ . $buildcmd
+done
diff --git a/mk/wrapper/cmd-sink-aix-xlc b/mk/wrapper/cmd-sink-aix-xlc
new file mode 100644
index 00000000000..4ffd919b82e
--- /dev/null
+++ b/mk/wrapper/cmd-sink-aix-xlc
@@ -0,0 +1,74 @@
+# $NetBSD: cmd-sink-aix-xlc,v 1.1 2004/09/21 15:01:41 jlam Exp $
+#
+# Copyright (c) 2004 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.
+
+# Empty out the command buffer and build up the command line in $cmd.
+blibpath=
+while ! queue_is_empty cmdbuf; do
+ pop_queue cmdbuf arg
+ $debug_log $wrapperlog " (cmd-sink-aix-xlc) pop: $arg"
+ case $arg in
+ ##############################################################
+ # AIX xlC doesn't support -Wl,-rpath,* but accumulate them
+ # into a path collection we can later append to comand line
+ # using -blibpath.
+ ##############################################################
+ -R*|-Wl,-R*|-Wl,-rpath,*|-Wl,-rpath-link,*|-Wl,--rpath,*)
+ case $arg in
+ -R*) R="-R" ;;
+ -Wl,-R*) R="-Wl,-R" ;;
+ -Wl,-rpath,*) R="-Wl,-rpath," ;;
+ -Wl,-rpath-link,*) R="-Wl,-rpath-link," ;;
+ -Wl,--rpath,*) R="-Wl,--rpath," ;;
+ esac
+ dir="${arg#$R}"
+ case $blibpath in
+ "") blibpath="$dir" ;;
+ *) blibpath="$blibpath:$dir" ;;
+ esac
+ $debug_log " (cmd-sink-aix-xlc) drop: $dir [adding to blibpath]"
+ ;;
+ *)
+ . $buildcmd
+ ;;
+ esac
+done
+
+# AIX xlc uses -blibpath to set the runtime library search path.
+if $test -n "$blibpath"; then
+ arg="-blibpath:$blibpath"
+ $debug_log " (cmd-sink-aix-xlc) pop: $arg"
+ . $buildcmd
+fi
diff --git a/mk/wrapper/cmd-sink-interix-gcc b/mk/wrapper/cmd-sink-interix-gcc
new file mode 100644
index 00000000000..b5adf1c8c24
--- /dev/null
+++ b/mk/wrapper/cmd-sink-interix-gcc
@@ -0,0 +1,50 @@
+# $NetBSD: cmd-sink-interix-gcc,v 1.1 2004/09/21 15:01:41 jlam Exp $
+#
+# Copyright (c) 2004 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.
+
+# Empty out the command buffer and build up the command line in $cmd.
+while ! queue_is_empty cmdbuf; do
+ pop_queue cmdbuf arg
+ $debug_log $wrapperlog " (cmd-sink) pop: $arg"
+ case $arg in
+ -fpic|-fPIC)
+ $echo "$0: Interix GNU cc doesn't support \`$arg'." 1>&2
+ exit 1
+ ;;
+ *)
+ . $buildcmd
+ ;;
+ esac
+done
diff --git a/mk/wrapper/cmd-sink-interix-ld b/mk/wrapper/cmd-sink-interix-ld
new file mode 100644
index 00000000000..bb16e9c40a0
--- /dev/null
+++ b/mk/wrapper/cmd-sink-interix-ld
@@ -0,0 +1,50 @@
+# $NetBSD: cmd-sink-interix-ld,v 1.1 2004/09/21 15:01:41 jlam Exp $
+#
+# Copyright (c) 2004 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.
+
+# Empty out the command buffer and build up the command line in $cmd.
+while ! queue_is_empty cmdbuf; do
+ pop_queue cmdbuf arg
+ $debug_log $wrapperlog " (cmd-sink) pop: $arg"
+ case $arg in
+ -shared|-Bshareable)
+ $echo "$0: Interix GNU ld doesn't support \`$arg'." 1>&2
+ exit 1
+ ;;
+ *)
+ . $buildcmd
+ ;;
+ esac
+done
diff --git a/mk/wrapper/cmd-sink-ld b/mk/wrapper/cmd-sink-ld
new file mode 100644
index 00000000000..1c62c6044e1
--- /dev/null
+++ b/mk/wrapper/cmd-sink-ld
@@ -0,0 +1,67 @@
+# $NetBSD: cmd-sink-ld,v 1.1 2004/09/21 15:01:41 jlam Exp $
+#
+# Copyright (c) 2004 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.
+
+# Empty out the command buffer and build up the command line in $cmd.
+while ! queue_is_empty cmdbuf; do
+ pop_queue cmdbuf arg
+ $debug_log $wrapperlog " (cmd-sink-ld) pop: $arg"
+ case $arg in
+ ############################################################
+ # Strip the "-Wl," from arguments that start with that prefix
+ # and add the result to the "ld" cache. This makes "ld"
+ # silently accept "-Wl,*" arguments, which are often a part
+ # of the LDFLAGS setting in pkgsrc, and allows such LDFLAGS
+ # to be shared between the compiler and the linker.
+ ############################################################
+ -Wl,*)
+ list="${arg#-Wl,}"
+ save_IFS="${IFS}"; IFS=","
+ revlist=
+ for opt in $list; do
+ shquote "$opt"; opt="$shquoted"
+ revlist="$opt $revlist"
+ done
+ IFS="${save_IFS}"
+ for opt in $revlist; do
+ $debug_log $wrapperlog " (cmd-sink-ld) pre: $opt"
+ prepend_queue cmdbuf "$opt"
+ done
+ ;;
+ *)
+ . $buildcmd
+ ;;
+ esac
+done
diff --git a/mk/wrapper/cmd-sink-unixware-gcc b/mk/wrapper/cmd-sink-unixware-gcc
new file mode 100644
index 00000000000..9e96dbf6278
--- /dev/null
+++ b/mk/wrapper/cmd-sink-unixware-gcc
@@ -0,0 +1,72 @@
+# $NetBSD: cmd-sink-unixware-gcc,v 1.1 2004/09/21 15:01:41 jlam Exp $
+#
+# Copyright (c) 2004 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.
+
+# Empty out the command buffer and build up the command line in $cmd.
+ldrunpath=
+while ! queue_is_empty cmdbuf; do
+ pop_queue cmdbuf arg
+ $debug_log $wrapperlog " (cmd-sink-unixware-gcc) pop: $arg"
+ case $arg in
+ ##############################################################
+ # UnixWare's GCC doesn't support -Wl,-rpath,* but accumulate
+ # them into LD_RUN_PATH to set in the environment.
+ ##############################################################
+ -R*|-Wl,-R*|-Wl,-rpath,*|-Wl,-rpath-link,*|-Wl,--rpath,*)
+ case $arg in
+ -R*) R="-R" ;;
+ -Wl,-R*) R="-Wl,-R" ;;
+ -Wl,-rpath,*) R="-Wl,-rpath," ;;
+ -Wl,-rpath-link,*) R="-Wl,-rpath-link," ;;
+ -Wl,--rpath,*) R="-Wl,--rpath," ;;
+ esac
+ dir="${arg#$R}"
+ case $ldrunpath in
+ "") ldrunpath="$dir" ;;
+ *) ldrunpath="$ldrunpath:$dir" ;;
+ esac
+ $debug_log $wrapperlog " (cmd-sink-unixware-gcc) drop: $dir [adding to LD_RUN_PATH]"
+ arg=
+ ;;
+ *)
+ . $buildcmd
+ ;;
+ esac
+done
+
+if $test -n "$ldrunpath"; then
+ $debug_log $wrapperlog " (cmd-sink-unixware-gcc) LD_RUN_PATH=\"$ldrunpath\""
+ LD_RUN_PATH="$ldrunpath"; export LD_RUN_PATH
+fi
diff --git a/mk/wrapper/gen-reorder.sh b/mk/wrapper/gen-reorder.sh
new file mode 100644
index 00000000000..4b2fe2bee84
--- /dev/null
+++ b/mk/wrapper/gen-reorder.sh
@@ -0,0 +1,142 @@
+#! @WRAPPER_SHELL@
+#
+# $NetBSD: gen-reorder.sh,v 1.1 2004/09/21 15:01:41 jlam Exp $
+#
+# Copyright (c) 2004 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.
+
+shell_lib="@_WRAP_SHELL_LIB@"
+wrapperlog="${WRAPPER_LOG-@_WRAP_LOG@}"
+debug="${WRAPPER_DEBUG-no}"
+
+cat="@CAT@"
+
+. $shell_lib
+
+case $debug in
+yes) debug_log="msg_log" ;;
+*) debug_log=":" ;;
+esac
+
+######################################################################
+# gen reorder:l:foo:bar
+# Outputs a branch of a shell case statement that reorders
+# libs to ensure that "-lfoo" occurs before "-lbar".
+######################################################################
+gen() {
+ save_IFS="${IFS}"; IFS=":"
+ set -- $1
+ IFS="${save_IFS}"
+ _cmd="$1"; shift
+ case $_cmd in
+ reorder)
+ $debug_log $wrapperlog " (gen-reorder) $_cmd: $@"
+ case $1 in
+ l)
+ $cat << EOF
+ # -l$2 comes before -l$3
+ -l$2)
+ case "\${_libs}" in
+ -l$3|-l$3" "*)
+ _libs="\$l \${_libs}"
+ ;;
+ *" "-l$3)
+ _libs="\${_libs%%-l$3}\$l -l$3"
+ ;;
+ *" "-l$3" "*)
+ _libs="\${_libs%% -l$3 *} \$l -l$3 \${_libs#* -l$3 }"
+ ;;
+ *)
+ _libs="\${_libs} \$l"
+ ;;
+ esac
+ ;;
+EOF
+ ;;
+ esac
+ ;;
+ *)
+ $debug_log $wrapperlog " (gen-reorder) $_cmd: $@ [unknown]"
+ ;;
+ esac
+}
+
+######################################################################
+# Header for reorder script
+######################################################################
+$cat << 'EOF'
+msg_log $wrapperlog "==> Reordering libraries: $libs"
+prevlibs=
+while $test "$libs" != "$prevlibs"; do
+ _libs=
+ for l in $libs; do
+ case $l in
+EOF
+
+######################################################################
+# Generate body for reorder script.
+######################################################################
+for arg do
+ gen "$arg"
+done
+
+######################################################################
+# Footer for reorder script
+######################################################################
+$cat << 'EOF'
+ *)
+ _libs="${_libs} $l"
+ ;;
+ esac
+ _libs="${_libs# }"
+ _libs="${_libs% }"
+ done
+ prevlibs="$libs"
+ libs="${_libs}"
+done
+
+# This section suppresses duplicate libraries in sequence.
+_libs=
+for l in $libs; do
+ case "${_libs}" in
+ $l|*" "$l) ;;
+ *) _libs="${_libs} $l" ;;
+ esac
+done
+_libs="${_libs# }"
+_libs="${_libs% }"
+libs="${_libs}"
+EOF
+
+exit 0
diff --git a/mk/wrapper/gen-transform.sh b/mk/wrapper/gen-transform.sh
new file mode 100644
index 00000000000..ceb9b25e213
--- /dev/null
+++ b/mk/wrapper/gen-transform.sh
@@ -0,0 +1,466 @@
+#! @WRAPPER_SHELL@
+#
+# $NetBSD: gen-transform.sh,v 1.1 2004/09/21 15:01:41 jlam Exp $
+#
+# Copyright (c) 2004 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.
+
+shell_lib="@_WRAP_SHELL_LIB@"
+wrapperlog="${WRAPPER_LOG-@_WRAP_LOG@}"
+debug="${WRAPPER_DEBUG-no}"
+
+cat="@CAT@"
+test="@TEST@"
+
+. $shell_lib
+
+case $debug in
+yes) debug_log="msg_log" ;;
+*) debug_log=":" ;;
+esac
+
+rpath_options="-Wl,--rpath, -Wl,-rpath-link, -Wl,-rpath, -Wl,-R -R"
+
+######################################################################
+# gen action arg
+# Outputs sed commands that correspond to $action for $arg.
+######################################################################
+gen()
+{
+ _sep=" \`\"':;,"
+ _ws_sep=" "
+
+ _action=$1; shift
+ save_IFS="${IFS}"; IFS=":"
+ set -- $1
+ IFS="${save_IFS}"
+ _cmd="$1"; shift
+
+ case $_cmd in
+ ###############################################################
+ # depot:src:dst
+ # Change "src/<dir>/*" into "dst/*", and the same in -I and
+ # -L options.
+ ###############################################################
+ depot)
+ case $_action in
+ transform|untransform)
+ gen $_action "opt-depot:$1:$2"
+ gen $_action "opt-depot:-I$1:-I$2"
+ gen $_action "opt-depot:-L$1:-L$2"
+ ;;
+ esac
+ ;;
+ ###############################################################
+ # I:src:dst
+ # Change "src" into "dst" and "src/*" into "dst/*" in -I
+ # options for transform, and back for untransform.
+ ###############################################################
+ I)
+ case $_action in
+ transform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@"
+ gen $_action "opt:-I$1:-I$2"
+ gen $_action "opt-sub:-I$1:-I$2"
+ ;;
+ untransform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@"
+ gen $_action "opt:-I$2:-I$1"
+ gen $_action "opt-sub:-I$2:-I$1"
+ ;;
+ esac
+ ;;
+ ###############################################################
+ # L:src:dst
+ # Change "src" into "dst" and "src/*" into "dst/*" in -L
+ # options for transform, and back for untransform.
+ ###############################################################
+ L)
+ case $_action in
+ transform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@"
+ gen $_action "opt:-L$1:-L$2"
+ gen $_action "opt-sub:-L$1:-L$2"
+ ;;
+ untransform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@"
+ gen $_action "opt:-L$2:-L$1"
+ gen $_action "opt-sub:-L$2:-L$1"
+ ;;
+ esac
+ ;;
+ ###############################################################
+ # l:foo:bar[:baz1...]
+ # Change "-lfoo" into "-lbar [-lbaz...]"
+ ###############################################################
+ l)
+ case $_action in
+ transform|untransform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@"
+ tolibs=
+ fromlib="-l$1"; shift
+ while $test $# -gt 0; do
+ case $1 in
+ "") ;;
+ *) case $tolibs in
+ "") tolibs="-l$1" ;;
+ *) tolibs="$tolibs -l$1" ;;
+ esac
+ ;;
+ esac
+ shift
+ done
+ gen $_action "opt:$fromlib:$tolibs"
+ ;;
+ esac
+ ;;
+ ##############################################################
+ # libpath:src:dst
+ # Change "src/*/libfoo.{a,la}" into "dst/*/libfoo.{a,la}".
+ ##############################################################
+ libpath)
+ case $_action in
+ transform|untransform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@"
+ $cat << EOF
+s|\([$_sep]\)$1\(/[^$_sep]*\.la[$_sep]\)|\1$2\2|g
+s|\([$_sep]\)$1\(/[^$_sep]*\.la[$_sep]\)|\1$2\2|g
+s|\([$_sep]\)$1\(/[^$_sep]*\.la\)$|\1$2\2|g
+s|^$1\(/[^$_sep]*\.la[$_sep]\)|$2\1|g
+s|^$1\(/[^$_sep]*\.la\)$|$2\1|g
+EOF
+ ;;
+ esac
+ ;;
+ ##############################################################
+ # mangle:src:dst
+ # Change "src" into "dst" and "src/*" into "dst/*", and the
+ # same in -I, -L, and rpath options.
+ ##############################################################
+ mangle)
+ case $_action in
+ transform|untransform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@"
+ #gen $_action "opt:$1:$2"
+ gen $_action "opt:-I$1:-I$2"
+ gen $_action "opt:-L$1:-L$2"
+ gen $_action "rpath-exact:$1:$2"
+ gen $_action "sub-mangle:$1:$2"
+ ;;
+ esac
+ ;;
+ ##############################################################
+ # no-abspath
+ # Remove all "dash" options that contain an absolute path.
+ ##############################################################
+ no-abspath)
+ case $_action in
+ transform|untransform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd"
+ gen $_action "rm-optarg:-I/"
+ gen $_action "rm-optarg:-L/"
+ for _R in $rpath_options; do
+ gen $_action "rm-optarg:$_R/"
+ done
+ ;;
+ esac
+ ;;
+ ##############################################################
+ # no-rpath
+ # Removes rpath options.
+ ##############################################################
+ no-rpath)
+ case "$_action" in
+ transform|untransform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd"
+ gen $_action rm-optarg:-Wl,--rpath,
+ gen $_action rm-optarg:-Wl,-rpath-link,
+ gen $_action rm-optarg:-Wl,-rpath,
+ gen $_action rm-optarg:-Wl,-R
+ gen $_action rm-optarg:-R
+ ;;
+ esac
+ ;;
+ ##############################################################
+ # opt:src:dst
+ # Change "src" into "dst", where "src" matches the whole
+ # option.
+ ##############################################################
+ opt)
+ case $_action in
+ transform|untransform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@"
+ $cat << EOF
+s|\([$_sep]\)$1\([$_sep]\)|\1$2\2|g
+s|\([$_sep]\)$1\([$_sep]\)|\1$2\2|g
+s|\([$_sep]\)$1$|\1$2|g
+s|^$1\([$_sep]\)|$2\1|g
+s|^$1$|$2|g
+EOF
+ ;;
+ esac
+ ;;
+ ###############################################################
+ # opt-depot:src:dst
+ # Change "src/<dir>/*" into "dst/*".
+ ###############################################################
+ opt-depot)
+ case $_action in
+ transform|untransform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@"
+ $cat << EOF
+s|\([$_sep]\)$1/[^/$_sep]*\(/[^$_sep]*[$_sep]\)|\1$2\2|g
+s|\([$_sep]\)$1/[^/$_sep]*\(/[^$_sep]*[$_sep]\)|\1$2\2|g
+s|\([$_sep]\)$1/[^/$_sep]*\(/[^$_sep]*\)$|\1$2\2|g
+s|^$1/[^/$_sep]*\(/[^$_sep]*[$_sep]\)|$2\1|g
+s|^$1/[^/$_sep]*\(/[^$_sep]*\)$|$2\1|g
+EOF
+ ;;
+ esac
+ ;;
+ ##############################################################
+ # opt-sub:src:dst
+ # Change "src/*" into "dst/*".
+ ##############################################################
+ opt-sub)
+ case $_action in
+ transform|untransform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@"
+ gen $_action "opt-sub-trailer:$1::$2:"
+ ;;
+ esac
+ ;;
+ ##############################################################
+ # opt-sub-trailer:src:src_trailer:dst:dst_trailer
+ # Change "src/*src_trailer" into "dst/*dst_trailer",
+ # where "src/*" matches "src" plus subdirectories.
+ ##############################################################
+ opt-sub-trailer)
+ case $_action in
+ transform|untransform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@"
+ $cat << EOF
+s|\([$_sep]\)$1\(/[^$_sep]*\)$2\([$_sep]\)|\1$3\2$4\3|g
+s|\([$_sep]\)$1\(/[^$_sep]*\)$2\([$_sep]\)|\1$3\2$4\3|g
+s|\([$_sep]\)$1\(/[^$_sep]*\)$2$|\1$3\2$4|g
+s|^$1\(/[^$_sep]*\)$2\([$_sep]\)|$3\1$4|g
+s|^$1\(/[^$_sep]*\)$2$|$3\1$4|g
+EOF
+ ;;
+ esac
+ ;;
+ ##############################################################
+ # P:src:dst
+ # Change "src/*/libfoo.{a,la}" into "dst/*/libfoo.{a,la}"
+ # for transform, and back for untransform.
+ ##############################################################
+ P)
+ case $_action in
+ transform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@"
+ gen $_action "libpath:$1:$2"
+ ;;
+ untransform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@"
+ gen $_action "libpath:$2:$1"
+ ;;
+ esac
+ ;;
+ ##############################################################
+ # rename:src:dst
+ # Synonym for "opt:src:dst".
+ ##############################################################
+ rename)
+ case $_action in
+ transform|untransform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@"
+ gen $_action "opt:$1:$2"
+ ;;
+ esac
+ ;;
+ ##############################################################
+ # rm:opt
+ # Remove "opt", where "opt" matches the entire option.
+ ##############################################################
+ rm)
+ case $_action in
+ transform|untransform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@"
+ gen $_action "opt:$1:"
+ esac
+ ;;
+ ##############################################################
+ # rm-optarg:opt
+ # Remove "opt" and any argument of that option where the
+ # two are combined in one word.
+ ##############################################################
+ rm-optarg)
+ case $_action in
+ transform|untransform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@"
+ $cat << EOF
+s|\([$_sep]\)$1[^$_sep]*\([$_sep]\)|\1\2|g
+s|\([$_sep]\)$1[^$_sep]*\([$_sep]\)|\1\2|g
+s|\([$_sep]\)$1[^$_sep]*$|\1|g
+s|^$1[^$_sep]*\([$_sep]\)|\1|g
+s|^$1[^$_sep]*$||g
+EOF
+ ;;
+ esac
+ ;;
+ ##############################################################
+ # rmdir:dir
+ # Remove all "dash" options that contain "dir" or "dir/*".
+ ##############################################################
+ rmdir)
+ case $_action in
+ transform|untransform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@"
+ gen $_action "opt:-I$1:"
+ gen $_action "opt-sub:-I$1:"
+ gen $_action "opt:-L$1:"
+ gen $_action "opt-sub:-L$1:"
+ for _R in $rpath_options; do
+ gen $_action "opt:$_R$1:"
+ gen $_action "opt-sub:$_R$1:"
+ done
+ ;;
+ esac
+ ;;
+ ##############################################################
+ # rpath:src:dst
+ # Change "src" into "dst" and "src/*" into "dst/*" in rpath
+ # options.
+ ##############################################################
+ rpath)
+ case $_action in
+ transform|untransform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@"
+ gen $_action "rpath-exact:$1:$2"
+ gen $_action "sub-rpath:$1:$2"
+ ;;
+ esac
+ ;;
+ ##############################################################
+ # rpath-exact:src:dst
+ # Change "src" into "dst" in rpath options.
+ ##############################################################
+ rpath-exact)
+ case $_action in
+ transform|untransform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@"
+ for _R in $rpath_options; do
+ gen $_action "opt:$_R$1:$_R$2"
+ done
+ ;;
+ esac
+ ;;
+ ##############################################################
+ # strip-slashdot:dir
+ # Change "dir/." into "dir" and the same in -I, -L, and
+ # rpath options.
+ ##############################################################
+ strip-slashdot)
+ case $_action in
+ transform|untransform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@"
+ gen $_action "opt-sub-trailer:$1:/\.:$1:"
+ gen $_action "opt-sub-trailer:-I$1:/\.:-I$1:"
+ gen $_action "opt-sub-trailer:-L$1:/\.:-L$1:"
+ for _R in $rpath_options; do
+ gen $_action "opt-sub-trailer:$_R$1:/\.:$_R$1:"
+ done
+ ;;
+ esac
+ ;;
+ ##############################################################
+ # sub-mangle:src:dst
+ # Change "src/*" into "dst/*", and the same in -I, -L, and
+ # rpath options.
+ ##############################################################
+ sub-mangle)
+ case $_action in
+ transform|untransform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@"
+ #gen $_action "opt-sub:$1:$2"
+ gen $_action "opt-sub:-I$1:-I$2"
+ gen $_action "opt-sub:-L$1:-L$2"
+ gen $_action "sub-rpath:$1:$2"
+ ;;
+ esac
+ ;;
+ ##############################################################
+ # sub-rpath:src:dst
+ # Change "src/*" into "dst/*" in rpath options.
+ ##############################################################
+ sub-rpath)
+ case $_action in
+ transform|untransform)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@"
+ for _R in $rpath_options; do
+ gen $_action "opt-sub:$_R$1:$_R$2"
+ done
+ ;;
+ esac
+ ;;
+ ##############################################################
+ # Everything else is ignored.
+ ##############################################################
+ *)
+ $debug_log $wrapperlog " (gen-transform) $_cmd: $@ [unknown]"
+ ;;
+ esac
+}
+
+######################################################################
+# Generate sed script.
+######################################################################
+action="$1"; shift
+for arg do
+ case $arg in
+ transform:*)
+ case $action in
+ transform) gen $action "${arg#transform:}" ;;
+ esac
+ ;;
+ untransform:*)
+ case $action in
+ untransform) gen $action "${arg#untransform:}" ;;
+ esac
+ ;;
+ *)
+ gen $action "$arg"
+ ;;
+ esac
+done
diff --git a/mk/wrapper/logic b/mk/wrapper/logic
new file mode 100644
index 00000000000..11818488e3c
--- /dev/null
+++ b/mk/wrapper/logic
@@ -0,0 +1,270 @@
+# $NetBSD: logic,v 1.1 2004/09/21 15:01:41 jlam Exp $
+#
+# Copyright (c) 2004 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.
+
+# Empty out the argument buffer and fill up the command buffer.
+skipargs=0
+while ! queue_is_empty argbuf; do
+ #
+ # Grab the next argument from the head of the argument buffer
+ # and return it in $arg.
+ #
+ argok=no
+ while $test "$argok" = "no"; do
+ pop_queue argbuf arg
+ $debug_log $wrapperlog " (logic) pop: $arg"
+ #
+ # Toggle whether we want to transform $arg or if we
+ # want to pass it unmodified into the command buffer.
+ #
+ if $test $skipargs -eq 0; then
+ do_transform=yes
+ else
+ skipargs=`$expr $skipargs - 1`
+ do_transform=no
+ argok=yes
+ continue
+ fi
+
+ case $arg in
+ ######################################################
+ # Split direct paths to shared libraries into the
+ # "-Ldir -llib" equivalent
+ ######################################################
+ /*/lib*.so|/*/lib*.so.[0-9]*)
+ dir="${arg%/lib*}"
+ lib="${arg#$dir/lib}"
+ case $lib in
+ */*) argok=yes; continue ;;
+ *.so) lib="${lib%.so}" ;;
+ *.so.[0-9]*) lib="${lib%.so.[0-9]*}" ;;
+ esac
+ prepend_queue argbuf "-l$lib"
+ $debug_log $wrapperlog " (logic) pre: -l$lib"
+ prepend_queue argbuf "-L$dir"
+ $debug_log $wrapperlog " (logic) pre: -L$dir"
+ ;;
+ /*/lib*.dylib) # Darwin
+ dir="${arg%/lib*.dylib}"
+ lib="${arg#$dir/lib}"
+ case $lib in
+ */*) argok=yes; continue ;;
+ *.[0-9]*.dylib) lib="${lib%%.[0-9]*.dylib}" ;;
+ *.dylib) lib="${lib%.dylib}" ;;
+ esac
+ prepend_queue argbuf "-l$lib"
+ $debug_log $wrapperlog " (logic) pre: -l$lib"
+ prepend_queue argbuf "-L$dir"
+ $debug_log $wrapperlog " (logic) pre: -L$dir"
+ ;;
+ ######################################################
+ # Merge "-Wl,-R -Wl,/dir" into a single "-Wl,-R/dir".
+ # Same for -Wl,-L, -Wl,-rpath and -Wl,-rpath-link.
+ ######################################################
+ -Wl,-[LR])
+ if queue_is_empty argbuf; then
+ argok=yes
+ continue
+ fi
+ pop_queue argbuf nextarg
+ $debug_log $wrapperlog " (logic) pop: $nextarg"
+ shquote "${nextarg#-Wl,}"; nextarg="$shquoted"
+ $debug_log $wrapperlog " (logic) pre: $arg$nextarg"
+ prepend_queue argbuf "$arg$nextarg"
+ ;;
+ -Wl,-rpath|-Wl,-rpath-link|-Wl,--rpath)
+ if queue_is_empty argbuf; then
+ argok=yes
+ continue
+ fi
+ pop_queue argbuf nextarg
+ $debug_log $wrapperlog " (logic) pop: $nextarg"
+ shquote "${nextarg#-Wl,}"; nextarg="$shquoted"
+ $debug_log $wrapperlog " (logic) pre: $arg,$nextarg"
+ prepend_queue argbuf "$arg,$nextarg"
+ ;;
+ ######################################################
+ # Remove rpath options that try to add relative paths
+ # to the runtime library search path. This basically
+ # cleans up after lazy programmers who can't write
+ # Makefiles.
+ ######################################################
+ -R[!/]*|-Wl,-R[!/]*|\
+ -Wl,-rpath,[!/]*|-Wl,-rpath-link,[!/]*|-Wl,--rpath,[!/]*)
+ $debug_log $wrapperlog " (logic) drop: $arg"
+ ;;
+ ######################################################
+ # Remove consecutive, repeated library options.
+ ######################################################
+ -l*)
+ if queue_is_empty argbuf; then
+ argok=yes
+ continue
+ fi
+ head_queue argbuf nextarg
+ while $test "$nextarg" = "$arg"; do
+ pop_queue argbuf nextarg
+ $debug_log $wrapperlog " (logic) drop: $nextarg"
+ if queue_is_empty argbuf; then
+ break
+ else
+ head_queue argbuf nextarg
+ fi
+ done
+ argok=yes
+ ;;
+ ######################################################
+ # The -o option takes an extra argument that should
+ # be passed unmodified.
+ #######################################################
+ -o)
+ skipargs=1
+ argok=yes
+ ;;
+ ######################################################
+ # GNU ld uses "--dynamic-linker /path/to/shared/object"
+ # to set the dynamic linker code for ELF executables.
+ ######################################################
+ --dynamic-linker)
+ skipargs=1
+ argok=yes
+ ;;
+ ######################################################
+ # Darwin's linker uses:
+ #
+ # -dylib_file /path/shlib:/path2/shlib
+ # -dylib_install_name /path/shlib
+ # -install_name /path/shlib
+ #
+ # to pass the installed locations for the shared
+ # libraries to the linker, and we need to pass the extra
+ # argument unmodified. The purpose of
+ # -seg_addr_table_filename is more obscure, but Darwin's
+ # imake rules use it.
+ ######################################################
+ -dylib_file|-dylib_install_name|-install_name|\
+ -seg_addr_table_filename)
+ skipargs=1
+ argok=yes
+ ;;
+ ######################################################
+ # Leave all else untouched.
+ ######################################################
+ *)
+ argok=yes
+ esac
+ done
+
+ # Try to look up the transformed $arg in the cache, but if
+ # not there, then apply the transformations and save the result
+ # in the cache.
+ #
+ case $do_transform in
+ yes)
+ . $cache
+ case $cachehit in
+ yes)
+ # The cache was hit and $arg is set.
+ $debug_log $wrapperlog " (logic) to: $arg [cached]"
+ ;;
+ *)
+ # Apply transformations to $arg.
+ addtocache=no
+ case $skip_transform in
+ yes)
+ $debug_log $wrapperlog " (logic) to: $arg [untransformed]"
+ ;;
+ *)
+ shquote "$arg"; cachearg="$shquoted"
+ case $arg in
+ -*|/*)
+ arg=`$echo "X$arg" | $Xsed @_WRAP_TRANSFORM_SED@`
+ $debug_log $wrapperlog " (logic) to: $arg"
+ addtocache=yes
+ ;;
+ *)
+ $debug_log $wrapperlog " (logic) to: $arg [untransformed]"
+ ;;
+ esac
+
+ # Apply wrapper-specific transformations
+ # to $arg.
+ #
+ . $transform
+ ;;
+ esac
+
+ # Re-create the cache file if we're adding to it.
+ case $updatecache,$addtocache in
+ yes,yes)
+ shquote "$arg"; cachedarg="$shquoted"
+ $cat >> $cache_body << EOF
+$cachearg) arg=$cachedarg; cachehit=yes ;;
+EOF
+ $cat $cache_header \
+ $cache_body \
+ $cache_footer > $cache
+ ;;
+ esac
+ ;;
+ esac
+ case $arg in
+ ######################################################
+ # Split -l options along whitespace. This disallows
+ # library names with whitespace, but it allows us to
+ # handle transformations that look like, e.g.
+ # "-lreadline" -> "-ledit -ltermcap".
+ ######################################################
+ -l*)
+ for lib in $arg; do
+ append_queue cmdbuf "$lib"
+ $debug_log $wrapperlog " (logic) push: $lib"
+ done
+ ;;
+ ######################################################
+ # Everything is goes into the command buffer unchanged.
+ ######################################################
+ *)
+ append_queue cmdbuf "$arg"
+ $debug_log $wrapperlog " (logic) push: $arg"
+ ;;
+ esac
+ ;;
+ *)
+ append_queue cmdbuf "$arg"
+ $debug_log $wrapperlog " (logic) push: $arg"
+ ;;
+ esac
+done
diff --git a/mk/wrapper/transform-mipspro-cc b/mk/wrapper/transform-mipspro-cc
new file mode 100644
index 00000000000..f2e553dd9bd
--- /dev/null
+++ b/mk/wrapper/transform-mipspro-cc
@@ -0,0 +1,78 @@
+# $NetBSD: transform-mipspro-cc,v 1.1 2004/09/21 15:01:41 jlam Exp $
+#
+# Copyright (c) 2004 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.
+
+case $arg in
+######################################################################
+# MIPSpro can handle -O[123] and -Ofast[=platform], so just pass them
+# on through.
+######################################################################
+-O[123]|-Ofast|-Ofast=*)
+ addtocache=yes
+ ;;
+######################################################################
+# Ignore all other -O* options.
+######################################################################
+-O*)
+ arg=
+ msg_log $wrapperlog " (transform-mipspro-cc) to: $arg"
+ addtocache=yes
+ ;;
+######################################################################
+# Directories for the runtime library search path are passed via
+# "-Wl,-rpath,<dir>", not "-Wl,-R<dir>".
+######################################################################
+-Wl,-R*)
+ arg="-Wl,-rpath,${arg#-Wl,-R}"
+ msg_log $wrapperlog " (transform-mipspro-cc) to: $arg"
+ addtocache=yes
+ ;;
+######################################################################
+# The MIPSpro compiler accepts these -W* directives, so just pass them
+# on through.
+######################################################################
+-W[ablfpR]*,*)
+ addtocache=yes
+ ;;
+######################################################################
+# Ignore all of the other -W* directives, which are likely to be
+# GCCisms.
+######################################################################
+-W*)
+ arg=
+ msg_log $wrapperlog " (transform-mipspro-cc) to: $arg"
+ addtocache=yes
+ ;;
+esac
diff --git a/mk/wrapper/transform-mipspro-ucode-cc b/mk/wrapper/transform-mipspro-ucode-cc
new file mode 100644
index 00000000000..4243eb7d1ad
--- /dev/null
+++ b/mk/wrapper/transform-mipspro-ucode-cc
@@ -0,0 +1,84 @@
+# $NetBSD: transform-mipspro-ucode-cc,v 1.1 2004/09/21 15:01:41 jlam Exp $
+#
+# Copyright (c) 2004 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.
+
+case $arg in
+######################################################################
+# MIPSpro can handle -O[0123] so just pass them on through.
+######################################################################
+-O[0123])
+ addtocache=yes
+ ;;
+######################################################################
+# Ignore all other -O* options.
+######################################################################
+-O*)
+ arg=
+ msg_log $wrapperlog " (transform-mipspro-ucode-cc) to: $arg"
+ addtocache=yes
+ ;;
+######################################################################
+# Directories for the runtime library search path are passed via
+# "-Wl,-rpath,<dir>", not "-Wl,-R<dir>".
+######################################################################
+-Wl,-R*)
+ arg="-Wl,-rpath,${arg#-Wl,-R}"
+ msg_log $wrapperlog " (transform-mipspro-ucode-cc) to: $arg"
+ addtocache=yes
+ ;;
+######################################################################
+# The MIPSpro compiler accepts -Wl,* so just pass it on through.
+######################################################################
+-Wl,*)
+ addtocache=yes
+ ;;
+######################################################################
+# Ignore all of the other -W* directives, which are likely to be
+# GCCisms.
+######################################################################
+-W*)
+ arg=
+ msg_log $wrapperlog " (transform-mipspro-ucode-cc) to: $arg"
+ addtocache=yes
+ ;;
+######################################################################
+# The MIPSpro compiler uses -KPIC to create position independent code.
+######################################################################
+-f[Pp][Ii][Cc])
+ arg="-KPIC"
+ msg_log $wrapperlog " (transform-mipspro-ucode-cc) to: $arg"
+ addtocache=yes
+ ;;
+esac
diff --git a/mk/wrapper/transform-sunpro-cc b/mk/wrapper/transform-sunpro-cc
new file mode 100644
index 00000000000..5d15f6ad81a
--- /dev/null
+++ b/mk/wrapper/transform-sunpro-cc
@@ -0,0 +1,115 @@
+# $NetBSD: transform-sunpro-cc,v 1.1 2004/09/21 15:01:41 jlam Exp $
+#
+# Copyright (c) 2004 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.
+
+case $arg in
+######################################################################
+# SunPro can handle -xO<n> (n={1|2|3|4|5}), so optimistically convert
+# those GCC -O<n> values to -xO<n>.
+######################################################################
+-O[12345])
+ arg="-xO${arg#-O}"
+ msg_log $wrapperlog " (transform-sunpro-cc) to: $arg"
+ addtocache=yes
+ ;;
+######################################################################
+# Silently ignore all other -O* options, except for "-O", which SunPro
+# interprets as asking for the default optimization level.
+######################################################################
+-O?*)
+ arg=
+ msg_log $wrapperlog " (transform-sunpro-cc) to: $arg"
+ addtocache=yes
+ ;;
+######################################################################
+# Directories for the runtime library search path are passed via simply
+# "-R<dir>", not "-Wl,-R<dir>".
+######################################################################
+-Wl,-R*)
+ arg="${arg#-Wl,}"
+ msg_log $wrapperlog " (transform-sunpro-cc) to: $arg"
+ addtocache=yes
+ ;;
+######################################################################
+# SunPro compilers don't even understand any -W* arguments, so just
+# silently ignore them all.
+######################################################################
+-W*)
+ arg=
+ msg_log $wrapperlog " (transform-sunpro-cc) to: $arg"
+ addtocache=yes
+ ;;
+######################################################################
+# Solaris' linker uses -Bstatic to create static objects.
+######################################################################
+-static)
+ arg="-Bstatic"
+ msg_log $wrapperlog " (transform-sunpro-cc) to: $arg"
+ addtocache=yes
+ ;;
+######################################################################
+# Solaris' linker uses -G to create shared objects.
+######################################################################
+--export-dynamic|-shared)
+ arg="-G"
+ msg_log $wrapperlog " (transform-sunpro-cc) to: $arg"
+ addtocache=yes
+ ;;
+######################################################################
+# SunPro uses -Kpic to create position independent code.
+######################################################################
+-f[Pp][Ii][Cc])
+ arg="-Kpic"
+ msg_log $wrapperlog " (transform-sunpro-cc) to: $arg"
+ addtocache=yes
+ ;;
+######################################################################
+# SunPro doesn't understand -pthread, and only -lpthread is needed on
+# Solaris.
+######################################################################
+-pthread)
+ arg="-lpthread"
+ msg_log $wrapperlog " (transform-sunpro-cc) to: $arg"
+ addtocache=yes
+ ;;
+######################################################################
+# Ignore some flags that are unnecessary for SunPro.
+######################################################################
+-ansi|-fno-gnu-keywords|-fstrict-prototypes|-pedantic)
+ arg=
+ msg_log $wrapperlog " (transform-sunpro-cc) to: $arg"
+ addtocache=yes
+ ;;
+esac
diff --git a/mk/wrapper/wrapper.sh b/mk/wrapper/wrapper.sh
new file mode 100644
index 00000000000..d6d029d26f2
--- /dev/null
+++ b/mk/wrapper/wrapper.sh
@@ -0,0 +1,107 @@
+#! @WRAPPER_SHELL@
+#
+# $NetBSD: wrapper.sh,v 1.1 2004/09/21 15:01:41 jlam Exp $
+#
+# Copyright (c) 2004 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.
+
+arg_source="@_WRAP_ARG_SOURCE@"
+buildcmd="@_WRAP_BUILDCMD@"
+cache="@_WRAP_CACHE@"
+cache_header="@_WRAP_CACHE_HEADER@"
+cache_body="@_WRAP_CACHE_BODY@"
+cache_footer="@_WRAP_CACHE_FOOTER@"
+cleanup="@_WRAP_CLEANUP@"
+cmd_sink="@_WRAP_CMD_SINK@"
+logic="@_WRAP_LOGIC@"
+reorderlibs="@_WRAP_REORDERLIBS@"
+shell_lib="@_WRAP_SHELL_LIB@"
+scan="@_WRAP_SCAN@"
+transform="@_WRAP_TRANSFORM@"
+wrapperlog="${WRAPPER_LOG-@_WRAP_LOG@}"
+skip_transform="${WRAPPER_SKIP_TRANSFORM-@_WRAP_SKIP_TRANSFORM@}"
+debug="${WRAPPER_DEBUG-no}"
+
+cat="@CAT@"
+echo="@ECHO@"
+expr="@EXPR@"
+sed="@SED@"
+test="@TEST@"
+Xsed="$sed -e 1s/^X//"
+
+. $shell_lib
+
+updatecache=${WRAPPER_UPDATE_CACHE-yes}
+reorder=${WRAPPER_REORDER-no}
+
+case $debug in
+yes) debug_log="msg_log" ;;
+*) debug_log=":" ;;
+esac
+
+original_cmd="$0 $@"
+msg_log $wrapperlog "[*]" $original_cmd
+
+cmd="@WRAPPEE@"
+do_transform=yes
+init_queue argbuf
+init_queue cmdbuf
+
+. $scan
+
+set -- "$@" @_WRAP_EXTRA_ARGS@
+. $arg_source
+. $logic
+. $cmd_sink
+
+# Reorder the libraries so that the library dependencies are correct.
+case $reorder in
+yes)
+ if $test -n "$libs"; then
+ . $reorderlibs
+ fi
+ ;;
+esac
+
+cmd="$cmd $libs"
+
+@_WRAP_ENV@
+
+msg_log $wrapperlog "<.>" $cmd
+eval $cmd
+wrapper_result=$?
+
+. $cleanup
+
+exit ${wrapper_result}