|
From: <sg...@us...> - 2003-12-10 19:45:24
|
Update of /cvsroot/libfunutil/libfunutil/toc/sbin
In directory sc8-pr-cvs1:/tmp/cvs-serv14493/toc/sbin
Modified Files:
toc_core.sh toconfigure
Log Message:
mass commit: fixes/changes from toc/s11n/cl trees.
Index: toc_core.sh
===================================================================
RCS file: /cvsroot/libfunutil/libfunutil/toc/sbin/toc_core.sh,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- toc_core.sh 19 Nov 2003 22:15:09 -0000 1.30
+++ toc_core.sh 10 Dec 2003 19:45:20 -0000 1.31
@@ -1,46 +1,54 @@
-# This file is sourced by configure. Do not run it standalone.
+# This file is sourced by configure. Do not run it standalone:
+# it is designed to be sources from the toconfigure script.
+#
# It contains the implementation of the toc API.
#
-
+#
# All global vars defined in this file are, unless otherwise noted,
# considered private - configure is not supposed to touch them
# directly, nor are test scripts.
+#
+# Sourcing this file from anywhere other than toconfigure will have undefined
+# results.
+#
-# Sourcing this file from anywhere other than configure will have undefined
-# results. :/
-
-export prefix=${prefix-${TOC_PREFIX-/usr/local}}
-# prefix will be overridden by the command-line arg --prefix=/path
+########################################################################
+# maintenance notes:
+#
+# vars expected from toconfigure:
+# TOC_HOME - path to toc's top dir
+# TOP_SRCDIR - directory we want to configure from (e.g., top-most
+# dir of a source tree).
TOC_QUIET=${TOC_QUIET-0}
TOC_LOUD=${TOC_LOUD-0}
-TOC_TOPDIR=${TOC_TOPDIR-${PWD}}
-TOC_INCLUDESDIR=${TOC_TOPDIR}/include
-
-TOC_TOCDIR=${TOC_TOPDIR}/toc
-PATH=${TOC_TOCDIR}/bin:${PATH}
-TOC_TESTSDIR=${TOC_TOCDIR}/tests
-TOC_MAKEFILES_DIR=$TOC_TOCDIR/make
+export prefix=${prefix-${TOC_PREFIX-/usr/local}}
+# prefix will be overridden by the command-line arg --prefix=/path
+TOC_INCLUDESDIR=${TOP_SRCDIR}/include
+TOC_TESTSDIR=${TOC_HOME}/tests
+TOC_MAKEFILES_DIR=$TOC_HOME/make
-TOC_ATSIGN_PARSER=$TOC_TOCDIR/bin/atsign_parse # utility to replace @TOKENS_LIKE_THIS_ONE@ in streams.
+TOC_ATSIGN_PARSER=$TOC_HOME/bin/atsign_parse # utility to replace @TOKENS_LIKE_THIS_ONE@ in streams.
TOC_DEBUG=${TOC_DEBUG-0}
TOC_SHARED_MAKEFILE=toc_shared.make
+# TOC_SHARED_MAKEFILE is obsolete, and should Go Away. Use toc.${PACKAGE_NAME}.make.at
+# and ${TOC_HOME}/make/toc.make.at instead.
-declare -a CONFIG_DOT_MAKE_ARRAY # array holds key=val strings for toc_shared.make.at
+declare -a CONFIG_DOT_MAKE_ARRAY # array holds key=val strings for makefiles
declare -a CONFIG_DOT_H_ARRAY # array holds key=val strings for config.h.at
TOC_DELETE_TEMP="test 1 = 1" # set to a false condition to disable deletion of some temp files (for debuggering)
-TOC_TIMESTAMP=${TOC_TOPDIR}/.toc.configtimestamp
+TOC_TIMESTAMP=${TOP_SRCDIR}/.toc.configtimestamp
touch ${TOC_TIMESTAMP}
# TOC_VERBOSE_WARNINGS=${TOC_VERBOSE_WARNINGS-0} # spits out the debug file contents
-#TOC_CACHE=${TOC_TOPDIR}/configure.last
+#TOC_CACHE=${TOP_SRCDIR}/configure.last
#test -f ${TOC_CACHE} && rm ${TOC_CACHE}
# echo $0 $@ >> ${TOC_CACHE}# loses quoted args' quotes
@@ -118,6 +126,11 @@
{
# outputs $@ if ${TOC_QUIET} = 0
# returns 1 if it does not output anything
+ # It it is passed no parameters it reads in from stdin,
+ # thus you can:
+ # toc_quietly <<EOF
+ # blah blah blah
+ # EOF
test "x${TOC_QUIET-0}" != "x0" && return 1
test -n "$1" && {
echo "$@"
@@ -126,10 +139,16 @@
cat
return 0
}
+
function toc_loudly
{
# outputs $@ if ${TOC_LOUD} != 0
# returns 1 if it does not output anything
+ # It it is passed no parameters it reads in from stdin,
+ # thus you can:
+ # toc_loudly <<EOF
+ # blah blah blah
+ # EOF
test "x${TOC_LOUD-0}" = "x0" && return 1
test -n "$1" && {
echo "$@"
@@ -141,13 +160,23 @@
function toc_dump_make_properties
-{ # Dumps the current properties from the makefile array to $1
- propsfile=$1
- i=0
+{ # Dumps the current properties from the makefile array to stdout
+ local i=0
while test $i -lt ${#CONFIG_DOT_MAKE_ARRAY[@]}; do
echo ${CONFIG_DOT_MAKE_ARRAY[$i]}
i=$((i + 1))
- done > $propsfile
+ done
+ return 0
+}
+
+function toc_dump_config_h_properties
+{ # Dumps the current properties from the config.h array to stdout
+ local i=0
+ while test $i -lt ${#CONFIG_DOT_H_ARRAY[@]}; do
+ echo ${CONFIG_DOT_H_ARRAY[$i]}
+ i=$((i + 1))
+ done
+ return 0
}
function toc_get_make
@@ -181,7 +210,7 @@
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"
+ toc_debug toc_get_make "$@": "$arg=$theval"
return $ret
}
@@ -192,63 +221,37 @@
local tmpl=$1
local target=$2
local tmpfile=.toc.atfilter_as_makefile
- toc_dump_make_properties $tmpfile
+ toc_dump_make_properties > $tmpfile
toc_atfilter_file $tmpfile $tmpl $target
local err=$?
rm $tmpfile
return $err
}
+
function toc_create_make
-{ # writes out toc_shared.make using the options set via toc_add_make and creates toc.make
- #echo "Creating ${TOC_SHARED_MAKEFILE} and it's friends... "
+{
+ # todo: completely refactor this func, splitting it up into
+ # several functions.
+ #
+ # Writes out toc_shared.make using the options set via toc_add_make and creates toc.make
+ # echo "Creating ${TOC_SHARED_MAKEFILE} and it's friends... "
+
# set some must-be-set-last vars here:
- toc_add_make TOC_SHARED_MAKEFILE=${TOC_SHARED_MAKEFILE}
- local toc_shared_qmakefile=${TOC_SHARED_MAKEFILE%%.make}.qmake
- toc_add_make TOC_SHARED_QMAKEFILE=${toc_shared_qmakefile}
- TOC_SHARED_MAKEFILE_AT=${TOC_SHARED_MAKEFILE}.at
- toc_add_make TOC_SHARED_MAKEFILE_AT=${TOC_SHARED_MAKEFILE_AT}
- TOC_GENDMAKE_OUT=toc.make
- toc_add_make TOC_MAKEFILE=$TOC_GENDMAKE_OUT # so we can add this to DISTCLEAN :/
+# toc_add_make TOC_SHARED_MAKEFILE=${TOC_SHARED_MAKEFILE}
+# local toc_shared_qmakefile=${TOC_SHARED_MAKEFILE%%.make}.qmake
+# toc_add_make TOC_SHARED_QMAKEFILE=${toc_shared_qmakefile}
+# TOC_SHARED_MAKEFILE_AT=${TOC_SHARED_MAKEFILE}.at
+# toc_add_make TOC_SHARED_MAKEFILE_AT=${TOC_SHARED_MAKEFILE_AT}
+# TOC_GENDMAKE_OUT=toc.make
+# toc_add_make TOC_MAKEFILE=$TOC_GENDMAKE_OUT # so we can add this to DISTCLEAN :/
# create toc.make for everyone who looks like they need it:
#echo "${TOC_GENDMAKE_OUT}: "
+ toc_run_failok toc_make | toc_die $? "Error creating toc.make!"
- local makeprops=${TOC_TOPDIR}/.toc.make.properties.tmp
- toc_dump_make_properties $makeprops
- local tocmakeprops
- for d in $(find ${TOC_TOPDIR} -name Makefile -o -name GNUMakefile | xargs grep -l "^include ${TOC_GENDMAKE_OUT}" ); do
- thedir=${d%%/Makefile}
- cmake=${thedir}/${TOC_GENDMAKE_OUT}
- toc_makerelative $thedir
- relpath=${TOC_MAKERELATIVE}
- cmake=${cmake##$TOC_TOPDIR/} # make it short, for asthetic reasons :/
-# echo "cmake=$cmake relpath=$relpath"
- shortform=${thedir##${PWD}/}
- test "$shortform" = "$PWD" && shortform= # top-most dir
-
- tocmakeprops=${cmake}.props
- cp $makeprops $tocmakeprops
- cat <<EOF >> $tocmakeprops
-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}
-TOC_EMOTICON_ERROR=${TOC_EMOTICON_ERROR}
-EOF
- toc_atfilter_file $tocmakeprops ${TOC_TOCDIR}/make/toc.make.at $cmake || {
- err=$?
- echo "Error creating toc.make!"
- exit $err
- }
- rm $tocmakeprops # >/dev/null 2>&1
- # toc_replace_file $cmake $tmpfile && echo "created" || echo "up to date"
- done
- #echo ${TOC_EMOTICON_OKAY}
- { # .qmake support
+ test 0 = 1 && { # .qmake support
qtat=${toc_shared_qmakefile}.at
test -f "$qtat" && {
toc_atfilter_as_makefile $qtat ${qtat%%.at} || {
@@ -258,12 +261,12 @@
qmakeout=toc.qmake
#echo "$qmakeout: "
- local files=$(find ${TOC_TOPDIR} -name Makefile -o -name "*.qmake" | xargs grep -l "^include(.*$qmakeout.*)" )
+ local files=$(find ${TOP_SRCDIR} -name Makefile -o -name "*.qmake" | xargs grep -l "^include(.*$qmakeout.*)" )
lastdir=
test -n "$files" && for d in $files; do
cmake=${d%/*}/${qmakeout}
- cmake=${cmake##$TOC_TOPDIR/} # make it a relative path, for asthetic reasons :/
+ cmake=${cmake##$TOP_SRCDIR/} # make it a relative path, for asthetic reasons :/
toc_makerelative $d
relpath=${TOC_MAKERELATIVE}
test "$lastdir" = "$cmake" && continue
@@ -277,7 +280,7 @@
include( \$\$TOC_SHARED_QMAKEFILE )
EOF
# echo -n " $cmake ... "
- toc_atfilter_file $tocmakeprops ${TOC_TOCDIR}/make/toc.qmake.at $cmake || {
+ toc_atfilter_file $tocmakeprops ${TOC_HOME}/make/toc.qmake.at $cmake || {
err=$?
echo "Error creating toc.qmake!"
exit $err
@@ -288,40 +291,17 @@
} # test -f "$qtat"
} # end qmake support
- #echo -n "${TOC_SHARED_MAKEFILE##${TOC_TOPDIR}/}: "
+ #echo -n "${TOC_SHARED_MAKEFILE##${TOP_SRCDIR}/}: "
- toc_atfilter_as_makefile ${TOC_SHARED_MAKEFILE_AT} ${TOC_SHARED_MAKEFILE} || {
- toc_die $? "Error filtering ${TOC_SHARED_MAKEFILE_AT}"
- }
+# toc_atfilter_as_makefile ${TOC_SHARED_MAKEFILE_AT} ${TOC_SHARED_MAKEFILE} || {
+# toc_die $? "Error filtering ${TOC_SHARED_MAKEFILE_AT}"
+# }
#set +x
#echo " ${TOC_EMOTICON_OKAY}"
- rm $makeprops
+# rm $makeprops
return 0
} # end function toc_create_make
-function toc_create_config_h
-{ # writes out config.h using the options set via toc_add_make
- local configh=${TOC_INCLUDESDIR}/config.h
- configh=${configh##${TOC_TOPDIR}/}
- local tmpl=$configh.at
- test -f $tmpl || {
- echo "Note: no $tmpl found, so $configh will not be created."
- return 0
- }
-
- local propsfile=.config.h.properties
- local tmpfile=.config.h.tmp
- i=0
- test -f $propsfile && rm $propsfile
- while test $i -lt ${#CONFIG_DOT_H_ARRAY[@]}; do
- echo ${CONFIG_DOT_H_ARRAY[$i]}
- i=$((i + 1))
- done >> $propsfile
- toc_atfilter_file $propsfile $tmpl $configh
- ${TOC_DELETE_TEMP} && test -f $propsfile && rm $propsfile
- return 0
-}
-
{ # function toc_find_in_path: shell function to find an app in a given path
# usage:
@@ -438,14 +418,14 @@
{ # function toc_run test_name [args to pass to test]
- # sources include/configure/test_name.test
- # and returns it's exit code, or 0 on success.
+ # Runs a test and returns it's return code.
#
# If $1 is an existing file, that file is treated
- # as the test, and sourced.
+ # as the test, and sourced, otherwise a lookup
+ # algorithm is used to find test_name.sh.
#
- # Do not call toc_run directly: it is meant to
- # be used by toc_run_*
+ # Normally clients should use toc_run_fail{,ok}
+ # this function.
TOC_CONFIG_LOG=.toc.run.log
TOC_RUN_DEPTH=0
test -f ${TOC_CONFIG_LOG} && rm ${TOC_CONFIG_LOG}
@@ -460,7 +440,9 @@
local desc=
toc_find_test $testname && {
path=${TOC_FIND_RESULT}
- desc=$(sed -ne 's|\#.*toc_run_description.*= *\(.*\)|\1|p' ${TOC_FIND_RESULT});
+ desc=$(sed -ne 's|\#.*toc_run_description.*= *\(.*\)|\1|p;' ${TOC_FIND_RESULT});
+ # note: ^^^ sed expr should end with 'q', but then i can only read the top-most line,
+ # and i like to have a shebang as the top-most line to help out emacs :/
} || {
toc_die 127 toc_run cannot find script for test $testname.
}
@@ -527,16 +509,32 @@
return 0
}
+ function toc_source_test
+ { # sources the given test script and returns it's error code.
+ # it accepts a filename or X, where X resolves to is ${TOC_HOME}/tests/X.sh.
+ local test=$1
+ shift
+ local tmpfile=.toc.${test##*/}.output
+ local sh=${TOC_TESTSDIR}/$test.sh
+ test -f $test && sh=$test
+ 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 "$@"
+ err=$?
+ return $err
+ }
+
function toc_find_failok
{
- # toc_find_failok works like toc_run, but searches for the passed-in app ($1)
- # 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
+ # toc_find_failok works like toc_run_failok, but searches for the app $1
+ # in path ${2-${PATH}}. It returns 1 if it finds no file, else zero.
+ # It "returns" the found file in the global var ${TOC_FIND_RESULT}.
+ local bin="$1"
shift
local path="${@-${PATH}}"
- toc_quietly -n "? find $bin ..."
- toc_find_in_path $bin $path || {
+ toc_quietly -n -e "? find $bin\t"
+ toc_find_in_path $bin "$path" || {
toc_quietly "not found ${TOC_EMOTICON_WARNING}"
return 1
}
@@ -546,28 +544,14 @@
test -n "$str" && echo " $str"
return 0
}
+
function toc_find_fail
- { # See toc_find_failok(), except this one exits on error
+ { # Same as toc_find_failok(), except this one exits on error
toc_find_failok "$@" || toc_die $? toc_find_fail "$@"
return 0
}
- function toc_source_test
- { # sources the given test script and returns it's error code.
- # it accepts a filename or X, where X resolves to is toc/tests/X.sh.
- local test=$1
- shift
- local tmpfile=.toc.${test##*/}.output
- local sh=${TOC_TESTSDIR}/$test.sh
- test -f $test && sh=$test
- 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 "$@"
- err=$?
- return $err
- }
} # end toc_run functions
@@ -588,28 +572,24 @@
# problem which needs to be addressed immediately.
#
#
- local tgt=$1
- local tmp=$2
- #toc_boldecho toc_replace_file $tgt $tmp
+ local tgt="$1"
+ local tmp="$2"
+ toc_debug toc_replace_file $tgt $tmp
test -f "$tmp" || {
echo "toc_replace_file: argument 2 ($2): could not find file."
exit 1
}
- # fstate="created"
- # test -f $tgt && fstate=updated
if test -f "$tgt"; then
if cmp -s "$tgt" "$tmp"; then
toc_debug "toc_replace_file: $tgt is up to date. Deleting $tmp."
#echo "toc_replace_file: $tgt fstate=up to date"
- rm -f $tmp
+ rm -f "$tmp"
return 1
fi
- #fstate=updated
fi
- mv -f $tmp $tgt || {
- toc_die 2 "toc_replace_file error: toc_replace_file: Could not move $tmp to $tgt!"
+ mv -f "$tmp" "$tgt" || {
+ toc_die 2 "toc_replace_file error: toc_replace_file: Could not move [$tmp] to [$tgt]!"
}
- #echo toc_replace_file 2>&1 fstate=$fstate
return 0
}
} # end toc_replace_file
@@ -621,15 +601,15 @@
# It returns !0 only if $TOC_ATSIGN_PARSER throws an error.
# $1 = file containing properties to @-filter.
# $2 = input template (e.g. toc_shared.make.at)
- # $3 = output file (e.g. toc_shared.make). Is only changed if
- # needed, so it is dependency-safe.
+ # $3 = output file (e.g. toc_shared.make). It is only changed if
+ # needed, so it is dependencies-safe.
local pfile="$1"
local tmpl="$2"
local ofile="$3"
test -f "$pfile" || toc_die $? "toc_atfilter_file: \$1: file not found: $pfile"
test -f "$tmpl" || toc_die $? "toc_atfilter_file: \$2: file not found: $tmpl"
local tmpfile=$ofile.tmp.toc_atfilter_file
- ${TOC_ATSIGN_PARSER} -f $pfile < $tmpl > $tmpfile || {
+ ${TOC_ATSIGN_PARSER} -f "$pfile" < "$tmpl" > "$tmpfile" || {
local err=$?
echo "toc_atfilter_file(): @-parsing failed: error $err "
echo ${TOC_EMOTICON_ERROR}
@@ -638,8 +618,8 @@
echo -n "$ofile ... "
fstate="created"
- test -f $ofile && fstate="updated"
- toc_replace_file $ofile $tmpfile || fstate="up to date"
+ test -f "$ofile" && fstate="updated"
+ toc_replace_file "$ofile" "$tmpfile" || fstate="up to date"
echo "$fstate"
return 0
}
@@ -648,34 +628,59 @@
function toc_makerelative
-{ # usage: toc_makerelative /foo/bar/one/two /foo/bar
- # sets global var TOC_MAKERELATIVE to the "return value".
+{ # Makes a relative path from a pair of paths.
+ # Usage: toc_makerelative /foo/bar/one/two /foo/bar
+ # It tries to make a relative path from $1, which must
+ # be a sub-path (or the same as) of $2.
+ # 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 startat="${1-$PWD}"
+ local relto="${2-${TOP_SRCDIR}}"
+ test -n "$relto" || $relto="$PWD"
+ test -f "$startat" && startat="$(dirname $startat)"
local dn=$startat/bogus
- local dn=${dn%*/*}
+ local dn="${dn%*/*}"
local rel="."
while test -n "$dn" -a "$dn" != "$relto" -a "$dn" != "/"; do
rel="$rel/.."
- dn=${dn%*/*}
+ dn="${dn%*/*}"
done
- TOC_MAKERELATIVE=${rel##./}
+ TOC_MAKERELATIVE="${rel##./}"
}
+
+function toc_internal_format_endconfigure
+{
+# internal helper to pretty up some output
+ perl -ane '$| = 1;
+ if( ! -f $F[0] ) { print; next; }
+ $fn = $F[0];
+ $st = $_;
+ $st =~ s|.*\.\.\.\s+||;
+ write;
+format STDOUT =
+ @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<
+$fn, $st
+.
+'
+ # come on... you gotta love perl!
+}
+
function toc_endconfigure
{ # ends the configuration process, processing the files
# which need to be @-parsed
toc_boldecho "==== Creating configuration-dependent files..."
{
- toc_create_config_h
- toc_create_make
+ toc_run_fail toc_make | toc_internal_format_endconfigure
+ toc_run_fail toc_config_h | toc_internal_format_endconfigure
}
local clean="$(ls .toc.* 2> /dev/null)"
- test -n "$clean" && rm $clean
+ test "x$clean" != x && rm $clean
+ echo =========================================================================
+ # maintenance note: the above =====... is formatted to line up with the output
+ # from toc_internal_format_endconfigure
+ return 0
}
function toc_parseargs
@@ -684,9 +689,12 @@
# 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
- local arg="$1"
- shift
+ local configure_args
+ local xtra=
+ echo "$@" | grep -q \\--prefix= || xtra="--prefix=${prefix}"
+# while [ "$#" -gt 0 ]; do
+ for arg in ${xtra} "$@"; do
+# local arg="$1"; shift
passon[${i}]="$arg"
i=$((i + 1))
local VAR=
@@ -721,7 +729,7 @@
EOF
# ^^^^ note usage of hard tabs in the cat data!
- local help=${TOC_TOPDIR}/toc.${PACKAGE_NAME}.help
+ local help=${TOP_SRCDIR}/toc.${PACKAGE_NAME}.help
test -f $help && {
echo -e "\nHelp options specific to ${PACKAGE_NAME}:\n"
local foo=$(head -1 $help)
@@ -815,9 +823,11 @@
toc_debug "toc_parseargs: exporting [$VAR]=$VAL"
export $VAR="$VAL"
toc_add_config "$VAR=$VAL"
+# foo=$(echo $VAL | sed -e "s,',\\\\',g")
+ configure_args="$configure_args --$VAR=\"$VAL\""
}
done
-
+ toc_add_config CONFIGURE_ARGUMENTS="$configure_args" # <---- !!!!experimental!!!!
test "x${TOC_PARSEARGS_CALLBACK}" != "x" && {
${TOC_PARSEARGS_CALLBACK} "${passon[@]}"
return $?
@@ -829,7 +839,9 @@
# We do some initial sanity checking here,
# but any tree-specific checks must be done from configure.
-toc_parseargs --prefix=${prefix} "$@"
+toc_parseargs "$@"
+toc_get_make prefix || toc_add_config prefix=${prefix}
+
toc_loudly 'Loud mode enabled.'
toc_source_test toc_tests_help || exit 0
@@ -847,7 +859,7 @@
it fails a test which it /needs/ to pass.
EOF
-# source ${TOC_TOCDIR}/tests/toc_core_tests.sh || {
+# source ${TOC_HOME}/tests/toc_core_tests.sh || {
toc_run_fail toc_core_tests || {
err=$?
echo "Core toc sanity test failed (err=$err). This tree is not toc-capable. ${TOC_EMOTICON_ERROR}"
Index: toconfigure
===================================================================
RCS file: /cvsroot/libfunutil/libfunutil/toc/sbin/toconfigure,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- toconfigure 27 Sep 2003 22:34:03 -0000 1.12
+++ toconfigure 10 Dec 2003 19:45:20 -0000 1.13
@@ -1,5 +1,7 @@
-#!/bin/bash
-# Top-level config script, "toc" style.
+#!/do/not/bash
+# Source tree configure script, toc-style.
+# The latest code is at http://toc.sourceforge.net/
+#
# Do not run this directly: wrap it up in a script called 'configure',
# stick it into your top-level build tree, set some environment vars,
# and source it. See the configure from the toc distribution for a
@@ -15,7 +17,7 @@
# Notes about this configure process:
# Project-wide vars are currently defined in:
# - this file
-# - project_globals.make.at
+# - toc.${PACKAGE_NAME}.make.at
# - And check the top-level Makefile, to be certain :/
#
#
@@ -25,9 +27,11 @@
#
# This tool still requires quite a few things, but it will not aim to be all things
# to all projects. Customize as you see fit.
+#
+# Note: there are no guarantees that any exit codes mean anything specific!
test -z "${PACKAGE_VERSION}" -a -z "${PACKAGE_NAME}" && {
- echo "toconfigure: environment vars PACKAGE_NAME and PACKAGE_VERSION must be set"
+ echo "toconfigure: environment vars PACKAGE_NAME and PACKAGE_VERSION must be set."
exit 1
}
configure=configure
@@ -36,34 +40,46 @@
exit 2
}
-grep -q "toc[_/]" $configure || {
+grep -i "toc" $configure > /dev/null || {
# this is kind of a callback, actually, since we should only be
# sourced from configure.
echo "Your configure script does not appear to be toc-aware. It shouldn't be sourcing this file."
exit 3
}
+TOP_SRCDIR=${PWD}
+TOC_HOME=${TOC_HOME-"${TOP_SRCDIR}/toc"}
+
+test -d "${TOC_HOME}" || {
+ echo "The toc home directory, TOC_HOME, not found. Set that variable to the top-most path to your toc installation, or unset it to use the default of ./toc"
+ exit 4
+}
+export TOP_SRCDIR
+export TOC_HOME
+export PATH=${TOC_HOME}/bin:${PATH}
+
{ # set up the core
# todo: implement toc_find_in_path() here so we can use it to find toc_core.sh
# for now assume we must source it from $(top_srcdir).
- CORE_SH=toc/sbin/toc_core.sh
+ CORE_SH=${TOC_HOME}/sbin/toc_core.sh
source ${CORE_SH} "$@" || { # core toc functions and initial sanity test
- echo "toconfigure: Pain! Suffering! Loading toc_core.sh failed!"
- exit 4
+ echo "toconfigure: Pain! Suffering! Loading ${CORE_SH} failed!"
+ exit 5
}
}
-toc_add_config_h PACKAGE_NAME=${PACKAGE_NAME}
-toc_add_make PACKAGE_NAME=${PACKAGE_NAME}
-toc_add_config_h PACKAGE_VERSION=${PACKAGE_VERSION}
-toc_add_make PACKAGE_VERSION=${PACKAGE_VERSION}
-
+toc_add_config PACKAGE_NAME="${PACKAGE_NAME}"
+toc_add_config PACKAGE_VERSION="${PACKAGE_VERSION}"
+toc_add_config TOC_HOME="${TOC_HOME}"
toc_add_make configure_build_quietly=${build_quietly-0}
+toc_add_make TOC_EMOTICON_OKAY=${TOC_EMOTICON_OKAY}
+toc_add_make TOC_EMOTICON_ERROR=${TOC_EMOTICON_ERROR}
+toc_add_make TOC_EMOTICON_WARNING=${TOC_EMOTICON_WARNING}
# include package-specific configure script. This eases upgrading a project's toc:
pkgconfig=${PACKAGE_CONFIGURE_SCRIPT-configure.${PACKAGE_NAME}}
test -f $pkgconfig && {
- . $pkgconfig
+ source $pkgconfig
err=$?
test $err -eq 0 || {
echo "toconfigure: error: $pkgconfig returned [non-zero] error code $err."
@@ -71,25 +87,29 @@
}
}
# toc_run_failok toc_project_makefile "Looking for toc.${PACKAGE_NAME}.make"
-toc_add_make SHELL=$(which bash)
+toc_add_config SHELL=$(which bash)
# 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+||;
- write;
-format STDOUT =
- @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<
-$fn, $st
-.
-'
-# come on... you gotta love perl!
+
+##### end the configuration process and write out our files...
+toc_endconfigure
+
+
+# if $POSTCONFIG exists it is run as our final step:
+POSTCONFIG=${TOP_SRCDIR}/postconfig.${PACKAGE_NAME}
+test -f ${POSTCONFIG} && {
+ source ${POSTCONFIG} || {
+ err=$?
+ echo "${POSTCONFIG} returned non-zero exit status: $?"
+ return $err
+ }
+}
+
+package_configure=${TOP_SRCDIR}/toc.${PACKAGE_NAME}.configure.make
+toc_dump_make_properties | perl -pe 's|^(\w+)=|$1 = |' > ${package_configure}
cat <<-EOF
=========================================================================
@@ -97,6 +117,5 @@
Be sure to read any messages from the tests run by configure.
=========================================================================
EOF
- # note the intentional use of hard tabs in the cat <<-EOF, above.
+# ^^^^ note the intentional use of hard tabs in the cat <<-EOF, above.
-# call toc_endconfigure to finalize the generated makefile and config.h
|