#!/bin/sh

# Note:  use sed to strip blanks because not all systems have same version
# of diff.

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

# This is conveniently changed to 'mv' when the tests change.
DIFF=diff

make clean

gct-init $GCTLIB
gct -B$GCTLIB -o executable \
  main.c dir1/1A/prog1A.c dir1/1B/prog1B.c dir1/Uuninst.c dir2/2A/prog2A.c\
  dir2/2B/prog2B.c  dir2/2B/Luninst.c

executable > exec.log
$DIFF exec.log exec.ref

for i in `find . -type d -print`
do
  echo SUMMARY FOR DIRECTORY $i > $i/SUMMARY.LOG
  gsummary -files -vf "$i/.*" GCTLOG >> $i/SUMMARY.LOG
  $DIFF $i/SUMMARY.LOG $i/SUMMARY.ref
done

for i in `find . -type d -print`
do
  echo SUMMARY FOR DIRECTORY $i > $i/SUMMARY2.LOG
  gsummary -r -vf "$i/.*" GCTLOG >> $i/SUMMARY2.LOG
  $DIFF $i/SUMMARY2.LOG $i/SUMMARY2.ref
done

for i in `find . -type d -print`
do
  echo SUMMARY FOR DIRECTORY $i > $i/SUMMARY3.LOG
  gsummary -vf "$i/.*" GCTLOG >> $i/SUMMARY3.LOG
  $DIFF $i/SUMMARY3.LOG $i/SUMMARY3.ref
done



for i in `find . -type d -print`
do
  echo REPORT FOR DIRECTORY $i > $i/REPORT.LOG
  greport -all -vf "$i/.*" GCTLOG >> $i/REPORT.LOG
  $DIFF $i/REPORT.LOG $i/REPORT.ref
done

# Use short names for System V old filesystem.

for i in `find . -name "*.c" -print`
do
  echo REPORT FOR FILE $i > $i.L
  greport -all -vf "$i" GCTLOG >> $i.L
  $DIFF $i.L $i.r
done

exit 0
