Source

caml2geom / Makefile

#  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
CAML2GEOM_MODULENAME = Caml2geom
PKGCONFIG = pkg-config
#OCAMLC = ocamlfind c -g
#OCAMLOPT = ocamlfind opt -g
OCAMLC = ocamlc -g
OCAMLOPT = ocamlopt -g
OCAMLMKLIB = ocamlmklib
CXXFLAGS = -g -fPIC -Wall -W
CPPFLAGS = `$(PKGCONFIG) --cflags 2geom`
LDFLAGS = `$(PKGCONFIG) --libs 2geom`

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

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

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

%.cmx: %.ml %.cmi dll$(CAML2GEOM).so
	$(OCAMLOPT) -c $< -cclib dll$(CAML2GEOM).so

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

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

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

$(CAML2GEOM).cma: $(CAML2GEOM).cmo
	$(OCAMLMKLIB) -o $(CAML2GEOM) $^ $(LDFLAGS)

$(CAML2GEOM).cmxa: $(CAML2GEOM).cmx
	$(OCAMLMKLIB) -o $(CAML2GEOM) $^ $(LDFLAGS)

dll$(CAML2GEOM).so lib$(CAML2GEOM).a: $(CAML2GEOM)_stubs.o
	$(OCAMLMKLIB) -o $(CAML2GEOM) $< $(LDFLAGS)

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

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

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