funcyjava.native:
	opam config exec -- \
	ocamlbuild -use-ocamlfind funcyjava.native

# "make test" Compiles everything and runs the regression tests
.PHONY: test
test: funcyjava.native testall.sh
	./testall.sh

# "make clean" removes all generated files
.PHONY : clean
clean:
	ocamlbuild -clean
	rm -rf testall.log ocamlllvm *.diff
	rm -rf *.cmx *.cmi *.cmo *.cmx *.o *.s *.ll *.out *.exe *.mli

.PHONY: demo1
demo1: funcyjava.native demos/demo1.fj
	./funcyjava.native demos/demo1.fj > demo1.ll
	llc -relocation-model=pic demo1.ll > demo1.s
	cc -o demo1.exe demo1.s 
	./demo1.exe 
	rm -rf *.cmx *.cmi *.cmo *.cmx *.o *.s *.ll *.out *.exe *.mli
	

.PHONY: demo2
demo2: funcyjava.native demos/demo2.fj
	./funcyjava.native demos/demo2.fj > demo2.ll
	llc -relocation-model=pic demo2.ll > demo2.s
	cc -o demo2.exe demo2.s 
	./demo2.exe 
	rm -rf *.cmx *.cmi *.cmo *.cmx *.o *.s *.ll *.out *.exe *.mli

.PHONY: demo3
demo3: funcyjava.native demos/demo3.fj
	./funcyjava.native demos/demo3.fj > demo3.ll
	llc -relocation-model=pic demo3.ll > demo3.s
	cc -o demo3.exe demo3.s 
	./demo3.exe 
	rm -rf *.cmx *.cmi *.cmo *.cmx *.o *.s *.ll *.out *.exe *.mli