# 
# 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.36 2010-06-30 08:46:12 tews Exp $
# 


include ../Common/CommonMakefile

INCLUDECOMMON=-I ../Common

OBJECTS= \
	names.cmo \
	classtypes.cmo \
	types_util.cmo ccsl_pretty.cmo \
	symbol.cmo prelude.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 derive.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

shift-latest-stable:
	(cd ..; cvs tag -d latest-stable)
	(cd ..; cvs tag latest-stable)
	$(MAKE) -C ../../Ccsl_Testcases shift-latest-stable


# 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) -r . -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 native_run ccslc ccslc.opt 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 isargeneration clearrun shift-latest-stable


pvsbeh=Hash.beh adt-acc.beh adt.beh cart.beh class_methods.beh \
	codomain.beh counter.beh ex.beh inherit.beh \
	map.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 

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

testprefix=../../Ccsl_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 -rf $(ccsltestdir)/pvsbin
	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

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

isardiff:
	diff -u -I '^ \* date' -I '^ \* command line' \
		-I '^ \* CCSL Compiler Version ' \
		-x '.cvsignore' -x '*~' -x '.#*' \
		$(testprefix)/StdIsar $(isartestdir) \
		| tee $(testprefix)/test-diff

generation:
	rm -f $(testprefix)/StdTh/*pvs
	rm -f $(testprefix)/StdTh/*prf
	rm -f $(testprefix)/StdTh/*el
	rm -f $(testprefix)/Th/*~
	rm -f $(testprefix)/Th/log
	cp $(testprefix)/Th/* $(testprefix)/StdTh

isargeneration:
	rm -f $(testprefix)/StdIsar/*thy
	rm -f $(testprefix)/StdIsar/ROOT.ML
	rm -f $(testprefix)/Isar/*~
	rm -f $(testprefix)/Isar/log
	cp $(testprefix)/Isar/* $(testprefix)/StdIsar

lexer.cmo: grammar.cmi ../Common/parser_util.cmi parser.cmi \
	../Common/error.cmi
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.cmi \
	../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 ***
### time-stamp-line-limit: 30 ***
### End: ***
