OBJS = ast.cmo parser.cmo scanner.cmo debug.cmo bytecode.cmo typecheck.cmo compile.cmo execute.cmo cpi.cmo


TARFILES = Makefile testall.sh scanner.mll parser.mly \
	ast.ml sast.ml bytecode.ml debug.ml typecheck.ml compile.ml execute.ml cpi.ml \
	$(TESTS:%=tests/test-%.mc) \
	$(TESTS:%=tests/test-%.out)

cpi : $(OBJS)
	ocamlc -g -o cpi $(OBJS)

all : clean cpi

.PHONY : test
test : cpi
	cd tests && ./runtests.sh

test_tc : cpi
	cd tc_tests && ./runtests.sh

test_edpi :
	ssh edpi 'cd plt2013; make clean; git pull; make test'

test_tc_edpi :
	ssh edpi 'cd plt2013; make clean; git pull; make test_tc'

test_qemupi :
	ssh qemupi 'cd plt2013; make clean; git pull; make test'

scanner.ml : scanner.mll
	ocamllex scanner.mll

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

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

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

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

.PHONY : clean
clean :
	rm -f cpi parser.ml parser.mli scanner.ml testall.log \
	*.cmo *.cmi *.out *.diff
	rm -rf tests/out
	rm -rf tc_tests/*.s

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