PACKAGES=-package sdl,sdl.sdlttf,sdl.sdlimage,unix,threads
OCAMLCFLAGS=$(PACKAGES) -thread -g
OCAMLOPTFLAGS=$(PACKAGES) -thread
OCAMLC=ocamlfind ocamlc
#OCAMLC=ocamlfind ocamlcp
OCAMLOPT=ocamlfind ocamlopt

all: gamePrimitives.cma gamePrimitives.cmxa

INTERFACES=math.mli control.mli utils.mli

FILES=math.ml utils.ml \
	gfx.ml control.ml pointer.ml input.ml \
	fader.ml label.ml scene.ml messages.ml

%.cmi: %.mli
	$(OCAMLC) -c $(OCAMLCFLAGS) -o $@ $<

%.cmo: %.ml
	$(OCAMLC) -c $(OCAMLCFLAGS) -o $@ $<

%.cmx: %.ml
	$(OCAMLOPT) -c $(OCAMLOPTFLAGS) -o $@ $<

.depends:
	ocamldep $(FILES) >.depends

-include .depends

install:
	-ocamlfind remove gameprimitives
	ocamlfind install gameprimitives META gamePrimitives.cma gamePrimitives.cmxa gamePrimitives.a *.mli *.cmi

depend:
	rm -f .depends
	$(MAKE) .depends

clean:
	rm -f *.cmx *.cmo *.cmi *~ mox *.o mox.exe moxopt.exe

gamePrimitives.cma: $(patsubst %.ml,%.cmo,$(FILES)) 
	$(OCAMLC) -o $@ -a $(OCAMLCFLAGS) $^ 

gamePrimitives.cmxa: $(patsubst %.ml,%.cmx,$(FILES)) 
	$(OCAMLOPT) -o $@ -a $(OCAMLOPTFLAGS) $^ 
