

######################################################################
## NOTE.  This file is not part of the standard ACL2 books build
## process; it is part of an experimental build system that is not yet
## intended, for example, to be capable of running the whole
## regression.  The ACL2 developers do not maintain this file.
##
## Please contact Jared Davis <jared@cs.utexas.edu> or Sol Swords
## <sswords@cs.utexas.edu> with any questions/comments.
######################################################################

# Copyright 2008 by Jared Davis and Sol Swords.
# Credit to Matt Kaufmann and J Strother Moore for code from Makefile-generic.


# This makefile is designed to support file-level dependencies among
# ACL2 books.  The make-all-deps.sh script produces a dependency file
# called Makefile-alldeps reflecting the dependencies among all the
# libraries that support this scheme.


all:

Makefile-alldeps:
	@echo "Running make-all-deps.sh" ;\
	bash make-all-deps.sh ;

include Makefile-alldeps

all: $(BOOKS)

%.cert: %.lisp
	@echo "Making `pwd`/$*.cert on `date`" ;\
	DIR=`dirname $*` ;\
	FILE=`basename $*` ;\
        ACL2=`which $(ACL2)` ;\
	cd $$DIR ;\
	rm -f $$FILE.cert ;\
	echo '(acl2::value :q)' > workxxx.$$FILE ;\
	echo '(in-package "ACL2")' >> workxxx.$$FILE ;\
	echo '(acl2::lp)' >> workxxx.$$FILE ;\
	echo '$(INHIBIT)' >> workxxx.$$FILE ;\
	if [ -f $$FILE.acl2 ] ;\
	then \
	  cat $$FILE.acl2 >> workxxx.$$FILE ;\
	elif [ -f cert.acl2 ] ;\
	then \
	  cat cert.acl2 >> workxxx.$$FILE ;\
	  echo "" >> workxxx.$$FILE ;\
	  echo "(certify-book \"$$FILE\" ? t)" >> workxxx.$$FILE ;\
	else \
	  echo "" >> workxxx.$$FILE ;\
	  echo "(certify-book! \"$$FILE\" 0 t)" >> workxxx.$$FILE ;\
	fi ;\
	echo "" >> workxxx.$$FILE ;\
	echo '(acl2::value :q)' >> workxxx.$$FILE ;\
	echo '(acl2::exit-lisp)' >> workxxx.$$FILE ;\
	($$ACL2 < workxxx.$$FILE 2>&1) > $$FILE.out ;\
	rm -f workxxx.$$FILE ;\
	((test -f $$FILE.cert) && (ls -al $$FILE.cert)) || (echo "**CERTIFICATION FAILED** for `pwd`/$$FILE.lisp" ; exit 1)



%.lisp:
	@echo "Trying to generate $*.lisp" ;\
	DIR=`dirname $*` ;\
	FILE=`basename $*` ;\
	cd $$DIR ;\
	$(MAKE) $$FILE.lisp
