diff options
author | jlam <jlam> | 2003-10-09 12:15:15 +0000 |
---|---|---|
committer | jlam <jlam> | 2003-10-09 12:15:15 +0000 |
commit | 9528267b5a0c3cee83a83222d0394cb050f336d6 (patch) | |
tree | e76a9cc2c237a4f70cfe05079cc1ef96e294b39a | |
parent | aee2893f0d7b1c587f9b3140f3c56be3768e2f20 (diff) | |
download | pkgsrc-9528267b5a0c3cee83a83222d0394cb050f336d6.tar.gz |
Change the way in which arguments are processed by the wrappers. We
know read the arguments by first placing them in a buffer and taking
the argument in the first non-empty buffer as the argument to process.
The buffer is there to allow "splitting" an argument into multiple
arguments (currently up to five arguments), e.g. "-Wl,-R/path1:/path2"
is split into "-Wl,-R/path1" and "-Wl,-R/path2". Each split argument
is placed into a buffer. Using a buffer lets us read and process all
of the arguments in a single pass despite "pushing" more arguments
onto the front of the argument array.
-rw-r--r-- | mk/buildlink3/bsd.buildlink3.mk | 13 | ||||
-rw-r--r-- | mk/buildlink3/buffer | 71 | ||||
-rw-r--r-- | mk/buildlink3/libtool.sh | 20 | ||||
-rw-r--r-- | mk/buildlink3/wrapper.sh | 14 |
4 files changed, 102 insertions, 16 deletions
diff --git a/mk/buildlink3/bsd.buildlink3.mk b/mk/buildlink3/bsd.buildlink3.mk index 24aa1bcb76e..fe38b39dc29 100644 --- a/mk/buildlink3/bsd.buildlink3.mk +++ b/mk/buildlink3/bsd.buildlink3.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.buildlink3.mk,v 1.26 2003/10/08 09:11:33 jlam Exp $ +# $NetBSD: bsd.buildlink3.mk,v 1.27 2003/10/09 12:15:15 jlam Exp $ # # An example package buildlink3.mk file: # @@ -829,6 +829,7 @@ _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_BUFFER= ${BUILDLINK_DIR}/bin/.buffer _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 @@ -857,6 +858,7 @@ _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_BUFFER.${_wrappee_}= ${_BLNK_WRAP_BUFFER} _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} @@ -993,6 +995,7 @@ _BLNK_WRAPPER_TRANSFORM_SED.${_wrappee_}= \ -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_BUFFER@|${_BLNK_WRAP_BUFFER.${_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" \ @@ -1013,6 +1016,7 @@ ${BUILDLINK_${_wrappee_}}: \ ${_BLNK_WRAPPER_SH.${_wrappee_}} \ ${_BLNK_WRAP_BUILDCMD.${_wrappee_}} \ ${_BLNK_WRAP_QUOTEARG.${_wrappee_}} \ + ${_BLNK_WRAP_BUFFER.${_wrappee_}} \ ${_BLNK_WRAP_MARSHALL.${_wrappee_}} \ ${_BLNK_WRAP_PRIVATE_CACHE.${_wrappee_}} \ ${_BLNK_WRAP_CACHE.${_wrappee_}} \ @@ -1128,6 +1132,13 @@ ${_BLNK_WRAP_QUOTEARG}: ${.CURDIR}/../../mk/buildlink3/quotearg | ${_BLNK_SH_CRUNCH_FILTER} > ${.TARGET} .endif +.if !target(${_BLNK_WRAP_BUFFER}) +${_BLNK_WRAP_BUFFER}: ${.CURDIR}/../../mk/buildlink3/buffer + ${_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} diff --git a/mk/buildlink3/buffer b/mk/buildlink3/buffer new file mode 100644 index 00000000000..bcc7425172e --- /dev/null +++ b/mk/buildlink3/buffer @@ -0,0 +1,71 @@ +# $NetBSD: buffer,v 1.1 2003/10/09 12:15:15 jlam Exp $ +# +# Fill the buffer if it's empty, and shift the arguments. The next +# argument checked by the cache and logic files is taken from the +# first non-empty buffer. We avoid using "eval" so that we can skip +# having to specially quote the argument using "sed". +# +case ${buf1}${buf2}${buf3}${buf4}${buf5} in +"") + arg="$1"; shift + # + # Marshall any group of consecutive arguments into a single + # $arg to be checked in the cache and logic files. + # + . $marshall + # + # Fill the buffers from $arg. + # + case $arg in + -Wl,-R*:*|-Wl,-rpath,*:*|-Wl,-rpath-link,*:*|\ + -Wl,--rpath,*:*|-Wl,--rpath-link,*:*) + # + # Change "-Wl,-R/path1:/path2:/path3" into + # "-Wl,-R/path1 -Wl,-R/path2 -Wl,-R/path3" so that + # they can be checked correctly in the cache and logic + # files. + # + case $arg in + -Wl,-R*) R="-Wl,-R" ;; + -Wl,-rpath,*) R="-Wl,-rpath," ;; + -Wl,-rpath-link,*) R="-Wl,-rpath-link," ;; + -Wl,--rpath,*) R="-Wl,--rpath," ;; + -Wl,--rpath-link,*) R="-Wl,--rpath-link," ;; + esac + arg=`$echo "X$arg" | $Xsed -e "s|^"$R"||g"` + allargs="$@" + save_IFS="${IFS}"; IFS=":" + set -- $arg + while $test $# -gt 0; do + if $test -z "$buf1"; then buf1="$R$1"; shift + elif $test -z "$buf2"; then buf2="$R$1"; shift + elif $test -z "$buf3"; then buf3="$R$1"; shift + elif $test -z "$buf4"; then buf4="$R$1"; shift + elif $test -z "$buf5"; then buf5="$R$1"; shift + fi + done + IFS="${save_IFS}" + if $test -n "$allargs"; then + set -- $allargs + fi + ;; + *) + if $test -z "$buf1"; then buf1="$arg" + elif $test -z "$buf2"; then buf2="$arg" + elif $test -z "$buf3"; then buf3="$arg" + elif $test -z "$buf4"; then buf4="$arg" + elif $test -z "$buf5"; then buf5="$arg" + fi + ;; + esac + ;; +esac +# +# Re-fetch $arg from the first non-empty buffer. +# +if $test -n "$buf1"; then arg="$buf1"; buf1= +elif $test -n "$buf2"; then arg="$buf2"; buf2= +elif $test -n "$buf3"; then arg="$buf3"; buf3= +elif $test -n "$buf4"; then arg="$buf4"; buf4= +elif $test -n "$buf5"; then arg="$buf5"; buf5= +fi diff --git a/mk/buildlink3/libtool.sh b/mk/buildlink3/libtool.sh index 8008999eafc..5710423b644 100644 --- a/mk/buildlink3/libtool.sh +++ b/mk/buildlink3/libtool.sh @@ -1,12 +1,13 @@ #!@BUILDLINK_SHELL@ # -# $NetBSD: libtool.sh,v 1.5 2003/10/03 19:39:19 jlam Exp $ +# $NetBSD: libtool.sh,v 1.6 2003/10/09 12:15:15 jlam Exp $ Xsed='@SED@ -e 1s/^X//' sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' buildcmd="@_BLNK_WRAP_BUILDCMD@" quotearg="@_BLNK_WRAP_QUOTEARG@" +buffer="@_BLNK_WRAP_BUFFER@" marshall="@_BLNK_WRAP_MARSHALL@" private_pre_cache="@_BLNK_WRAP_PRIVATE_PRE_CACHE@" private_cache_add="@_BLNK_WRAP_PRIVATE_CACHE_ADD@" @@ -35,6 +36,9 @@ BUILDLINK_DIR="@BUILDLINK_DIR@" WRKDIR="@WRKDIR@" WRKSRC="@WRKSRC@" +# Argument buffers +buf1=; buf2=; buf3=; buf4=; buf5= + mode=link prevopt= nonopt= @@ -101,9 +105,13 @@ install) done ;; *) - while $test $# -gt 0; do - arg="$1"; shift + while $test $# -gt 0 -o -n "${buf1}${buf2}${buf3}${buf4}${buf5}"; do skipargs=0 + # + # Get the next argument from the buffer. + # + . $buffer + case $arg in --fix-la) . $libtool_fix_la @@ -121,12 +129,6 @@ install) cachehit=no skipcache=no # - # Marshall any group of consecutive arguments into - # a single $arg to be checked in the cache and - # logic files. - # - . $marshall - # # Check the private cache, and possibly set # skipcache=yes. # diff --git a/mk/buildlink3/wrapper.sh b/mk/buildlink3/wrapper.sh index 4a611fc2fd1..dc2d395cb60 100644 --- a/mk/buildlink3/wrapper.sh +++ b/mk/buildlink3/wrapper.sh @@ -1,12 +1,13 @@ #!@BUILDLINK_SHELL@ # -# $NetBSD: wrapper.sh,v 1.4 2003/10/03 19:39:19 jlam Exp $ +# $NetBSD: wrapper.sh,v 1.5 2003/10/09 12:15:15 jlam Exp $ Xsed='@SED@ -e 1s/^X//' sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' buildcmd="@_BLNK_WRAP_BUILDCMD@" quotearg="@_BLNK_WRAP_QUOTEARG@" +buffer="@_BLNK_WRAP_BUFFER@" marshall="@_BLNK_WRAP_MARSHALL@" private_pre_cache="@_BLNK_WRAP_PRIVATE_PRE_CACHE@" private_cache_add="@_BLNK_WRAP_PRIVATE_CACHE_ADD@" @@ -33,17 +34,18 @@ BUILDLINK_DIR="@BUILDLINK_DIR@" WRKDIR="@WRKDIR@" WRKSRC="@WRKSRC@" +# Argument buffers +buf1=; buf2=; buf3=; buf4=; buf5= + cmd="@WRAPPEE@ @_BLNK_WRAP_EXTRA_FLAGS@" -while $test $# -gt 0; do - arg="$1"; shift +while $test $# -gt 0 -o -n "${buf1}${buf2}${buf3}${buf4}${buf5}"; do 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. + # Get the next argument from the buffer. # - . $marshall + . $buffer # # Check the private cache, and possibly set skipcache=yes. # |