OBJS = ast.cmo parser.cmo scanner.cmo compile.cmo codeGen.cmo bytecode.cmo\
	semantic.cmo yaglc.cmo

CPPOBJS = cpp/jsoncpp.o

# 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 microc.ml \
# 	$(TESTS:%=tests/test-%.mc) \
# 	$(TESTS:%=tests/test-%.out)

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

.PHONY : test
test : yaglc 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 $<

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

.PHONY : clean
clean :
	rm -f yaglc parser.ml parser.mli scanner.ml testall.log \
	*.cmo *.cmi *.out *.diff *.*~* *.c* *.svg

run:$(CPPOBJS)
	make && ./yaglc easy_example.yagl && clang-format -style=LLVM -i example.cpp && g++ example.cpp -L./cpp -o example.out -I./cpp/json && ./example.out
# Generated by ocamldep *.ml *.mli
ast.cmo:
ast.cmx:
semantic.cmo: ast.cmo
semantic.cmx: ast.cmx
bytecode.cmo: ast.cmo
bytecode.cmx: ast.cmx
codeGen.cmo: bytecode.cmo ast.cmo
codeGen.cmx: bytecode.cmx ast.cmx
compile.cmo: bytecode.cmo ast.cmo
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
yaglc.cmo: scanner.cmo parser.cmi compile.cmo codeGen.cmo ast.cmo
yaglc.cmx: scanner.cmx parser.cmx compile.cmx codeGen.cmx ast.cmx
parser.cmi: ast.cmo
