# 1] Dans la suite du fichier, suivre toutes les instructions de
#    remplacement.
# 2] Crer un fichier vide nomm .depend (destiner  stocker les
#    dpendences entre les diffrents fichier du projet.
# 3] Calculer les dependances du projet: 
#    > make depend
# 4] C'est prt! (Taper 'make')

BYTECOMPILER=ocamlc
COMPILEOPTION=str.cma -c 
COMPILEFINALOPTION=str.cma

# placer ici le nom de l'executable du projet, attention le fichier
# .ml contenant le main doit avoir le mme nom!
MAIN=SMVtoJAVA

# fabrication d'une boucle d'excution incluant toute les libs
OTOPROG=project_top

BASEDIR=./Sources

# ajouter d'autre rpertoire si besoin
INCLUDES= -I .

# donner tous les fichiers composant le projet
OBJECT_FILES=		Exceptions.cmo\
	     		Declaration.cmo\
			Lexer.cmo\
			Parser.cmo\
			Creation.cmo\
			Modification.cmo\
			Typage.cmo\
			Generation.cmo\
			SMVtoJAVA.cmo

executable: $(MAIN) $(OBJECT_FILES) $(OPTOBJECT_FILES)

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

%.ml: %.mly
	ocamlyacc -v $<

%.mli: %.mly
	ocamlyacc -v $<

%.ml: %.mll
	ocamllex $<

%.cmo: %.ml 
	$(BYTECOMPILER) $(COMPILEOPTION) $(INCLUDES) $<

%.cmi:	%.mli
	$(BYTECOMPILER) $(COMPILEOPTION) $(INCLUDES) $< 

%.cmx:	%.ml
	$(COMPILER) $(COMPILEOPTOPTION) $(INCLUDES) $<

# dans la suite, remplacer grammar.* (resp lexer.*) 
# par le nom du fichier contenant la grammaire (resp. le lexer)
depend: Parser.mli Parser.ml Lexer.ml
	ocamldep $(INCLUDES) *.mli *.ml *.mll *.mly > .depend

include .depend

Parser.mli: Parser.mly
Parser.ml: Parser.mly
Lexer.ml: Lexer.mll

clean:
	rm -f *.cmo *.cmi *.cmx *.o
	rm -f Parser.ml Parser.mli Lexer.ml Parser.output

top:
	ocamlmktop -o $(OTOPROG) $(INCLUDES) str.cma $(OBJECT_FILES)

graph:
	ocamldep *.ml *.mli | ocamldot -fullgraph | dot -Tps > dependence.ps

doc:
	ocamldoc -html -d ../Documentation Exceptions.ml Declaration.ml Creation.ml Modification.ml Typage.ml Generation.ml

$(MAIN): $(OBJECT_FILES)
	$(BYTECOMPILER) $(COMPILEFINALOPTION) -o $(MAIN)  $(INCLUDES) $(OBJECT_FILES)
	cp $(MAIN) ../Binaires/


