#!/bin/sh
if [ "x$GCTLIB" = "x" ]
then
  GCTLIB=`pwd`/../..
  PATH=.:`pwd`/../..:$PATH
fi

say()
{
	echo "$INDENT" " $1"
}

#  This compiles files but throws away stupid copyright messages that 
#  some C compilers spit to stderr.  
#  It also strips warnings from the RS/6000 compiler, which is uniquely
#  picky and complains about macro redefinitions even if the new value is
#  the same as the old value.
hush_cc()
{
  cc $* 2> /tmp/Gerr$$
  grep -v 'Copyright (C)' /tmp/Gerr$$ | grep -v "has been redefined" 1>&2
  rm /tmp/Gerr$$
}


make clean
echo $INDENT "NOTE:  On some machines, expect assembler warnings like 'cannot"
echo $INDENT "NOTE:  resolve tag _rtx_def'"

say list-utilities
hush_cc -c -I$GCTLIB -I$GCTLIB/config gct-util-tst.c 
hush_cc -c -DTEST -I$GCTLIB -I$GCTLIB/config $GCTLIB/gct-util.c 
hush_cc gct-util-tst.o gct-util.o 
a.out

say transformation-utilities
hush_cc -c -g -I$GCTLIB -I$GCTLIB/config tbuild.c 
hush_cc -c -g -DTEST -I$GCTLIB -I$GCTLIB/config $GCTLIB/gct-util.c 
hush_cc -c -g -DTEST -I$GCTLIB -I$GCTLIB/config $GCTLIB/gct-tbuild.c 
hush_cc tbuild.o gct-util.o gct-tbuild.o
a.out

# say mapfile
# hush_cc -c -g -I$GCTLIB -I$GCTLIB/config mapfile-test.c 
# hush_cc -c -g -DTEST -I$GCTLIB -I$GCTLIB/config $GCTLIB/gct-mapfil.c 
# hush_cc -c -g -DTEST -I$GCTLIB -I$GCTLIB/config $GCTLIB/gct-util.c 
# hush_cc mapfile-test.o gct-mapfil.o gct-util.o
# a.out
# diff Mapfile.log Mapfile.ref


exit 0
