# {{{ COPYING 
#
#  This file contains compile rules to build glMLite, an OCaml binding
#  to the OpenGL API.
#
#  Copyright (C) 2006 - 2011  Florent Monnier, Some rights reserved
#  Contact:  <fmonnier@linux-nantes.org>
#
#  Permission is hereby granted, free of charge, to any person obtaining a
#  copy of this software and associated documentation files (the "Software"),
#  to deal in the Software without restriction, including without limitation the
#  rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
#  sell copies of the Software, and to permit persons to whom the Software is
#  furnished to do so, subject to the following conditions:
#
#  The above copyright notice and this permission notice shall be included in
#  all copies or substantial portions of the Software.
#
#  The Software is provided "as is", without warranty of any kind, express or
#  implied, including but not limited to the warranties of merchantability,
#  fitness for a particular purpose and noninfringement. In no event shall
#  the authors or copyright holders be liable for any claim, damages or other
#  liability, whether in an action of contract, tort or otherwise, arising
#  from, out of or in connection with the software or the use or other dealings
#  in the Software.
#
# }}}

OCAMLOPT=ocamlopt

# GL_WRAPER_PATH := $(PREFIX)
  GL_WRAPER_PATH := "+glMLite"

all: test

SExprLite.cma:  SExprLite.cmi SExprLite.cmo
	$(OCAMLC) -a -o SExprLite.cma SExprLite.cmo

SExprLite.cmx: SExprLite.ml
	$(OCAMLOPT) -c SExprLite.ml

SExprLite.cmxa:  SExprLite.cmi SExprLite.cmx
	$(OCAMLOPT) -a -o SExprLite.cmxa SExprLite.cmx


# COMPILES A DEMO
# default demo to compile:
DEMO=demo_sexpr.ml
DEMO_OPT := $(patsubst %.ml,%.opt, $(DEMO))

# there are more modules than needed by the default demo,
# so that make can be called with DEMO defined with another demo, for example:
# make DEMO=outline.ml
$(DEMO_OPT):  $(DEMO)   SExprLite.cmxa
	$(OCAMLOPT)  -o $@              \
	    -ccopt -L$(GL_WRAPER_PATH)  \
	    -I $(GL_WRAPER_PATH)        \
	    GL.cmxa Glu.cmxa Glut.cmxa  \
	    FunGL.cmxa  FunGlut.cmxa    \
	    vertArray.cmxa              \
	    jpeg_loader.cmxa            \
	    png_loader.cmxa             \
	    svg_loader.cmxa             \
	    ftgl.cmxa                   \
	    str.cmxa  bigarray.cmxa     \
	    SExprLite.cmxa              \
	    $<

# test

test: test-opt

test-opt: $(DEMO_OPT)
	./$(DEMO_OPT)


clean:
	rm -f *.[oa] *.cm[ixoa] *.cmxa *.opt

cleaner: clean
	rm -f *~

# vim: fdm=marker
