# 
# 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.17 2002/01/24 14:43:58 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 \
	adt_theory.cmo \
	\
	iface_class.cmo member_class.cmo \
	substitution.cmo \
	parser.cmo \
	lexer.cmo ccsl_hashkeys.cmo grammar.cmo \
	\
	emptytype_theory.cmo \
	\
	inherit.cmo resolution.cmo newtypecheck.cmo \
	component_pass.cmo feature.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 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) . -tags 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


ccsltest: run
	rm -f ../TestCases/Th/.pvscontext
	rm -f ../TestCases/Th/*pvs
	rm -f ../TestCases/Th/*prf
	rm -f ../TestCases/Th/*el
	./run -batch ../TestCases/*beh -d ../TestCases/Th

#	 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 '*~' -x '.#*' \
		../TestCases/StdTh ../TestCases/Th \
		| 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/*~
	cp ../TestCases/Th/* ../TestCases/StdTh


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.cmo
grammar.cmi: grammar.mli classtypes.cmi 
grammar.ml: grammar.mly
grammar.mli: grammar.mly
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
