# Set ACL2 to the acl2 executable in your system. Make sure that the version
# of Acl2 is V1-9. Our script file is not tested with other versions.
ACL2 = /projects/acl2/v2-5-debian-gnu-linux/saved_acl2


# Extension for the compiled object file names.
# For GCL, use "o"
# For Allegro, use "fasl".
EXT=o

INHIBIT = (assign inhibit-output-lst (list (quote prove) (quote proof-tree) (quote warning) (quote observation)))

#  If you define this to be a list of book names (without .lisp or any other
#  suffixes) then you can do `make all' and `make dependencies'.

BOOKS = ihs trivia utils b-ops-aux b-ops-aux-def basic-def proof model table-def basic-lemmas

#  This tells make to expect `suffix rules' for these file suffixes.

.SUFFIXES: .cert .lisp  .date $EXT


#  This rule certifies every book in BOOKS.  If the dependencies are set up
#  correctly then the order of the books in BOOKS won't matter.

all:
	echo '(value :q)' > workxxx
	echo '(with-open-file (str "workyyy" :direction :output) (format str "~a" acl2::*compiled-file-extension*))' >> workxxx
	${ACL2} < workxxx
	rm -f workxxx
	for book in $(BOOKS) ;\
	do \
	make  -f makefile $$book.cert INHIBIT='$(INHIBIT)' EXT=`cat workyyy` ;\
	done 

#  This rule tells how to get <book>.cert from <book>.lisp, either by running
#  Acl2 on the <book>.acl2 file (if it exists) or using the default command
#  to certify at ground zero.

.lisp.cert:
	echo "Making $*.cert on `date`"
	rm -f $*.cert
	date > $*.date
	if  [ -f $*.acl2 ] ; \
	then \
	  $(ACL2) < $*.acl2 > $*.out ; \
	else \
	  echo ':q' > workxxx ; \
	  echo '(lp)' >> workxxx ; \
	  echo '(ld `($(INHIBIT) (certify-book! "$*" 0 $(COMPILE_FLAG))))' >> workxxx ; \
	  $(ACL2) < workxxx > $*.out ; \
	fi
	sleep 1
	ls -al $*.cert 



#  This rule checks to insure that the make was succesful, where success
#  means that the <book>.o file was created.

.date.o: 
	echo 'The make for the book $*.lisp seems to have failed.'
	false


clean: 
	rm -f *.out *.date *.cert *.o *.fasl

#  This rule output the dependency file into ./.dependency.	


# Include dependency file


ihs.cert: ihs.lisp

trivia.cert: trivia.lisp

utils.cert: utils.lisp

b-ops-aux.cert: b-ops-aux.lisp
b-ops-aux.cert: b-ops-aux-def.cert

b-ops-aux-def.cert: b-ops-aux-def.lisp
b-ops-aux-def.cert: trivia.cert
b-ops-aux-def.cert: ihs.cert

basic-def.cert: basic-def.lisp
basic-def.cert: ihs.cert
basic-def.cert: trivia.cert
basic-def.cert: b-ops-aux.cert

proof.cert: proof.lisp
proof.cert: utils.cert
proof.cert: basic-def.cert
proof.cert: model.cert
proof.cert: table-def.cert
proof.cert: basic-lemmas.cert

model.cert: model.lisp
model.cert: utils.cert
model.cert: basic-def.cert

table-def.cert: table-def.lisp
table-def.cert: utils.cert
table-def.cert: basic-def.cert
table-def.cert: model.cert

basic-lemmas.cert: basic-lemmas.lisp
basic-lemmas.cert: utils.cert
basic-lemmas.cert: basic-def.cert
basic-lemmas.cert: model.cert
basic-lemmas.cert: table-def.cert
