# 
# The LOOP Project
# 
# The LOOP Team, Dresden University and Nijmegen University
# 
# Copyright (C) 2002
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License in file COPYING in this or one of the
# parent directories for more details.
# 
# created by Hendrik 24.10.00
# 
# Time-stamp: <Monday 8 October 01 17:58:00 tews@ithif51>
# 
# Makefile for the ccsl compiler
# 
# $Id: GNUmakefile,v 1.22 2002/07/18 13:43:19 tews Exp $
# 


include ../Common/CommonMakefile

INCLUDECOMMON=-I ../Common

OBJECTS= \
	names.cmo \
	classtypes.cmo \
	types_util.cmo ccsl_pretty.cmo \
	symbol.cmo lifting.cmo variance.cmo \
	\
	morphism.cmo \
	pre_printing.cmo \
	theory_class.cmo interface_theory.cmo \
	methodinv_theory.cmo \
	bisim_theory.cmo semantics_theory.cmo \
	morphism_theory.cmo \
	full_liftings_theory.cmo \
	class_theorems_theory.cmo \
	adt_theory.cmo \
	sig_theory.cmo \
	\
	iface_class.cmo member_class.cmo \
	substitution.cmo \
	parser.cmo lexer.cmo \
	abstract_lexer.cmo ccsl_hashkeys.cmo grammar.cmo \
	\
	emptytype_theory.cmo \
	\
	inherit.cmo resolution.cmo newtypecheck.cmo behavioural.cmo \
	component_pass.cmo feature.cmo class_methods.cmo \
	attribute_pass.cmo \
	\
	main.cmo

NATIVE=$(OBJECTS:.cmo=.cmx)

all: clearrun run

run: $(LOOPLIB) $(OBJECTS)
	$(OCAMLC) $(COMPFLAGS) -o run unix.cma $(LOOPLIB) $(OBJECTS) 

ccslc: run
	mv run ccslc

native: $(LOOPLIBX) $(NATIVE)
	$(OCAMLOPT) -o native_run $(OPTCOMPFLAGS) \
		unix.cmxa $(LOOPLIBX) $(NATIVE) 

ccslc.opt: native
	mv native_run ccslc.opt

# top: $(IFACE) $(OBJECTS)
# 	  $(OCAMLMKTOP) -o toplevel $(OBJECTS)

ccsl_hashkeys.ml ccsl_hashkeys.mli: $(HASHKEYS) grammar.mly
	$(HASHKEYS) -size 29 -o ccsl grammar.mly

TAGS.local:
	$(OTAGS) . -o TAGS.prelocal
	$(ETAGS) -l yacc -o yacc.etags *mly 
	$(CATTAGS) TAGS.prelocal yacc.etags > TAGS.local

depend::
	cd ../Common; $(MAKE) depend

clearrun:
	rm -f run toplevel

clean::
	cd ../Common; $(MAKE) clean
	rm -f run toplevel core 
	rm -f lexer.ml
	rm -f ccsl_hashkeys.ml ccsl_hashkeys.mli
	rm -f grammar.ml grammar.mli 
	rm -f grammar.output

realclean:: clean
	rm -f *etags TAGS


.PHONY:: ccsltest diff generation clearrun


pvsbeh=Hash.beh adt-acc.beh adt.beh cart.beh class_methods.beh \
	codomain.beh counter.beh ex.beh inherit.beh morphism.beh \
	point.beh pvsinfix.beh queue.beh register.beh rename.beh \
	stack.beh test.beh test2.beh typedef.beh vars.beh \
	visibility.beh 

# point.beh pvsinfix.beh 
# isar bugs : morphism.beh 

isarbeh=adt-acc.beh cart.beh class_methods.isar.beh \
	codomain.beh counter.isar.beh ex.beh inherit.beh \
	queue.beh rename.beh \
	stack.isar.beh typedef.isar.beh \
	visibility.beh \
	adt.beh 

testprefix=../TestCases
relpvsbeh=$(addprefix $(testprefix)/,$(pvsbeh))
relisarbeh=$(addprefix $(testprefix)/,$(isarbeh))

testccslc=./run
ccsltestdir=$(testprefix)/Th
isartestdir=$(testprefix)/Isar

ccsltest: $(testccslc)
	rm -f $(ccsltestdir)/.pvscontest
	rm -f $(ccsltestdir)/*_basic*
	rm -f $(ccsltestdir)/*bin
	rm -f $(ccsltestdir)/*_adt*
	rm -f $(ccsltestdir)/compiler-output
	rm -f $(ccsltestdir)/ccsl_prelude*
	rm -f $(ccsltestdir)/pvs-batch.el
	$(testccslc) -batch $(relpvsbeh) -d $(ccsltestdir) \
		2>&1 | tee $(ccsltestdir)/compiler-output

isartest: $(testccslc)
	rm -f $(isartestdir)/*thy
	rm -f $(isartestdir)/*ML
	$(testccslc) -batch $(relisarbeh) -d $(isartestdir) \
		-isa -no-inline-lifting \
		2>&1 | tee $(isartestdir)/compiler-output

#	 for f in ../TestCases/*beh ; \
#	    do \
#		 echo ============ $$f; \
#		 ./run -batch $$f -d ../TestCases/Th; \
#	    done

diff: 
	diff -c -I '^% date' -I '^% command line' \
		-I 'ccsllib : Library =' \
		-x '*bin' -x '*_adt.pvs' -x '.pvscontext' \
		-x '.cvsignore' -x '*~' -x '.#*' \
		../TestCases/StdTh $(ccsltestdir) \
		| tee ../TestCases/test-diff

isardiff:
	diff -c -I '^ \* date' -I '^ \* command line' \
		-x '.cvsignore' -x '*~' -x '.#*' \
		../TestCases/StdIsar $(isartestdir) \
		| tee ../TestCases/test-diff

#	cp ../PvsPrelude/predicates.pvs ../Examples/Ccsl/TestCases/Th

generation:
	rm -f ../TestCases/StdTh/*pvs
	rm -f ../TestCases/StdTh/*prf
	rm -f ../TestCases/StdTh/*el
	rm -f ../TestCases/Th/*~
	rm -f ../TestCases/Th/log
	cp ../TestCases/Th/* ../TestCases/StdTh

isargeneration:
	rm -f ../TestCases/StdIsar/*thy
	rm -f ../TestCases/StdIsar/ROOT.ML
	rm -f ../TestCases/Isar/*~
	rm -f ../TestCases/Isar/log
	cp ../TestCases/Isar/* ../TestCases/StdIsar

lexer.cmo: grammar.cmi ../Common/parser_util.cmi parser.cmi \
	../Common/error.cmo
lexer.ml: lexer.mll
ccsl_hashkeys.cmi: grammar.cmi
ccsl_hashkeys.cmo: ccsl_hashkeys.cmi ../Common/top_classes.cmo
grammar.cmo: grammar.ml grammar.cmi ../Common/error.cmo \
	../Common/parser_util.cmi \
	member_class.cmo iface_class.cmi parser.cmi
grammar.cmi: grammar.mli classtypes.cmo
grammar.ml: grammar.mly
grammar.mli: grammar.mly
abstract_lexer.cmi: grammar.cmi
abstract_lexer.cmo: grammar.cmi
main.cmo: lexer.cmo ccsl_hashkeys.cmi

lexer.cmx: grammar.cmi ../Common/parser_util.cmi parser.cmi \
	../Common/error.cmx
ccsl_hashkeys.cmx: ccsl_hashkeys.cmi ../Common/top_classes.cmx
grammar.cmx: grammar.ml grammar.cmi ../Common/error.cmx \
	../Common/parser_util.cmi \
	member_class.cmx iface_class.cmx
main.cmx: lexer.cmx ccsl_hashkeys.cmi

# ocamldep 

include .depend


### Local Variables: ***
### version-control: t ***
### kept-new-versions: 5 ***
### delete-old-versions: t ***
### time-stamp-line-limit: 30 ***
### End: ***
