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

all: $(out)

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

$(libs): hgl.cmx hgl.cmo chgl.o
	ocamlmklib -o hgl hgl.cmx  
	ocamlmklib -o hgl hgl.cmo  
	ocamlmklib -o hgl chgl.o  

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

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

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