# Usage:
#  make cons-<prg>
# to run the consumer side, ie. disassemble Grail prg, generate .thy files out
# of them and feed them through isabelle, using a pre-built heap for
# Grail prg logic, datatype representations etc.
# 
# Example:
#   make cons-Append
#
# ---------------------------------------------------------------------------

#GF=${HOME}/mrg-working/progs/Grail/gf/src/gf
#HEAP=${HOME}/isabelle/heaps/polyml-4.1.3_x86-linux/VCG_LRT2 

PROGHOME=../../../..
GF=${PROGHOME}/Grail/gf/src/gf
ISABELLE=isabelle
IMG_NAME=VCG_LRT2 
# this is where I keep my local Heap image -- HWL
#HEAP=${HOME}/isabelle/heaps/polyml-4.1.3_x86-linux/$(IMG_NAME)
HEAP=/tmp/isabelle/$(IMG_NAME)

URL=ftp://ftp.macs.hw.ac.uk/pub/gph/hwloidl

cons-%: %.class $(HEAP)
	$(GF) -t VCG $<
	echo "use_thy \"$(subst .class,Certificate3,$<)\"" > ROOT.ML
	$(ISABELLE) -r $(HEAP) DUMMY < ROOT.ML

$(HEAP):
	@echo "Downloading image from $(URL)"
	-if [ ! -d `dirname $(HEAP)` ] ; then mkdirhier `dirname $(HEAP)` ; fi
	wget --output-document=$(HEAP) $(URL)/$(IMG_NAME)

clean:
	-rm *.class *.thy *.lfd *.constraints ROOT.ML *~ *^
