OBJS = ast.cmo sast.cmo parser.cmo scanner.cmo bytecode.cmo semantic.cmo compile.cmo  generator.cmo faster.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 bytecode.ml interpret.ml semantic.ml compile.ml execute.ml faster.ml \
	$(TESTS:%=tests/test-%.mc) \
	$(TESTS:%=tests/test-%.out)

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

.PHONY : test
test : faster testall.sh
	./testall.sh

rtest: faster
	./faster < $(param)
	gcc -fopenmp faster_generated.c -o faster_gen_output
	./faster_gen_output


scanner.ml : scanner.mll
	ocamllex scanner.mll
parser.ml parser.mli : parser.mly
	ocamlyacc parser.mly

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


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

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

.PHONY : clean
clean :
	rm -f faster faster_generated.c faster_gen_output parser.ml parser.mli scanner.ml testall.log \
	*.cmo *.cmi *.out *.diff

# Generated by ocamldep *.ml *.mli
ast.cmo:
ast.cmx:
bytecode.cmo: ast.cmo
bytecode.cmx: ast.cmx
compile.cmo: semantic.cmo sast.cmo bytecode.cmo ast.cmo
compile.cmx: semantic.cmx sast.cmx bytecode.cmx ast.cmx
faster.cmo: semantic.cmo parser.cmi generator.cmo compile.cmo bytecode.cmo \
    ast.cmo
faster.cmx: semantic.cmx parser.cmx generator.cmx compile.cmx bytecode.cmx \
    ast.cmx
generator.cmo: bytecode.cmo ast.cmo
generator.cmx: bytecode.cmx ast.cmx
parser.cmo: ast.cmo parser.cmi
parser.cmx: ast.cmx parser.cmi
sast.cmo: ast.cmo
sast.cmx: ast.cmx
semantic.cmo: sast.cmo bytecode.cmo ast.cmo
semantic.cmx: sast.cmx bytecode.cmx ast.cmx
parser.cmi: ast.cmo
