OCAMLCLANG = ocamlc -thread -c -ccopt "-O9 -fomit-frame-pointer -ffast-math -mcpu=pentium -march=pentium"
OCAMLC = ocamlc -c -thread -g
OCAMLOPT = ocamlopt -thread -c -unsafe -noassert
libs = gl.cma gl.cmxa libgl.a dllgl.so gl.a
out = $(addprefix ../lib/,$(libs) gl.cmi)

all: $(out)

$(out): $(libs) gl.cmi
	cp $(libs) gl.cmi ../lib

$(libs): gl.cmx gl.cmo cgl.o
	ocamlmklib -o gl gl.cmx  
	ocamlmklib -o gl gl.cmo  
	ocamlmklib -o gl cgl.o  

cgl.o: cgl.c
	$(OCAMLCLANG) $< -o $@

gl.cmx gl.cmo gl.cmi: gl.ml
	$(OCAMLC) $<
	$(OCAMLOPT) $<

clean:
	@rm -f core a.out cgl.o gl.o gl.cm[iox] $(libs) $(out)
