OS = $(shell uname -s 2>/dev/null | tr [:lower:] [:upper:])
# 'linux' is output for Linux system, 'darwin' for OS X
DARWIN = $(strip $(findstring DARWIN, $(OS)))

JCFLAGS = -classpath jfugue.jar
JC = javac

OBJS = parser.cmo scanner.cmo printer.cmo helper.cmo execute.cmo compiler.cmo tonedef.cmo #str.cma
UNIXFLAG = unix.cma
UNIXFLAGX = unix.cmxa

tonedef : $(OBJS) PlayJFugue
	ocamlc -o tonedef $(UNIXFLAG) $(OBJS)

scanner.ml : scanner.mll
	ocamllex scanner.mll

parser.ml parser.mli : parser.mly
	ocamlyacc parser.mly

%.cmo : %.ml
	ocamlc -c $(UNIXFLAG) $<

%.cmi : %.mli
	ocamlc -c $(UNIXFLAG) $<

#str.cma : str.cma
#	ocamlopt -c $(UNIXFLAGX) str.cmxa

PlayJFugue : PlayJFugue.java
	$(JC) $(JCFLAGS) $<

test : tonedef
	python test.py

.PHONY : clean
clean :
	rm -f tonedef parser.ml parser.mli scanner.ml *.cmo *.cmi *.class *~ 

# Generated by ocamldep *.ml *.mli
ast.cmi:
bytecode.cmi: ast.cmi
helper.cmo: ast.cmi bytecode.cmi
parser.cmo: ast.cmi parser.cmi
parser.cmx: ast.cmi parser.cmi
parser.cmi: ast.cmi
printer.cmo: ast.cmi 
printer.cmx: ast.cmi 
compiler.cmo: ast.cmi bytecode.cmi helper.cmo
compiler.cmx: ast.cmi bytecode.cmi helper.cmo
execute.cmo:  bytecode.cmi ast.cmi helper.cmo
execute.cmx:  bytecode.cmx ast.cmi helper.cmo
scanner.cmo: parser.cmi
scanner.cmx: parser.cmx
