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

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

.PHONY : test
test : svipc testall.sh
	./testall.sh

scanner.ml : scanner.mll
	ocamllex scanner.mll

parser.ml parser.mli : parser.mly
	ocamlyacc -v parser.mly

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

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

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

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

.PHONY : clean_all
clean_all :
	rm -f svipc parser.output parser.ml parser.mli scanner.ml testall.log \
	*.cmo *.cmi *.out *.diff && find ./tests/ ! -name "*.svip" -type f -delete

# Generated by ocamldep *.ml *.mli
ast.cmo: 
ast.cmx: 
bytecode.cmo: ast.cmo 
bytecode.cmx: ast.cmx 
compile.cmo: bytecode.cmo ast.cmo 
compile.cmx: bytecode.cmx ast.cmx 
execute.cmo: bytecode.cmo ast.cmo 
execute.cmx: bytecode.cmx ast.cmx 
interpret.cmo: ast.cmo 
interpret.cmx: ast.cmx 
svipc.cmo: scanner.cmo parser.cmi interpret.cmo execute.cmo compile.cmo \
    bytecode.cmo ast.cmo 
svipc.cmx: scanner.cmx parser.cmx interpret.cmx execute.cmx compile.cmx \
    bytecode.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 
sast.cmo: ast.cmo
sast.cmx: ast.cmx