#! /bin/sh
#
#make-all: make all systems afresh
#
#Modify these two variables for your local installation
#
DBASES=/homes/lcp/dbases	#directory to hold Poly/ML databases
IMAGES=/homes/lcp/images	#directory to hold New Jersey images

# process command line switches
DEL="off";
for A in $*
do
	case $A in
	-d)	DEL="on" ;;
	-poly)	COMP="Poly"
		MAKEFILE="Makefile"
		DESTDIR=$DBASES ;;
	-nj)	COMP="NJ" 
		MAKEFILE="Makefile.NJ"
		DESTDIR=$IMAGES ;;
	*)	echo "Bad flag for make-all: $A"
		echo "Usage:  make-all [ -d ] [ -poly | -nj ]"
		exit ;;
	esac
done
echo delete=$DEL '      '   Compiler=${COMP?'No compiler specified'}

#remove all images to force rebuild
(cd $DESTDIR;  rm Pure FOL CTT LK LK-set HOL)

echo
echo
echo '*****Pure Isabelle*****'
make -f $MAKEFILE > $COMP.log 

echo
echo
echo '*****First-Order Logic (FOL)*****'
(cd FOL;  make -f $MAKEFILE test > $COMP.log)

echo
echo
echo '*****Constructive Type Theory (CTT)*****'
(cd CTT;  make -f $MAKEFILE test > $COMP.log)

case $DEL in
    on)	rm $DESTDIR/FOL $DESTDIR/CTT
esac

echo
echo
echo '*****Classical Sequent Calculus (LK)*****'
(cd LK;  make -f $MAKEFILE test > $COMP.log)

echo
echo
echo '*****Set theory (LK/set)*****'
(cd LK/set;  make -f $MAKEFILE test > $COMP.log)

case $DEL in
    on)	rm $DESTDIR/LK $DESTDIR/LK-set
esac

echo
echo
echo '*****Higher-Order Logic (HOL)*****'
(cd HOL;  make -f $MAKEFILE test > $COMP.log)

echo
echo
echo '*****Log file lines containing the word "error"*****'
#   Look at standard error also!
grep -i error $COMP.log FOL/$COMP.log CTT/$COMP.log LK/$COMP.log LK/set/$COMP.log HOL/$COMP.log 

case $DEL in
    on)	rm $DESTDIR/Pure $DESTDIR/HOL
esac
