From: <sg...@us...> - 2003-08-31 20:33:00
|
Update of /cvsroot/libfunutil/libfunutil/toc/sbin In directory sc8-pr-cvs1:/tmp/cvs-serv21765/toc/sbin Modified Files: toc_core.sh Log Message: Added optional second arg to toc_get_make, to tell it out echo output. Added $prefix to toc.make. Added toc_export function. Index: toc_core.sh =================================================================== RCS file: /cvsroot/libfunutil/libfunutil/toc/sbin/toc_core.sh,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- toc_core.sh 31 Aug 2003 00:40:48 -0000 1.23 +++ toc_core.sh 31 Aug 2003 20:32:56 -0000 1.24 @@ -147,30 +147,37 @@ } function toc_get_make -{ # an inefficient way to get a key which has been previously set +{ # gets a key which has been previously set # via toc_add_make. The value is not echoed, but is in the # global var ${TOC_GET_MAKE}. Returns 0 if it finds the var # and 1 if it does not. + # # $1 = name of var. - i=${#CONFIG_DOT_MAKE_ARRAY[@]} - arg=$1 - theval= + # [$2] = if 1 then the result is echoed. If 2 then $1=${TOC_GET_MAKE} + # is echoed. Default behaviour is to not output anything. + # A pneumonic for $2: 1 stands for one part (the value) and 2 + # stands for 2 parts (the key and the value). TOC_GET_MAKE= - ret=1 + local i=${#CONFIG_DOT_MAKE_ARRAY[@]} + local arg="$1" + local theval= + local ret=1 i=$((i - 1)) while test $i -ge 0; do foo=${CONFIG_DOT_MAKE_ARRAY[$i]} - k=${foo%%=*} - v=${foo#*=} + k="${foo%%=*}" + v="${foo#*=}" test "$arg" = "$k" && { ret=0 - theval=$v + theval="$v" break } i=$((i - 1)) done - TOC_GET_MAKE=$theval - toc_debug toc_get_make $arg=$theval + TOC_GET_MAKE="$theval" + test "x$2" = "x1" && echo ${TOC_GET_MAKE} + test "x$2" = "x2" && echo $arg="${TOC_GET_MAKE}" + toc_debug toc_get_make "$arg=$theval" return $ret } @@ -219,8 +226,9 @@ tocmakeprops=${cmake}.props cp $makeprops $tocmakeprops cat <<EOF >> $tocmakeprops -TOC_RELATIVE_DIR=${shortform##./} TOC_TOP_SRCDIR=${relpath##./} +prefix=${prefix} +TOC_RELATIVE_DIR=${shortform##./} TOC_SHARED_MAKEFILE=${TOC_SHARED_MAKEFILE} TOC_EMOTICON_OKAY=${TOC_EMOTICON_OKAY} TOC_EMOTICON_WARNING= ${TOC_EMOTICON_WARNING} @@ -336,13 +344,14 @@ # # It returns 1 if ${TOC_FIND_RESULT} is empty (i.e., if it found anything), # else it returns 0. - function toc_find_in_path () + function toc_find_in_path { + toc_debug toc_find_in_path $@ TOC_FIND_RESULT= # holds the quasi-return value local app=$1 shift - local path=$@ - test -n "$path" || path=$PATH + local path="$@" + test -n "$path" || path="$PATH" # strange: when run as: toc_find_in_path ls $PATH # path is space-separated! # echo path=$path @@ -372,6 +381,8 @@ # # Only call these funcs with one key/val pair at a time, to allow for # proper handling of foo="something with spaces in it" + # + # usage: toc_add_make VAR="VAR's value, presumably." function toc_add_make { toc_debug "toc_add_make: $@" @@ -387,6 +398,15 @@ toc_add_make $@ toc_add_config_h $@ } + function toc_export + { # the ultimate in laziness: toc_add_config plus shell export. + toc_debug toc_export $@ + toc_add_config $@ + local args="$@" + local k="${args%%=*}" + local v="${args##*=}" + eval "export $k='$v'" + } } # end config manipulator @@ -493,7 +513,8 @@ # in ${2-${PATH}. It returns 1 if it finds no file, else zero. # It "returns" the found file in ${TOC_FIND_RESULT}. local bin=$1 - path=${2-${PATH}} + shift + path="${@-${PATH}}" toc_quietly -n "? find $bin ..." toc_find_in_path $bin $path || { toc_quietly "not found ${TOC_EMOTICON_WARNING}" @@ -604,6 +625,27 @@ } } # end toc_atfilter_file + + +function toc_makerelative +{ # usage: toc_makerelative /foo/bar/one/two /foo/bar + # sets global var TOC_MAKERELATIVE to the "return value". + # In the above example, it should = ./../.. + local startat=${1-$PWD} + local relto=${2-${TOC_TOPDIR}} + test -n "$relto" || $relto=$PWD + test -f $startat && startat=$(dirname $startat) + local dn=$startat/bogus + local dn=${dn%*/*} + local rel="." + while test -n "$dn" -a "$dn" != "$relto" -a "$dn" != "/"; do + rel="$rel/.." + dn=${dn%*/*} + done + TOC_MAKERELATIVE=${rel##./} +} + + function toc_endconfigure { # ends the configuration process, processing the files # which need to be @-parsed @@ -621,9 +663,9 @@ toc_debug "toc_parseargs: Handling command-line arguments: $@" # mostly stolen from the qt 3.1.0 configure script :) while [ "$#" -gt 0 ]; do - local VAR= - local VAL= - local arg=$1 + VAR= + VAL= + arg=$1 shift case $arg in --help|-?) @@ -725,26 +767,7 @@ } done return 0 -} - - -function toc_makerelative -{ # usage: toc_makerelative /foo/bar/one/two /foo/bar - # sets global var TOC_MAKERELATIVE to the "return value". - # In the above example, it should = ./../.. - local startat=${1-$PWD} - local relto=${2-${TOC_TOPDIR}} - test -n "$relto" || $relto=$PWD - test -f $startat && startat=$(dirname $startat) - local dn=$startat/bogus - local dn=${dn%*/*} - local rel="." - while test -n "$dn" -a "$dn" != "$relto" -a "$dn" != "/"; do - rel="$rel/.." - dn=${dn%*/*} - done - TOC_MAKERELATIVE=${rel##./} -} +} # end parseargs # We do some initial sanity checking here, |