# 
# 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 with common definition and rules
# 
# $Id: CommonMakefile,v 1.21 2010-10-19 19:09:20 tews Exp $
# 


# for experiments
OCAMLDIR=
#OCAMLDIR=/usr/local/ocaml-2.04/bin/
#OCAMLDIR=/usr/local/ocaml-3.01/bin/
#OCAMLDIR=/usr/local/ocaml-3.02/bin/
#OCAMLDIR=/usr/local/ocaml-3.04/bin/
#OCAMLDIR=/usr/local/stow/ocaml-3.07/bin/
LOOPLIB=../Common/looplib.cma
LOOPLIBX=../Common/looplib.cmxa
CCSLCOMPILER=../Ccsl/run

DIRS=Admin Ccsl Common Keywords


OCAMLLEX=$(OCAMLDIR)ocamllex
OCAMLYACC=$(OCAMLDIR)ocamlyacc
OCAMLCP=$(OCAMLDIR)ocamlcp
OCAMLC=$(OCAMLDIR)ocamlc.opt
OCAMLOPT=$(OCAMLDIR)ocamlopt.opt
OCAMLDEP=$(OCAMLDIR)ocamldep
OCAMLMKTOP=$(OCAMLDIR)ocamlmktop

# for byte code profiling
#OCAMLC=$(OCAMLCP)

# uncomment the next line for bytecode debugging support
COMPFLAGS= -g # -i # -nolabels

# for gprof
OPTCOMPFLAGS= # -p

ETAGS=etags
#OTAGS=/home/tews/install/otags-1.2-beta/otags -cat /home/tews/install/otags-1.2-beta/cattags -p4 "/home/tews/install/otags-1.2-beta/camlp4str -I /home/tews/install/otags-1.2-beta"
#CATTAGS=/home/tews/install/otags-1.2-beta/cattags
CATTAGS=cattags
OTAGS=otags

HASHKEYS=../Keywords/keys

.PRECIOUS: %.ml %.mli
.PHONY:: depend clearrun score $(LOOPLIB) $(LOOPLIBX) $(JAVALIB) $(JAVALIBX)
.PHONY:: $(CCSLCOMPILER)
.PHONY:: tags TAGS.local

start: all

$(HASHKEYS):
	cd ../Keywords; $(MAKE) -e

$(LOOPLIB):
	cd ../Common; $(MAKE) -e looplib.cma

$(LOOPLIBX):
	cd ../Common; $(MAKE) -e looplib.cmxa

$(CCSLCOMPILER):
	cd ../Ccsl; $(MAKE) -e run

clean::
	rm -f core *cmo *cmi *cmx *cma *cmxa *o *a 

cleanall: 
	for d in $(DIRS) ; do \
	    cd ../$$d ; $(MAKE) -e realclean; \
	done

depend::
	$(OCAMLDEP) $(INCLUDECOMMON) *mli *ml > .depend


#TOTAG=$(wildcard *ml)
#TAGFILES=$(TOTAG:.ml=.etags)
#
#tags
#	 $(ETAGS) -l yacc -o yacc.etags *mly 
#	 cattags *etags > TAGS
#
#%.etags : %.ml
#	 otags $<

tags:
	cd ../Common; $(MAKE) TAGS.local
	cd ../Ccsl; $(MAKE) TAGS.local
	cd ..; $(CATTAGS) Common/TAGS.local Ccsl/TAGS.local > TAGS


# clean cvs garbage
cvs-clean:
	find . -name '.#*' -exec rm {} \;
	rm *merge-backup


.SUFFIXES: .mll .mly .ml .mli .cmo .cmi .cmx

%.ml : %.mll
	$(OCAMLLEX) $<

%.ml %.mli: %.mly
	$(OCAMLYACC) $<

.mli.cmi:
	$(OCAMLC) -c $(INCLUDECOMMON) $(COMPFLAGS) $<

.ml.cmo:
	$(OCAMLC) -c $(INCLUDECOMMON) $(COMPFLAGS) $<

.ml.cmx:
	$(OCAMLOPT) -c $(INCLUDECOMMON) $(OPTCOMPFLAGS) $<


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