summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorjlam <jlam>2003-10-03 19:39:19 +0000
committerjlam <jlam>2003-10-03 19:39:19 +0000
commit4128f3cce0cd7dc9459ddee74d443aaf908358b2 (patch)
tree41bbdd7c68171c46a86410bccc508d727ef552be /mk
parent779e4307cca4b5a33a555d7635cab6d8adb777d1 (diff)
downloadpkgsrc-4128f3cce0cd7dc9459ddee74d443aaf908358b2.tar.gz
Factor out some more commonly used bits of the wrapper system into
their own files: buildcmd and quotearg, which are used to build up the command line and to quote arguments. Also add the ability to skip processing the next few arguments and add them directly to the command line. Now, either the marshall script or the cache scripts can request skipping the N arguments by setting skipargs=N.
Diffstat (limited to 'mk')
-rw-r--r--mk/buildlink3/bsd.buildlink3.mk34
-rw-r--r--mk/buildlink3/buildcmd45
-rw-r--r--mk/buildlink3/libtool-do-install25
-rw-r--r--mk/buildlink3/libtool.sh49
-rw-r--r--mk/buildlink3/logic19
-rw-r--r--mk/buildlink3/quotearg20
-rw-r--r--mk/buildlink3/wrapper.sh35
7 files changed, 116 insertions, 111 deletions
diff --git a/mk/buildlink3/bsd.buildlink3.mk b/mk/buildlink3/bsd.buildlink3.mk
index ce2f87c6c9e..bf9a7b4d281 100644
--- a/mk/buildlink3/bsd.buildlink3.mk
+++ b/mk/buildlink3/bsd.buildlink3.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.buildlink3.mk,v 1.22 2003/09/30 10:17:30 jlam Exp $
+# $NetBSD: bsd.buildlink3.mk,v 1.23 2003/10/03 19:39:19 jlam Exp $
#
# An example package buildlink3.mk file:
#
@@ -841,6 +841,8 @@ _BLNK_SANITIZED_PATH!= ${ECHO} ${PATH} | ${SED} \
_BLNK_WRAP_SANITIZE_PATH= PATH="${_BLNK_SANITIZED_PATH}"
_BLNK_EMPTY_FILE?= ${BUILDLINK_DIR}/bin/.empty
_BLNK_WRAP_ENV?= ${BUILDLINK_WRAPPER_ENV}
+_BLNK_WRAP_BUILDCMD= ${BUILDLINK_DIR}/bin/.buildcmd
+_BLNK_WRAP_QUOTEARG= ${BUILDLINK_DIR}/bin/.quotearg
_BLNK_WRAP_MARSHALL= ${BUILDLINK_DIR}/bin/.marshall
_BLNK_WRAP_PRE_CACHE= ${BUILDLINK_DIR}/bin/.pre-cache
_BLNK_WRAP_CACHE_ADD= ${BUILDLINK_DIR}/bin/.cache-add
@@ -851,7 +853,6 @@ _BLNK_WRAP_POST_CACHE= ${BUILDLINK_DIR}/bin/.post-cache
_BLNK_WRAP_LOGIC= ${BUILDLINK_DIR}/bin/.logic
_BLNK_WRAP_LOGIC_TRANSFORM= ${BUILDLINK_DIR}/bin/.logic-trans
_BLNK_WRAP_LOG= ${WRKLOG}
-_BLNK_LIBTOOL_DO_INSTALL= ${BUILDLINK_DIR}/bin/.libtool-do-install
_BLNK_LIBTOOL_FIX_LA= ${BUILDLINK_DIR}/bin/.libtool-fix-la
_BLNK_FAKE_LA= ${BUILDLINK_DIR}/bin/.fake-la
_BLNK_GEN_TRANSFORM= ${BUILDLINK_DIR}/bin/.gen-transform
@@ -868,6 +869,8 @@ _BLNK_WRAP_SETENV.${_wrappee_}= ${_wrappee_}="${BUILDLINK_${_wrappee_}:T}"
_BLNK_WRAP_SANITIZE_PATH.${_wrappee_}= ${_BLNK_WRAP_SANITIZE_PATH}
_BLNK_WRAP_EXTRA_FLAGS.${_wrappee_}= # empty
_BLNK_WRAP_ENV.${_wrappee_}= ${_BLNK_WRAP_ENV}
+_BLNK_WRAP_BUILDCMD.${_wrappee_}= ${_BLNK_WRAP_BUILDCMD}
+_BLNK_WRAP_QUOTEARG.${_wrappee_}= ${_BLNK_WRAP_QUOTEARG}
_BLNK_WRAP_MARSHALL.${_wrappee_}= ${_BLNK_WRAP_MARSHALL}
_BLNK_WRAP_PRIVATE_PRE_CACHE.${_wrappee_}= ${_BLNK_EMPTY_FILE}
_BLNK_WRAP_PRIVATE_CACHE_ADD.${_wrappee_}= ${_BLNK_EMPTY_FILE}
@@ -974,7 +977,6 @@ _BLNK_WRAP_EXTRA_FLAGS.SHLIBTOOL= ${_BLNK_WRAP_EXTRA_FLAGS.LIBTOOL}
.PHONY: buildlink-wrappers
-buildlink-wrappers: ${_BLNK_LIBTOOL_DO_INSTALL}
buildlink-wrappers: ${_BLNK_LIBTOOL_FIX_LA}
.for _wrappee_ in ${_BLNK_WRAPPEES}
@@ -996,13 +998,15 @@ _BLNK_WRAPPER_TRANSFORM_SED.${_wrappee_}= \
-e "s|@WRKSRC@|${WRKSRC}|g" \
-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|@TOUCH@|${TOUCH:Q}|g" \
- -e "s|@_BLNK_LIBTOOL_DO_INSTALL@|${_BLNK_LIBTOOL_DO_INSTALL:Q}|g" \
-e "s|@_BLNK_LIBTOOL_FIX_LA@|${_BLNK_LIBTOOL_FIX_LA:Q}|g" \
-e "s|@_BLNK_WRAP_LOG@|${_BLNK_WRAP_LOG:Q}|g" \
-e "s|@_BLNK_WRAP_EXTRA_FLAGS@|${_BLNK_WRAP_EXTRA_FLAGS.${_wrappee_}:Q}|g" \
+ -e "s|@_BLNK_WRAP_BUILDCMD@|${_BLNK_WRAP_BUILDCMD.${_wrappee_}:Q}|g" \
+ -e "s|@_BLNK_WRAP_QUOTEARG@|${_BLNK_WRAP_QUOTEARG.${_wrappee_}:Q}|g" \
-e "s|@_BLNK_WRAP_MARSHALL@|${_BLNK_WRAP_MARSHALL.${_wrappee_}:Q}|g" \
-e "s|@_BLNK_WRAP_PRIVATE_PRE_CACHE@|${_BLNK_WRAP_PRIVATE_PRE_CACHE.${_wrappee_}:Q}|g" \
-e "s|@_BLNK_WRAP_PRIVATE_CACHE_ADD@|${_BLNK_WRAP_PRIVATE_CACHE_ADD.${_wrappee_}:Q}|g" \
@@ -1021,6 +1025,8 @@ buildlink-wrappers: ${BUILDLINK_${_wrappee_}}
.if !target(${BUILDLINK_${_wrappee_}})
${BUILDLINK_${_wrappee_}}: \
${_BLNK_WRAPPER_SH.${_wrappee_}} \
+ ${_BLNK_WRAP_BUILDCMD.${_wrappee_}} \
+ ${_BLNK_WRAP_QUOTEARG.${_wrappee_}} \
${_BLNK_WRAP_MARSHALL.${_wrappee_}} \
${_BLNK_WRAP_PRIVATE_CACHE.${_wrappee_}} \
${_BLNK_WRAP_CACHE.${_wrappee_}} \
@@ -1122,6 +1128,20 @@ ${_BLNK_EMPTY_FILE}:
${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_ARGS} ${.TARGET}
.endif
+.if !target(${_BLNK_WRAP_BUILDCMD})
+${_BLNK_WRAP_BUILDCMD}: ${.CURDIR}/../../mk/buildlink3/buildcmd
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_BLNK_SH_CRUNCH_FILTER} > ${.TARGET}
+.endif
+
+.if !target(${_BLNK_WRAP_QUOTEARG})
+${_BLNK_WRAP_QUOTEARG}: ${.CURDIR}/../../mk/buildlink3/quotearg
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_BLNK_SH_CRUNCH_FILTER} > ${.TARGET}
+.endif
+
.if !target(${_BLNK_WRAP_MARSHALL})
${_BLNK_WRAP_MARSHALL}: ${.CURDIR}/../../mk/buildlink3/marshall
${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
@@ -1268,12 +1288,6 @@ ${_BLNK_WRAP_PRIVATE_POST_LOGIC.${_wrappee_}}:
. endif
.endfor
-${BUILDLINK_DIR}/bin/.libtool-do-install: \
- ${.CURDIR}/../../mk/buildlink3/libtool-do-install
- ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
- ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
- | ${_BLNK_SH_CRUNCH_FILTER} > ${.TARGET}
-
${BUILDLINK_DIR}/bin/.libtool-fix-la: \
${.CURDIR}/../../mk/buildlink3/libtool-fix-la \
${_BLNK_UNTRANSFORM_SEDFILE}
diff --git a/mk/buildlink3/buildcmd b/mk/buildlink3/buildcmd
new file mode 100644
index 00000000000..2a1bb6814a4
--- /dev/null
+++ b/mk/buildlink3/buildcmd
@@ -0,0 +1,45 @@
+# $NetBSD: buildcmd,v 1.1 2003/10/03 19:39:19 jlam Exp $
+#
+# Append $arg to $cmd to build up the command line to be executed, but
+# directly add the next few arguments to $cmd if $skipargs > 0.
+
+if $test $skipargs -gt 0; then
+ cmd="$cmd $arg"
+ while $test $skipargs -gt 0; do
+ arg=$1; shift
+ . $quotearg
+ arg="$qarg"
+ cmd="$cmd $arg"
+ skipargs=`$expr $skipargs - 1`
+ done
+else
+ #
+ # Reduce command length by not appending options that we've
+ # already seen to the command.
+ #
+ case $arg in
+ -[DILR]*|-Wl,-R*|-Wl,-*,/*)
+ #
+ # These options are only ever useful the first time
+ # they're given. All other instances are redundant.
+ #
+ case "$cmd" in
+ *" "$arg|*" "$arg" "*) ;;
+ *) cmd="$cmd $arg" ;;
+ esac
+ ;;
+ -l*)
+ #
+ # Extra libraries are suppressed only if they're
+ # repeated, e.g. "-lm -lm -lm -lm" -> "-lm".
+ #
+ case "$cmd" in
+ *" "$arg) ;;
+ *) cmd="$cmd $arg" ;;
+ esac
+ ;;
+ *)
+ cmd="$cmd $arg"
+ ;;
+ esac
+fi
diff --git a/mk/buildlink3/libtool-do-install b/mk/buildlink3/libtool-do-install
deleted file mode 100644
index dc851a5e339..00000000000
--- a/mk/buildlink3/libtool-do-install
+++ /dev/null
@@ -1,25 +0,0 @@
-# $NetBSD: libtool-do-install,v 1.2 2003/09/02 06:59:56 jlam Exp $
-#
-# This file is called directly by the libtool wrapper when it has
-# figured out that the libtool invocation is meant to do a file
-# installation. We simply quote the remaining command-line arguments
-# properly to build a correct libtool command line. The libtool
-# wrapper will perform the actual execution. We don't worry about
-# caching or speed, since installation is not a bottleneck for package
-# creation.
-
-cmd="$cmd $arg"
-while $test $# -gt 0; do
- arg="$1"; shift
- case $arg in
- *[\`\"\$\\]*)
- arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
- ;;
- esac
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- cmd="$cmd $arg"
-done
diff --git a/mk/buildlink3/libtool.sh b/mk/buildlink3/libtool.sh
index f6057eb58e9..8008999eafc 100644
--- a/mk/buildlink3/libtool.sh
+++ b/mk/buildlink3/libtool.sh
@@ -1,10 +1,12 @@
#!@BUILDLINK_SHELL@
#
-# $NetBSD: libtool.sh,v 1.4 2003/09/23 19:48:23 jlam Exp $
+# $NetBSD: libtool.sh,v 1.5 2003/10/03 19:39:19 jlam Exp $
Xsed='@SED@ -e 1s/^X//'
sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
+buildcmd="@_BLNK_WRAP_BUILDCMD@"
+quotearg="@_BLNK_WRAP_QUOTEARG@"
marshall="@_BLNK_WRAP_MARSHALL@"
private_pre_cache="@_BLNK_WRAP_PRIVATE_PRE_CACHE@"
private_cache_add="@_BLNK_WRAP_PRIVATE_CACHE_ADD@"
@@ -20,7 +22,6 @@ post_logic="@_BLNK_WRAP_POST_LOGIC@"
wrapperlog="${BUILDLINK_WRAPPER_LOG-@_BLNK_WRAP_LOG@}"
libtool_fix_la="@_BLNK_LIBTOOL_FIX_LA@"
-libtool_do_install="@_BLNK_LIBTOOL_DO_INSTALL@"
fixlibpath=${BUILDLINK_FIX_IMPROPER_LIBTOOL_LIBPATH-yes}
updatecache=${BUILDLINK_UPDATE_CACHE-yes}
@@ -86,12 +87,23 @@ done
cmd="@WRAPPEE@"
case $mode in
install)
- arg="$1"; shift
- . $libtool_do_install
+ #
+ # We're doing libtool installation, so just quote all of the
+ # command-line arguments and append them to $cmd. We don't worry
+ # about caching or speed, since installation is not a bottleneck
+ # for package creation.
+ #
+ while $test $# -gt 0; do
+ arg="$1"; shift
+ . $quotearg
+ arg="$qarg"
+ cmd="$cmd $arg"
+ done
;;
*)
while $test $# -gt 0; do
arg="$1"; shift
+ skipargs=0
case $arg in
--fix-la)
. $libtool_fix_la
@@ -137,34 +149,9 @@ install)
;;
esac
#
- # Reduce command length by not appending options that we've
- # already seen to the command.
+ # Build up the command-line.
#
- case "$arg" in
- -[DILR]*|-Wl,-R*|-Wl,-*,/*)
- #
- # These options are only ever useful the first time
- # they're given. All other instances are redundant.
- #
- case "$cmd" in
- *" "$arg|*" "$arg" "*) ;;
- *) cmd="$cmd $arg" ;;
- esac
- ;;
- -l*)
- #
- # Extra libraries are suppressed only if they're
- # repeated, e.g. "-lm -lm -lm -lm" -> "-lm".
- #
- case "$cmd" in
- *" "$arg) ;;
- *) cmd="$cmd $arg" ;;
- esac
- ;;
- *)
- cmd="$cmd $arg"
- ;;
- esac
+ . $buildcmd
done
;;
esac
diff --git a/mk/buildlink3/logic b/mk/buildlink3/logic
index c62c25ceaf6..75b9b2909ff 100644
--- a/mk/buildlink3/logic
+++ b/mk/buildlink3/logic
@@ -1,26 +1,11 @@
-# $NetBSD: logic,v 1.3 2003/09/19 22:47:34 jlam Exp $
+# $NetBSD: logic,v 1.4 2003/10/03 19:39:19 jlam Exp $
quotedarg=no
addtocache=no
addtoprivatecache=no
cachesettings='arg="$cachearg"; cachehit=yes'
-# $qarg contains a correctly-quoted $arg
-case $arg in
-*[\`\"\$\\]*)
- qarg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
- quotedarg=yes
- ;;
-*)
- qarg="$arg"
- ;;
-esac
-case $qarg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- qarg="\"$qarg\""
- quotedarg=yes
- ;;
-esac
+. $quotearg
searcharg="$qarg"
case $arg in
diff --git a/mk/buildlink3/quotearg b/mk/buildlink3/quotearg
new file mode 100644
index 00000000000..ea37c7df37c
--- /dev/null
+++ b/mk/buildlink3/quotearg
@@ -0,0 +1,20 @@
+# $NetBSD: quotearg,v 1.1 2003/10/03 19:39:19 jlam Exp $
+#
+# Returns $qarg, which contains a correctly-quoted $arg. Also sets
+# $quotedarg to "yes" if the $arg needed to be quoted.
+#
+case $arg in
+*[\`\"\$\\]*)
+ qarg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+ quotedarg=yes
+ ;;
+*)
+ qarg="$arg"
+ ;;
+esac
+case $qarg in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ qarg="\"$qarg\""
+ quotedarg=yes
+ ;;
+esac
diff --git a/mk/buildlink3/wrapper.sh b/mk/buildlink3/wrapper.sh
index c95f4968f67..4a611fc2fd1 100644
--- a/mk/buildlink3/wrapper.sh
+++ b/mk/buildlink3/wrapper.sh
@@ -1,10 +1,12 @@
#!@BUILDLINK_SHELL@
#
-# $NetBSD: wrapper.sh,v 1.3 2003/09/08 21:10:26 jlam Exp $
+# $NetBSD: wrapper.sh,v 1.4 2003/10/03 19:39:19 jlam Exp $
Xsed='@SED@ -e 1s/^X//'
sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
+buildcmd="@_BLNK_WRAP_BUILDCMD@"
+quotearg="@_BLNK_WRAP_QUOTEARG@"
marshall="@_BLNK_WRAP_MARSHALL@"
private_pre_cache="@_BLNK_WRAP_PRIVATE_PRE_CACHE@"
private_cache_add="@_BLNK_WRAP_PRIVATE_CACHE_ADD@"
@@ -24,6 +26,7 @@ cacheall="${BUILDLINK_CACHE_ALL-no}"
cat="@CAT@"
echo="@ECHO@"
+expr="@EXPR@"
test="@TEST@"
BUILDLINK_DIR="@BUILDLINK_DIR@"
@@ -35,6 +38,7 @@ while $test $# -gt 0; do
arg="$1"; shift
cachehit=no
skipcache=no
+ skipargs=0
#
# Marshall any group of consecutive arguments into a single
# $arg to be checked in the cache and logic files.
@@ -58,34 +62,9 @@ while $test $# -gt 0; do
no) . $logic ;;
esac
#
- # Reduce command length by not appending options that we've
- # already seen to the command.
+ # Build up the command-line.
#
- case $arg in
- -[DILR]*|-Wl,-R*|-Wl,-*,/*)
- #
- # These options are only ever useful the first time
- # they're given. All other instances are redundant.
- #
- case "$cmd" in
- *" "$arg|*" "$arg" "*) ;;
- *) cmd="$cmd $arg" ;;
- esac
- ;;
- -l*)
- #
- # Extra libraries are suppressed only if they're
- # repeated, e.g. "-lm -lm -lm -lm" -> "-lm".
- #
- case "$cmd" in
- *" "$arg) ;;
- *) cmd="$cmd $arg" ;;
- esac
- ;;
- *)
- cmd="$cmd $arg"
- ;;
- esac
+ . $buildcmd
done
@_BLNK_WRAP_ENV@