-PKGNAME = gdome2-xslt
+
ARCHIVE = mlgdome2-xslt
-REQUIRES = gdome2
+PKGNAME = gdome2-xslt
+OCAMLINSTALLDIR = $(DESTDIR)$(OCAMLSTDLIBDIR)/$(PKGNAME)
+STUBSDIR = $(DESTDIR)$(OCAMLSTUBDIR)
+OCAMLFLAGS = -I +gdome2
+OCAMLC = @OCAMLC@ ${OCAMLFLAGS}
+OCAMLOPT = @OCAMLOPT@ ${OCAMLFLAGS}
+OCAMLDEP = @OCAMLDEP@
+OCAML_CFLAGS = @OCAML_CFLAGS@
OCAMLFIND = @OCAMLFIND@
-OCAMLC = $(OCAMLFIND) @OCAMLC@ -package "$(REQUIRES)"
-OCAMLOPT = $(OCAMLFIND) @OCAMLOPT@ -package "$(REQUIRES)"
-OCAMLDEP = $(OCAMLFIND) @OCAMLDEP@ -package "$(REQUIRES)"
-OCAMLMKLIB = @OCAMLMKLIB@
+OCAMLMKLIB = ocamlmklib
DLL = dll$(ARCHIVE).so
-OCAMLSTDLIBDIR = $(DESTDIR)/@OCAMLSTDLIBDIR@
-OCAMLSTUBDIR = $(DESTDIR)/@OCAMLSTUBDIR@
-OCAMLINSTALLDIR = $(OCAMLSTDLIBDIR)/$(PKGNAME)
-MODULES = i_gdome_xslt gdome_xslt
-INIT = gdome_xslt_init
-CMI_S = $(MODULES:%=%.cmi)
-CMO_S = $(MODULES:%=%.cmo)
-CMX_S = $(MODULES:%=%.cmx)
-O_S = ml_gdome_xslt.o $(top_builddir)/C/gdome_xslt/gdome_xslt.o
-SHARED_LIBS = -lxslt -lgdome -lglib -lxml2 -lmlgdome
-BYTE_STUFF = $(ARCHIVE).cma $(INIT).cmo
-NATIVE_STUFF = $(ARCHIVE).cmxa $(ARCHIVE).a $(INIT).cmx
-BYTE_INSTALL_STUFF = \
- i_gdome_xslt.cmi gdome_xslt.cmi gdome_xslt.mli $(ARCHIVE).cma \
- $(INIT).cmi $(INIT).cmo $(INIT).mli $(DLL) META
-NATIVE_INSTALL_STUFF = $(ARCHIVE).a $(ARCHIVE).cmxa $(INIT).cmx $(INIT).o
+
+CLEANFILES = \
+ $(ARCHIVE).cma $(ARCHIVE).cmxa $(ARCHIVE).a lib$(ARCHIVE).a $(DLL) \
+ *.cmo *.cmx *.cmi
EXTRA_DIST = \
- META.in gdome_xslt.ml gdome_xslt.mli \
- gdome_xslt_init.ml gdome_xslt_init.mli i_gdome_xslt.ml \
- ml_gdome_xslt.c ml_gdome_xslt.h ocaml-io.h .depend
+ META.in .depend \
+ gdome_xslt.ml gdome_xslt.mli gdome_xslt_init.ml gdome_xslt_init.mli \
+ i_gdome_xslt.ml \
+ ocaml-io.h
if HAVE_OCAMLOPT_COND
-noinst_DATA = $(BYTE_STUFF) $(NATIVE_STUFF)
+noinst_DATA = $(ARCHIVE).cma $(DLL) $(ARCHIVE).cmxa $(ARCHIVE).a gdome_xslt_init.cmo gdome_xslt_init.cmx
else
-noinst_DATA = $(BYTE_STUFF)
+noinst_DATA = $(ARCHIVE).cma $(DLL) gdome_xslt_init.cmo
endif
-noinst_LTLIBRARIES = libmlgdome2_xslt.la
-libmlgdome2_xslt_la_SOURCES = ml_gdome_xslt.c
+noinst_LTLIBRARIES = libmlgdome2-xslt.la
+
+C_SRC = ml_gdome_xslt.c
+libmlgdome2_xslt_la_SOURCES = $(C_SRC)
+
+O_S = $(C_SRC:%.c=%.o)
+LO_S = $(O_S:%.o=%.lo) $(top_builddir)/C/gdome_xslt/gdome_xslt.lo
+CMA_DEPS = i_gdome_xslt.cmo gdome_xslt.cmo
+CMXA_DEPS = $(CMA_DEPS:%.cmo=%.cmx)
+SHARED_LIBS = -lxslt -lgdome -lglib -lxml2 -lmlgdome
+
+$(ARCHIVE).cma: $(CMA_DEPS)
+ $(OCAMLMKLIB) -o $(ARCHIVE) -L@OCAMLSTUBDIR@ $(CMA_DEPS) $(SHARED_LIBS)
+
+$(ARCHIVE).cmxa: $(CMXA_DEPS)
+ $(OCAMLMKLIB) -o $(ARCHIVE) -L@OCAMLSTUBDIR@ $(CMXA_DEPS) $(SHARED_LIBS)
+$(DLL) $(ARCHIVE).a: $(LO_S)
+ # use .lo for ocamlmklib
+ for f in $(LO_S); do \
+ cp $$f $$f.o; \
+ done
+ $(OCAMLMKLIB) -o $(ARCHIVE) -L@OCAMLSTUBDIR@ $(LO_S:%=%.o) $(SHARED_LIBS)
+ for f in $(LO_S:%=%.o); do \
+ rm $$f; \
+ done
+
+INCLUDES = $(GDOME_CFLAGS) $(MLGDOME_CFLAGS) -I/usr/include/caml -I$(top_srcdir)/C/gdome_xslt
+
+BYTECODE_STUFF = $(ARCHIVE).cma $(DLL) gdome_xslt.cmi gdome_xslt.mli gdome_xslt_init.cmi gdome_xslt_init.mli gdome_xslt_init.cmo
+NATIVECODE_STUFF = $(ARCHIVE).cmxa $(ARCHIVE).a gdome_xslt_init.cmx
if HAVE_OCAMLOPT_COND
-install-data-local: $(BYTE_INSTALL_STUFF) $(NATIVE_INSTALL_STUFF)
+install-data-local: $(BYTECODE_STUFF) $(NATIVECODE_STUFF)
else
-install-data-local: $(BYTE_INSTALL_STUFF)
+install-data-local: $(BYTECODE_STUFF)
endif
- $(mkinstalldirs) $(OCAMLSTDLIBDIR) $(OCAMLSTUBDIR)
+ $(mkinstalldirs) $(OCAMLINSTALLDIR) $(STUBSDIR)
chmod -x $(DLL)
- $(OCAMLFIND) install -destdir $(OCAMLSTDLIBDIR) $(PKGNAME) $^
- ln -fs $(DLL) $(OCAMLSTUBDIR)/lib$(ARCHIVE).so
-
-CLEANFILES = \
- $(ARCHIVE).{cma,cmxa,a} $(CMI_S) $(CMO_S) $(CMX_S) ml_gdome_xslt.o \
- $(DLL) $(INIT).cm[iox] libmlgdome2-xslt.a
-
-INCLUDES = \
- $(GDOME_CFLAGS) $(MLGDOME_CFLAGS) \
- -I/usr/include/caml -I$(top_srcdir)/C/gdome_xslt
-
-$(ARCHIVE).cma $(DLL): $(CMO_S)
- $(OCAMLMKLIB) -o $(ARCHIVE) -L@OCAMLSTUBDIR@ $(CMO_S) $(O_S) $(SHARED_LIBS)
-$(ARCHIVE).cmxa $(ARCHIVE).a: $(CMX_S)
- $(OCAMLMKLIB) -o $(ARCHIVE) -L@OCAMLSTUBDIR@ $(CMX_S) $(O_S) $(SHARED_LIBS)
-
-%.cmi: %.mli
- $(OCAMLC) -c $<
-%.cmo: %.ml %.cmi
- $(OCAMLC) -c $<
-%.cmx: %.ml %.cmi
- $(OCAMLOPT) -c $<
-
-i_gdome_xslt.cmo: i_gdome_xslt.ml
- $(OCAMLC) -c $<
-i_gdome_xslt.cmx: i_gdome_xslt.ml
- $(OCAMLOPT) -c $<
-
-depend: *.ml *.mli
- $(OCAMLDEP) *.ml *.mli >.depend
+ for i in $^; do \
+ if [ "$$i" != "$(DLL)" ]; then \
+ $(INSTALL_DATA) $$i $(OCAMLINSTALLDIR)/$$i; \
+ fi \
+ done
+ if [ "x$(OCAMLFIND)" != "x" ]; then \
+ mv $(OCAMLINSTALLDIR) $(OCAMLINSTALLDIR).saved; \
+ $(OCAMLFIND) install -destdir $(DESTDIR)$(OCAMLSTDLIBDIR)/ $(PKGNAME) META $(DLL); \
+ $(INSTALL_DATA) $(OCAMLINSTALLDIR).saved/* $(OCAMLINSTALLDIR)/; \
+ rm -rf $(OCAMLINSTALLDIR).saved/; \
+ else \
+ $(INSTALL_DATA) $(DLL) $(STUBSDIR); \
+ fi
+ ln -fs $(DLL) $(STUBSDIR)/lib$(ARCHIVE).so
+
+uninstall-local:
+ if [ "x$(OCAMLFIND)" != "x" ]; then \
+ $(OCAMLFIND) remove -destdir $(DESTDIR)$(OCAMLSTDLIBDIR)/ $(PKGNAME); \
+ else \
+ rm -rf $(OCAMLINSTALLDIR); \
+ rm $(STUBSDIR)/$(DLL); \
+ fi
+ rm $(STUBSDIR)/lib$(ARCHIVE).so
+
+#### OCaml only stuff from now on
+
+DEPOBJS = *.ml *.mli
+
+depend:
+ $(OCAMLDEP) $(DEPOBJS) > .depend
+
+%.cmi : $(srcdir)/%.mli
+ if test ! -e $(@:%.cmi=%.mli) -a "x$(srcdir)" != "x." ; then $(LN_S) $< . ; fi
+ $(OCAMLC) -c $(@:%.cmi=%.mli)
+
+%.cmo : $(srcdir)/%.ml
+ if test ! -e $(@:%.cmo=%.ml) -a "x$(srcdir)" != "x." ; then $(LN_S) $< . ; fi
+ $(OCAMLC) -c $(@:%.cmo=%.ml)
+
+%.cmx %.o : $(srcdir)/%.ml
+ if test ! -e $(@:%.cmx=%.ml) -a "x$(srcdir)" != "x." ; then $(LN_S) $< . ; fi
+ $(OCAMLOPT) -c $(@:%.cmx=%.ml)
+
include .depend
OCAMLFIND = @OCAMLFIND@
OCAMLC = $(OCAMLFIND) @OCAMLC@ -package "$(REQUIRES)"
OCAMLOPT = $(OCAMLFIND) @OCAMLOPT@ -package "$(REQUIRES)"
-CMA = ../gdome_xslt/mlgdome2-xslt.cma
-CMXA = ../gdome_xslt/mlgdome2-xslt.cmxa
-INIT_CMO = ../gdome_xslt/gdome_xslt_init.cmo
-INIT_CMX = ../gdome_xslt/gdome_xslt_init.cmx
-INCLUDES = -I ../gdome_xslt/
+CMA = $(top_builddir)/ocaml/gdome_xslt/mlgdome2-xslt.cma
+CMXA = $(top_builddir)/ocaml/gdome_xslt/mlgdome2-xslt.cmxa
+INIT_CMO = $(top_builddir)/ocaml/gdome_xslt/gdome_xslt_init.cmo
+INIT_CMX = $(top_builddir)/ocaml/gdome_xslt/gdome_xslt_init.cmx
+OCAMLC_FLAGS = -I $(top_builddir)/ocaml/gdome_xslt/
EXTRA_DIST = test.ml
CLEANFILES = test{,.o,.opt} test.cm[iox]
endif
test: test.ml $(CMA) $(INIT_CMO)
- $(OCAMLC) -o $@ -linkpkg $(INCLUDES) $(CMA) $(INIT_CMO) $<
+ $(OCAMLC) -o $@ -linkpkg $(OCAMLC_FLAGS) $(CMA) $(INIT_CMO) $<
test.opt: test.ml $(CMXA) $(INIT_CMX)
- $(OCAMLOPT) -o $@ -linkpkg $(INCLUDES) $(CMXA) $(INIT_CMX) $<
+ $(OCAMLOPT) -o $@ -linkpkg $(OCAMLC_FLAGS) $(CMXA) $(INIT_CMX) $<