#! /bin/echo this_file_should_be_sourced,_not_executed
#  -*- Mode: Shell-script -*-
# ----------------------------------------------------------------------
# defs --- define the environment for autogen tests.
#
# Author:         Bruce Korb <bkorb@gnu.org>
# Maintainer:     Bruce Korb <bkorb@gnu.org>
# Created:        Fri Mar 27 21:15:30 1998
# Last Modified:  $Date: 2005/12/09 20:13:50 $
#            by: bkorb
# ----------------------------------------------------------------------
# $Id: defs.in,v 4.2 2005/12/09 20:13:50 bkorb Exp $
# ----------------------------------------------------------------------

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
#  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 "." && pwd `
top_srcdir=`cd "../.." && pwd`
CC="/opt/intel/cc/9.0/bin/icc"
GUILE_VERSION="106007"
LIBGUILE_PATH="/local/lib"
AGexe="/home/bkorb/ag/ag/agen5/autogen"
GDexe="/home/bkorb/ag/ag/getdefs/getdefs"
CLexe="/home/bkorb/ag/ag/columns/columns"
AG_VERSION="5.8"

builddir=`pwd`
top_builddir=`cd ../.. && pwd`

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

lo_dir=${top_builddir}/autoopts
test -d ${lo_dir}/.libs && lo_dir=${lo_dir}/.libs
LD_LIBRARY_PATH=${lo_dir}:${LD_LIBRARY_PATH-/dev/null}
export LD_LIBRARY_PATH

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

progname=`echo "$0" | sed 's,^.*/,,'`
testname=`echo "$progname" | sed 's,\..*$,,'`
testsubdir=${testsubdir-testdir}

export progname testname testsubdir
exec 9>&2

test -d ${testsubdir} || mkdir ${testsubdir}
cd ${testsubdir} || {
  echo "Cannot make or change into ${testsubdir}"
  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/`

CFLAGS=`echo ${CFLAGS} ${dirs}`

# User can set VERBOSE to prevent output redirection
case x$VERBOSE in
  xNO* | xno* | x0 | x | xf* )
    rm -rf * .[!.]*
    logf=${testname}-out.log
    exec 2> ${testname}-out.log 1>&2
    VERBOSE=false
    ;;

  x* )
    set -x
    : VERBOSE is ${VERBOSE}
    VERBOSE=true
    ;;
esac

echo "=== Running $progname"
chmod +w * > /dev/null 2>&1 || :

# A standard failure function
failure()
{
  test -d ${builddir}/FAILURES || mkdir ${builddir}/FAILURES
  cd ${testsubdir}
  l=`ls -d ${testname}* .${testname}*` 2>/dev/null
  test -n "${l}" && {
    ( \cd ${builddir}/FAILURES
      rm -rf $l ) 2>/dev/null
    mv -f ${l} ${builddir}/FAILURES
  }
  echo FAILURE: "$*"
  exit 1
}

cleanup()
{
  if ${VERBOSE}
  then : ; else
    cd ${builddir}
    rm -rf ${testsubdir}
  fi
  echo ${testname} done
}
# defs ends here
