#! /bin/sh
#
#make-all: make all systems afresh
#   make-all     		-- builds and keeps all databases
#   make-all delete		-- builds all databases then deletes them
#   for testing only: removes all databases except the Pure one: isa/BASE
#
#Standard output of Make goes to BASE.log on the subdirectories
#
#Can redirect standard output and error like this, or use "batch" command
#    make-all >log 2>errors &
#
echo 'FULL REBUILD OF ISABELLE. (Date and directory follow)'
date
pwd

case $1 in
    delete) echo 'Databases will be deleted';;
    *)      echo 'Databases will be kept';;
esac

#remove all databases to force rebuild (and to free disc space)
rm BASE FOL/BASE CTT/BASE LK/BASE LK/set/BASE HOL/BASE 

echo;echo;echo '*****Pure Isabelle*****'
make > BASE.log 

echo;echo;echo '*****First-Order Logic (FOL)*****'
(cd FOL;  make > BASE.log)

echo;echo;echo '*****Constructive Type Theory (CTT)*****'
(cd CTT;  make > BASE.log)

case $1 in
    delete) rm FOL/BASE CTT/BASE 
esac

echo;echo;echo '*****Classical Sequent Calculus (LK)*****'
(cd LK;  make > BASE.log)

echo;echo;echo '*****Set theory (LK/set)*****'
(cd LK/set;  make > BASE.log)

case $1 in
    delete) rm LK/BASE LK/set/BASE
esac

echo;echo;echo '*****Higher-Order Logic (HOL)*****'
(cd HOL;  make > BASE.log)

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


case $1 in
    delete) rm BASE HOL/BASE 
esac
