From: <sg...@us...> - 2003-09-27 22:34:35
|
Update of /cvsroot/libfunutil/libfunutil/toc/sbin In directory sc8-pr-cvs1:/tmp/cvs-serv7210/toc/sbin Modified Files: toc_core.sh toconfigure Log Message: massive commit, mainly fixes/changes from the elib tree. Index: toc_core.sh =================================================================== RCS file: /cvsroot/libfunutil/libfunutil/toc/sbin/toc_core.sh,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- toc_core.sh 5 Sep 2003 09:33:48 -0000 1.26 +++ toc_core.sh 27 Sep 2003 22:34:03 -0000 1.27 @@ -77,23 +77,27 @@ } function boldecho { # backwards compatibility - toc_boldecho $@ + toc_boldecho "$@" } } # end eye candy TOC_ERR_OK=0 TOC_ERR_ERROR=1 +# OKAY, ERROR and WARNING are "core" emoticons: TOC_EMOTICON_OKAY="${TOC_BOLD_}:-)${_TOC_BOLD}" TOC_EMOTICON_ERROR="${TOC_BOLD_}:-(${_TOC_BOLD}" TOC_EMOTICON_WARNING="${TOC_BOLD_}:-O${_TOC_BOLD}" -# TOC_EMOTICON_WTF="${TOC_BOLD_}:-?${_TOC_BOLD}" + +# "unofficial" emoticons:x +TOC_EMOTICON_GRIEF="${TOC_BOLD_}:'-(${_TOC_BOLD}" +TOC_EMOTICON_WTF="${TOC_BOLD_}:-?${_TOC_BOLD}" function toc_debug { test "$TOC_DEBUG" -ne 0 || return 0; - echo "toc_debug: " $@ 1>&2 + echo "toc_debug: " "$@" 1>&2 return 0 } @@ -346,12 +350,26 @@ # else it returns 0. function toc_find_in_path { - toc_debug 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" + + # EXPERIMENTAL --with-FOO=/path/to/foo support + local foo + local bar + bar=$(echo $app | tr '[\-\.\\/+]' '[_____]') + # ^^^ there's Grief waiting to happen here :/ + eval foo=\$configure_with_${bar} + test x${foo} != x -a x${foo} != x0 -a x${foo} != x1 && { + toc_loudly -n " Using explicit --with-$app: $foo" + app="${foo}" + path="" + } + # /experiment + # strange: when run as: toc_find_in_path ls $PATH # path is space-separated! # echo path=$path @@ -395,13 +413,13 @@ } function toc_add_config { - toc_add_make $@ - toc_add_config_h $@ + 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 $@ + toc_debug toc_export "$@" + toc_add_config "$@" local args="$@" local k="${args%%=*}" local v="${args##*=}" @@ -435,7 +453,7 @@ { TOC_RUN_DEPTH=$((TOC_RUN_DEPTH + 1)) local depth=${TOC_RUN_DEPTH} - toc_debug "toc_run " $@ + toc_debug "toc_run " "$@" local testname=$1 #${TOC_FIND_RESULT} #TOC_DIR=${TOC_TESTSDIR} local path= @@ -458,10 +476,12 @@ i=$((i + 1)) done toc_boldecho -n " [$showname] " - test -n "$desc" && echo -n $desc + test -n "$desc" && eval "echo -n $desc" + # ^^^ the eval allows us to use $VARS in toc_run_description. as a + # side-effect, however, you must escape ><| in toc_run_description! echo local err=0 - toc_source_test $testname $@ + toc_source_test $testname "$@" err=$? if test ${TOC_FAIL_FAST-0} = 1 -a $err != 0; then toc_die $err "toc_run: TOC_FAIL_FAST is set, and test $testname returned a non-zero error code." @@ -473,10 +493,10 @@ function toc_run_failok { # runs toc_run and warns if there was an error. # It does not exit - it passed back the error code from the test. - toc_debug toc_run_failok $@ + toc_debug toc_run_failok "$@" local testname=$1 local depth=$((TOC_RUN_DEPTH + 1)) - toc_run $@ || { + toc_run "$@" || { local ret=$? toc_loudly -n "[${depth}] " toc_boldecho -n "^^^^^^^^^^ " @@ -491,10 +511,10 @@ function toc_run_fail { # calls toc_run and fails if it returns !0 - toc_debug toc_run_fail $@ + toc_debug toc_run_fail "$@" local testname=$1 local depth=$((TOC_RUN_DEPTH + 1)) - toc_run $@ || { + toc_run "$@" || { local ret=$? toc_loudly -n "[${depth}] " toc_boldecho -n "^^^^^^^^^^ " @@ -514,13 +534,13 @@ # It "returns" the found file in ${TOC_FIND_RESULT}. local bin=$1 shift - path="${@-${PATH}}" + local path="${@-${PATH}}" toc_quietly -n "? find $bin ..." toc_find_in_path $bin $path || { toc_quietly "not found ${TOC_EMOTICON_WARNING}" return 1 } - str= + local str= test "x${TOC_QUIET-0}" = "x0" && str="${TOC_EMOTICON_OKAY}" test "x${TOC_LOUD-0}" != "x0" && str="${TOC_FIND_RESULT}" test -n "$str" && echo " $str" @@ -528,7 +548,7 @@ } function toc_find_fail { # See toc_find_failok(), except this one exits on error - toc_find_failok $@ || toc_die $? toc_find_fail $@ + toc_find_failok "$@" || toc_die $? toc_find_fail "$@" return 0 } @@ -544,7 +564,7 @@ test -f "$sh" || toc_die 1 "toc_source_test $test: $sh not found!" local err=0 toc_debug "toc_source_test sourcing [$sh $@]" - source $sh $@ + source $sh "$@" err=$? return $err } @@ -662,42 +682,68 @@ { # parses $@ for arguments toc can work with. toc_debug "toc_parseargs: Handling command-line arguments: $@" # mostly stolen from the qt 3.1.0 configure script :) + local i=0 + local -a passon # clone of $@ to pass on to TOC_PARSEARGS_CALLBACK while [ "$#" -gt 0 ]; do - VAR= - VAL= - arg="$1" + local arg="$1" shift + passon[${i}]="$arg" + i=$((i + 1)) + local VAR= + local VAL= + #echo arg=$arg case $arg in --help|-?) cat<<-EOF Usage: $0 [--prefix=/path] [--argument=value] [--arg2=val2] ... - See the README file for this package to find out which arguments are supported. - Standard arguments include: EOF -# ^^^^ note usage of hard tabs in the cat command! -cat <<EOF | perl -ne 'm/\t*(.*)\s*\|\s*(.*)/; print " $1\n\t\t$2\n";' +# ^^^^ note usage of hard tabs in the cat data! + +cat <<EOF | perl -ne '$|=1; next unless m|\w|; m/\t*(.*)\s*\|\s*(.*)/; print " $1\n\t\t$2\n";' --help or -? | Show this help. - --prefix=/path | Top-most path for installation. Default: ${prefix} + --prefix=/path | Top-most path for installation. Default=${prefix} --enable-FEATURE=... | Exports config variable configure_enable_FEATURE. - --enable-FEATURE | Equivalent to --enable-FEATURE=1. - --disable-FEATURE | Equivalent to --enable-FEATURE=0. - --with-FEATURE=... | Sets the global variable configure_with_FEATURE. - --with-FEATURE | Equivalent to --with-FEATURE=1. - --without-FEATURE | Equivalent to --with-FEATURE=0. + --enable-FEATURE | Equivalent to --enable-FEATURE=1. + --disable-FEATURE | Equivalent to --enable-FEATURE=0. + --with-FEATURE=... | Sets the config variable configure_with_FEATURE. + --with-FEATURE | Equivalent to --with-FEATURE=1. + --without-FEATURE | Equivalent to --with-FEATURE=0. --XXX=YYY | Exports config variable XXX=YYY. --XXX | Equivalent to --XXX=1. - --toc-quiet,--quiet | Disables some text which may be of arguable utility. - --toc-loud, --loud | Enables some otherwise superfluous information. - --verbose | Enables --loud and disables --quiet + --toc-quiet,--quiet | Makes configure run more quietly. + --toc-loud, --loud | configure will output some otherwise superfluous information. + --verbose | Enables --loud and disables --quiet. --toc-fail-fast | Causes configure to abort if toc_run_failok returns non-zero. - + --toc-debug | Enables debugging output in the configure framework. EOF -# ^^^^ note usage of hard tabs in the cat command! +# ^^^^ note usage of hard tabs in the cat data! + + local help=${TOC_TOPDIR}/toc.${PACKAGE_NAME}.help + test -f $help && { + echo -e "\nHelp options specific to ${PACKAGE_NAME}:\n" + local foo=$(head -1 $help) + local sh=${foo#\#\!} + local hash=${foo%%\!*} + test "x#" = "x$hash" -a "x$hash" != "x$sh" -a "x$sh" != "x" || { + # lookie like no script of some sort. + sh=cat + } + $sh $help + echo "" # just for looks. + } + local help=toc.${PACKAGE_NAME}.help.sh + test -f $help && { + echo "" + echo "Help options specific to this package:" + cat $help + echo "" # just for looks. + } + exit 0 - ;; + ;; # finally end --help --prefix=*) # reserved. VAR=$(echo $arg | sed "s,^--\(.*\)=.*,\1,;") @@ -728,7 +774,7 @@ VAL=$(echo "$arg" | sed "s,^--.*=\(.*\),\1,") VAR=configure_${VAR} ;; - --enable-*|--with-*) + --enable-*|--with-*) # sets configure_with_XXX=1 or configure_enable_XXX=1 VAR=configure_$(echo $arg | sed "s,^--\(.*\),\1,;s,-,_,g") VAL=1 @@ -750,17 +796,15 @@ VAL=0 export $VAR="$VAL" ;; - --*=*) + --*=*) # SOOOOOOO arguable # sets XXX=YYY VAR=$(echo $arg | sed "s,^--\(.*\)=.*,\1,;s,-,_,g") VAL=$(echo $arg | sed "s,^--.*=\(.*\),\1,") - # SOOOOOOO arguable: ;; --*) # this is soooooo arguable # sets XXX=1 VAR=$(echo $arg | sed "s,^--\(.*\),\1,;s,-,_,g;") VAL=1 - # SOOOOOOO arguable: ;; *) toc_boldecho "WARNING: unrecognized option: $arg" @@ -773,6 +817,11 @@ toc_add_config "$VAR=$VAL" } done + + test "x${TOC_PARSEARGS_CALLBACK}" != "x" && { + ${TOC_PARSEARGS_CALLBACK} "${passon[@]}" + return $? + } return 0 } # end parseargs @@ -789,19 +838,17 @@ toc_quietly <<-EOF ${TOC_BOLD_}Emoticon legend:${_TOC_BOLD} - ${TOC_EMOTICON_OKAY} Good news. - ${TOC_EMOTICON_ERROR} Bad news. - ${TOC_EMOTICON_WARNING} A warning, possibly an error, but we - do not yet know if it is fatal. A warning might actually - be an error: this is build tree dependent. + ${TOC_EMOTICON_OKAY} Good News. + ${TOC_EMOTICON_ERROR} Bad News. + ${TOC_EMOTICON_WARNING} A warning, possibly even Bad News, but we do not yet + know if it is fatal: this is build tree dependent. - Note that not all config test failures are fatal: it will stop if - it fails a test which it /needs/ to pass. + Note that not all config test failures are fatal: it will stop if + it fails a test which it /needs/ to pass. EOF # source ${TOC_TOCDIR}/tests/toc_core_tests.sh || { toc_run_fail toc_core_tests || { -# Don't do "toc_run toc_core" because then we don't see the output :/ err=$? echo "Core toc sanity test failed (err=$err). This tree is not toc-capable. ${TOC_EMOTICON_ERROR}" exit $err Index: toconfigure =================================================================== RCS file: /cvsroot/libfunutil/libfunutil/toc/sbin/toconfigure,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- toconfigure 5 Sep 2003 09:32:50 -0000 1.11 +++ toconfigure 27 Sep 2003 22:34:03 -0000 1.12 @@ -58,6 +58,8 @@ toc_add_config_h PACKAGE_VERSION=${PACKAGE_VERSION} toc_add_make PACKAGE_VERSION=${PACKAGE_VERSION} +toc_add_make configure_build_quietly=${build_quietly-0} + # include package-specific configure script. This eases upgrading a project's toc: pkgconfig=${PACKAGE_CONFIGURE_SCRIPT-configure.${PACKAGE_NAME}} test -f $pkgconfig && { @@ -73,12 +75,14 @@ # toc_run_fail toc_configure_finalcheck # toc_configre_finalcheck is arguable :/ + + +# end the configuration process and write out our files... toc_endconfigure | perl -ane '$| = 1; if( ! -f $F[0] ) { print; next; } $fn = $F[0]; $st = $_; $st =~ s|.*\.\.\.\s+||; -# print "\t$F[0]\t\t\t$st"; write; format STDOUT = @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<< |