#!/bin/sh
# Test handling of compilations of files in remote directories.

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

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

make clean
say original	# Make sure standard C compiler behaves as expected.

cc -c source-here/newfile1.c
cc -c source-here/oldfile1.c

cd compile-here
cc -c ../source-here/newfile2.c
cc -c ../source-here/oldfile2.c

cc -o executable ../newfile1.o ../oldfile1.o newfile2.o oldfile2.o main.c
executable > orig.log
cd ..


say GCT

gct-init $GCTLIB
gct -B$GCTLIB -c source-here/newfile1.c
gct -B$GCTLIB -c source-here/oldfile1.c
cc -c -I. source-here/oldfile1.c


cd compile-here
gct -B$GCTLIB -test-dir .. -c ../source-here/newfile2.c
gct -B$GCTLIB -test-dir .. -c ../source-here/oldfile2.c
cc -c -I.. ../source-here/oldfile2.c

gct -B$GCTLIB -test-dir .. -o executable ../newfile1.o ../oldfile1.o \
	newfile2.o oldfile2.o main.c
grestore -test-dir ..

executable > new.log ; diff orig.log new.log

ROOT=`echo pwd | sh`
greport -all -test-dir .. GCTLOG | sed "s=$ROOT=ABSOLUTE=" > report.log
diff report.log ../report.ref

exit 0


