Source

caml2geom / Makefile

Full commit
#  Copyright (c) 2011 Barry Schwartz
#
#  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.

#--------------------------------------------------------------------------

CAML2GEOM = caml2geom
PKGCONFIG = pkg-config
OCAMLC = ocamlfind c -g
OCAMLOPT = ocamlfind opt -g
OCAMLMKLIB = ocamlmklib
CXXFLAGS = -g -fPIC
CPPFLAGS = `$(PKGCONFIG) --cflags 2geom`
LDFLAGS = `$(PKGCONFIG) --libs 2geom`

#--------------------------------------------------------------------------

#%.mli : %.ml
#	$(OCAMLC) -i $< > $@

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

%.cmo: %.ml %.cmi
	$(OCAMLC) -c $<

%.cma: %.cmo dll%_stubs.so
	$(OCAMLC) -a -o $@ $< -dllib dll$*_stubs.so

%.cmx: %.ml %.cmi
	$(OCAMLOPT) -c $<

%.cmxa: %.cmx dll%_stubs.so
	$(OCAMLOPT) -a -o $@ $< -cclib dll%_stubs.so

%_stubs.o: %_stubs.c
	$(OCAMLC) -cc "$(CXX)" -ccopt "$(CXXFLAGS)" -ccopt "$(CPPFLAGS)" -c $<

dll%_stubs.so lib_%_stubs.a: %_stubs.o
	$(OCAMLMKLIB) -o $*_stubs $< $(LDFLAGS)

#--------------------------------------------------------------------------

default: $(CAML2GEOM).cmi $(CAML2GEOM).cma $(CAML2GEOM).cmxa dll$(CAML2GEOM)_stubs.so

test1: test1.ml $(CAML2GEOM).cmi $(CAML2GEOM).cma dll$(CAML2GEOM)_stubs.so
	$(OCAMLC) -o $@ -dllib `pwd`/dll$(CAML2GEOM)_stubs.so test1.ml

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

#--------------------------------------------------------------------------