# $NetBSD: buildcmd,v 1.4 2004/01/30 10:56:11 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 $arg in -L*) case "$ldflags" in *" "$arg|*" "$arg" "*) ;; *) ldflags="$ldflags $arg" ;; esac ;; *) case "$cmd" in *" "$arg|*" "$arg" "*) ;; *) cmd="$cmd $arg" ;; esac ;; esac ;; -l*) # # Suppressed sequentially repeated libraries, # e.g. "-lm -lm -lm -lm" -> "-lm". # case "$libs" in *" "$arg) ;; *) libs="$libs $arg" ;; esac ;; *) cmd="$cmd $arg" ;; esac fi