#!/bin/sh

if [ "x$GCTLIB" = "x" ]
then
  GCTLIB=`pwd`/../../../..
  PATH=.:`pwd`/../../../..:$PATH
  export PATH
fi


exit_on_error()
{
  if [ 0 != $? ]
  then
	echo "FAILURE: Component failed, so stopping rest of test."
	exit 1
  fi
}

# Make initial version.

make clean

gct-init $GCTLIB
make "CC=gct -B$(GCTLIB) -test-nolink" executable1 executable2 >> MAKELOG
exit_on_error

if [ -f executable1 -o -f executable2 ]
then
	echo "FAILURE:  executables made too early."
fi
make "CC=gct -B$(GCTLIB)" executable1 executable2 >> MAKELOG
exit_on_error

executable1 > 1.run1.log; diff 1.run1.log 1.run1.ref
executable2 > 2.run1.log; diff 2.run1.log 2.run1.ref

greport -all GCTLOG > both.rep1.log; diff both.rep1.log both.rep1.ref
gsummary GCTLOG > both.sum1.log; diff both.sum1.log both.sum1.ref

exit 0
