pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/mk/buildlink3 Factor out some more commonly used bits ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/239409a203f8
branches:  trunk
changeset: 462483:239409a203f8
user:      jlam <jlam%pkgsrc.org@localhost>
date:      Fri Oct 03 19:39:19 2003 +0000

description:
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:

 mk/buildlink3/bsd.buildlink3.mk  |  34 +++++++++++++++++++--------
 mk/buildlink3/buildcmd           |  45 ++++++++++++++++++++++++++++++++++++
 mk/buildlink3/libtool-do-install |  25 --------------------
 mk/buildlink3/libtool.sh         |  49 ++++++++++++++-------------------------
 mk/buildlink3/logic              |  19 +-------------
 mk/buildlink3/quotearg           |  20 ++++++++++++++++
 mk/buildlink3/wrapper.sh         |  35 +++++----------------------
 7 files changed, 116 insertions(+), 111 deletions(-)

diffs (truncated from 395 to 300 lines):

diff -r ad0d87e09346 -r 239409a203f8 mk/buildlink3/bsd.buildlink3.mk
--- a/mk/buildlink3/bsd.buildlink3.mk   Fri Oct 03 18:31:18 2003 +0000
+++ b/mk/buildlink3/bsd.buildlink3.mk   Fri Oct 03 19:39:19 2003 +0000
@@ -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_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_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_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 @@
 
 .PHONY: buildlink-wrappers
 
-buildlink-wrappers: ${_BLNK_LIBTOOL_DO_INSTALL}
 buildlink-wrappers: ${_BLNK_LIBTOOL_FIX_LA}
 
 .for _wrappee_ in ${_BLNK_WRAPPEES}
@@ -996,13 +998,15 @@
        -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 @@
 .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 @@
        ${_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 @@
 .  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 -r ad0d87e09346 -r 239409a203f8 mk/buildlink3/buildcmd
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mk/buildlink3/buildcmd    Fri Oct 03 19:39:19 2003 +0000
@@ -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 -r ad0d87e09346 -r 239409a203f8 mk/buildlink3/libtool-do-install
--- a/mk/buildlink3/libtool-do-install  Fri Oct 03 18:31:18 2003 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -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 -r ad0d87e09346 -r 239409a203f8 mk/buildlink3/libtool.sh
--- a/mk/buildlink3/libtool.sh  Fri Oct 03 18:31:18 2003 +0000
+++ b/mk/buildlink3/libtool.sh  Fri Oct 03 19:39:19 2003 +0000
@@ -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 @@
 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 @@
 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 @@
                        ;;
                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 -r ad0d87e09346 -r 239409a203f8 mk/buildlink3/logic
--- a/mk/buildlink3/logic       Fri Oct 03 18:31:18 2003 +0000
+++ b/mk/buildlink3/logic       Fri Oct 03 19:39:19 2003 +0000
@@ -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"
 



Home | Main Index | Thread Index | Old Index