
OBJS = ast.cmo scanner.cmo parser.cmo bytecode.cmo compile.cmo execute.cmo
COMPILER = retrocraft.cmo
TESTS = tests.cmo runtest.cmo

CONF=-I +threads
LIBS=$(WITHGRAPHICS) $(WITHUNIX) $(WITHTHREADS) $(WITHGPC)

# Default setting of the WITH* variables. Should be changed if your
# local libraries are not found by the compiler.
WITHGRAPHICS =graphics.cma -cclib -lgraphics -cclib -L/usr/X11R6/lib -cclib -lX11

WITHTHREADS =threads.cma -cclib -lthreads

WITHUNIX =unix.cma -cclib -lunix

WITHGPC =camlgpc.cma -cclib -L.


default: 
	@make -f MakefileGPC
	@make compiler

compiler : $(OBJS) $(COMPILER)
	ocamlc $(CONF) -o retrocraft $(LIBS) $(OBJS) $(COMPILER)

runtests : $(OBJS) $(TESTS)
	ocamlc -o runtests $(OBJS) $(TESTS)

scanner.ml : scanner.mll
	ocamllex scanner.mll

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

%.cmo : %.ml
	ocamlc $(CONF) -c $<

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


.PHONY : clean
clean :
	rm -rf *.cmo *.cmi retrocraft parser.mli parser.ml scanner.ml \
	*.cmo *.cmi *.out *.diff *.a
	@make clean -f MakefileGPC

clean_runtests :
	rm -rf *.cmo *.cmi runtests parser.mli parser.ml scanner.ml

# Clean test reference files
clean_r :
	find . -name *.reference | xargs /bin/rm -f

# Clean intermediate test files
clean_i :
	find . -name *.reference | xargs /bin/rm -f
	rm -rf *.c.out *.diff

# 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 
retrocraft.cmo: scanner.cmo parser.cmi execute.cmo compile.cmo \
    bytecode.cmo ast.cmo tests.cmo
retrocraft.cmx: scanner.cmx parser.cmx execute.cmx compile.cmx \
    bytecode.cmx ast.cmx tests.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 
tests.cmo:
tests.cmx: