#! /bin/echo this_file_should_be_sourced,_not_executed # -*- Mode: Shell-script -*- # ---------------------------------------------------------------------- # defs --- define the environment for autogen tests. # # Time-stamp: "2007-07-04 10:12:38 bkorb" # Author: Bruce Korb # Last Modified: $Date: 2007/07/04 21:36:39 $ ## ## This file is part of AutoOpts, a companion to AutoGen. ## AutoOpts is free software. ## AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved ## ## AutoOpts is available under any one of two licenses. The license ## in use must be one of these two and the choice is under the control ## of the user of the license. ## ## The GNU Lesser General Public License, version 3 or later ## See the files "COPYING.lgplv3" and "COPYING.gplv3" ## ## The Modified Berkeley Software Distribution License ## See the file "COPYING.mbsd" ## ## These files have the following md5sums: ## ## 239588c55c22c60ffe159946a760a33e pkg/libopts/COPYING.gplv3 ## fa82ca978890795162346e661b47161a pkg/libopts/COPYING.lgplv3 ## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd # # $Id: defs.in,v 1.13 2007/07/04 21:36:39 bkorb Exp $ # ---------------------------------------------------------------------- progname=`echo "$0" | sed 's,^.*/,,'` testname=`echo "$progname" | sed 's,\..*$,,'` export progname testname # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # C O N F I G U R E D V A L U E S # # Make sure srcdir is an absolute path. Supply the variable # if it does not exist. We want to be able to run the tests # stand-alone!! # srcdir=`cd "@srcdir@" && pwd ` top_srcdir=`cd "@top_srcdir@" && pwd` GUILE_VERSION="@GUILE_VERSION@" LIBGUILE_PATH="@LIBGUILE_PATH@" AG_VERSION="@AG_VERSION@" GREP="@GREP@" EGREP="@EGREP@" FGREP="@FGREP@" test -z "${CFLAGS}" && CFLAGS="@DEFS@ @CFLAGS@" test -z "${CPPFLAGS}" && CPPFLAGS="@CPPFLAGS@" test -z "${testsubdir}" && testsubdir=@testsubdir@ test -z "${CC}" && { CC="@CC@" test -z "${CC}" && echo "No CC configured" && exit 1 } SHELL="@SHELL@" AGexe="@AGexe@" d=`dirname ${AGexe}` f=`basename ${AGexe}` AGexe=`cd ${d} && pwd`/${f} GDexe="@GDexe@" d=`dirname ${GDexe}` f=`basename ${GDexe}` GDexe=`cd ${d} && pwd`/${f} CLexe="@CLexe@" d=`dirname ${CLexe}` f=`basename ${CLexe}` CLexe=`cd ${d} && pwd`/${f} builddir=`pwd` top_builddir=`cd ../.. && pwd` CFLAGS=`echo ${CFLAGS} | sed 's/-Werror//'` if test ${GUILE_VERSION} -gt 107000 then case ${AG_VERSION} in *pre* ) GUILE_WARN_DEPRECATED=detailed ;; * ) GUILE_WARN_DEPRECATED=no ;; esac export GUILE_WARN_DEPRECATED fi LIB='@AG_LDFLAGS@ @LDFLAGS@ @LIBGUILE_LIBS@' test -f /usr/lib/libgen.so && { case "${LIB}" in *-lgen* ) : ;; * ) LIB="${LIB} -lgen" ;; esac } INC="@LIBGUILE_CFLAGS@" export CC GUILE_VERSION LIBGUILE_PATH AG_VERSION AGexe GDexe CLexe # If only the "rm(1)" command could be relied upon.... # purge() { rm -rf ${*} 2>/dev/null bad='' for f do test -f ${f} -o -d ${f} && bad="${bad} ${f}" done test -z "$bad" && return 0 set -- $bad test "x${RANDOM}" = "x${RANDOM}" && RANDOM=`expr 0${RANDOM} + 1 2>/dev/null` f=ZZPURGE-${1}-${RANDOM}-$$ if test $# -gt 1 then mkdir ${f} mv $* ${f}/. else mv $1 ${f} fi } be_silent() { setx=: VERBOSE=false purge testdir # Sometimes, MSDos FS cannot even rename the directory!! # if test -d testdir then purge testdir/* testdir/.??* else msg=echo mkdir testdir || exit 1 fi } be_verbose() { setx='set -x' msg=: VERBOSE=true test -d testdir || mkdir testdir || exit 1 # exec > testdir/${testname}.log 2>&1 } case "$-" in *x*) be_verbose ;; *) case "${VERBOSE}" in '' | [Nn]* | 0 | [Ff]* ) be_silent ;; *) be_verbose ;; esac ;; esac exec 8>&2 1>testdir/${testname}.log 2>&1 set -x lo_dir=${top_builddir}/autoopts test -d ${lo_dir}/.libs && lo_dir=${lo_dir}/.libs LD_LIBRARY_PATH=${lo_dir}:${LIBGUILE_PATH}:${LD_LIBRARY_PATH-/dev/null} LIB=`echo ${lo_dir}/libopts.a ${lo_dir}/libguileopts.a ${LIB}` export LD_LIBRARY_PATH # A standard failure function # failure() { ${setx} if test -d ../FAILURES then ( \cd ../FAILURES ; purge -rf ${testname}* .*${testname}* ) else mkdir ../FAILURES ; fi set +x exec > /dev/null 2>&8 cat ${testname}.log >&2 cd ${testsubdir} ( mv -f ${testname}* .*${testname}* ../FAILURES || : ) 2>/dev/null for f in core* do test -f ${f} && mv -f ${f} ../FAILURES/${testname}-${f} ; done echo FAILURE: "$*" >&8 exit 1 } cleanup() { ${setx} if ${VERBOSE} ; then : ; else cd ${builddir} purge testdir test -d testdir && mv testdir ZZJUNK-$$ fi ${msg} ${testname} done } compile() { ${setx} test "X${Csrc}" = "X" && Csrc="${testname}" test "X${Cexe}" = "X" && Cexe="${Csrc}" test "X${Dnam}" = "X" && Dnam="${testname}" d=`echo TEST_TEST_${Dnam}_OPTS | tr '[a-z]-' '[A-Z]_'` cc_cmd="${CC} ${CFLAGS} -D$d ${INC} -o ${Cexe} ${Csrc}.c ${LIB}" eval ${cc_cmd} || \ failure cannot compile ${Csrc}.c if test $# -gt 0 then ./${Cexe} ${*} > ${Csrc}.help || \ failure cannot obtain help output for ${Csrc} fi Csrc='' Cexe='' Dnam='' } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # cd testdir || { echo "Cannot make or change into testdir" >&8 exit 1 } testsubdir=`pwd` dirs=` for f in ${top_builddir} ${top_srcdir} do for d in . autoopts agen5 do (cd $f/$d && pwd) done done | sort -u | sed 's/^/-I/'` INC=`echo ${dirs}`" ${CPPFLAGS} ${INC} " f=`\cd ${LIBGUILE_PATH}/../bin && pwd` PATH=${top_builddir}/columns:${f}:${PATH} stdopts=${srcdir}/stdopts.def # All the tests will require the templates in the autoopts dir. # AG_L="${AGexe} -L`cd ${srcdir}/..;pwd`" # In general, they will have a test main procedure, too. # test_main=yes use_flags=true : "=== Running $progname for ${testname} using ${SHELL=sh} ===" chmod +w * > /dev/null 2>&1 || : export SHELL case "$-" in *x*) SHELLX="${SHELL} -x" ;; * ) SHELLX="${SHELL}" ;; esac ## Local Variables: ## Mode: shell-script ## indent-tabs-mode: nil ## sh-indentation: 2 ## sh-basic-offset: 2 ## End: # defs.in ends here