OBJS = ast.cmo parser.cmo scanner.cmo ccode.cmo translate.cmo compile.cmo

TESTS = \
arith1 \
arith2 \
fib \
for1 \
func1 \
func2 \
func3 \
gcd \
global1 \
hello \
if1 \
if2 \
if3 \
if4 \
ops1 \
var1 \
while1

TARFILES = Makefile testall.sh scanner.mll parser.mly \
	ast.ml ccode.ml translate.ml compile.ml \
	$(TESTS:%=tests/test-%.mc) \
	$(TESTS:%=tests/test-%.out)

compile : $(OBJS)
	ocamlc -o compile $(OBJS)

.PHONY : test
test : compile testall.sh
	./testall.sh

scanner.ml : scanner.mll
	ocamllex scanner.mll

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

%.cmo : %.ml
	ocamlc -c $<

%.cmi : %.mli
	ocamlc -c $<

compile.tar.gz : $(TARFILES)
	cd .. && tar czf compile/compile.tar.gz $(TARFILES:%=compile/%)

.PHONY : clean
clean :
	rm -f compile parser.ml parser.mli scanner.ml testall.log \
	*.cmo *.cmi *.out *.diff

# Generated by ocamldep *.ml *.mli
ast.cmo: 
ast.cmx: 
ccode.cmo: ast.cmo 
ccode.cmx: ast.cmx 
translate.cmo: ccode.cmo ast.cmo 
translate.cmx: ccode.cmx ast.cmx 
compile.cmo: scanner.cmo parser.cmi translate.cmo \
    ccode.cmo ast.cmo 
compile.cmx: scanner.cmx parser.cmx translate.cmx \
    ccode.cmx ast.cmx 
parser.cmo: ast.cmo parser.cmi 
parser.cmx: ast.cmx parser.cmi 
scanner.cmo: parser.cmi 
scanner.cmx: parser.cmx 
parser.cmi: ast.cmo 
