OCAMLOPT = ocamlfind ocamlopt $(OCAMLOPTIONS)
OCAMLDEP = ocamldep
+LIBRARIES = $(shell ocamlfind query -recursive -predicates "byte $(PREDICATES)" -format "%d/%a" $(REQUIRES))
+LIBRARIES_OPT = $(shell ocamlfind query -recursive -predicates "native $(PREDICATES)" -format "%d/%a" $(REQUIRES))
+
+
ARCHIVE = $(PACKAGE).cma
ARCHIVE_OPT = $(PACKAGE).cmxa
OBJECTS_TO_INSTALL = $(ARCHIVE) $(ARCHIVE_OPT) $(ARCHIVE_OPT:%.cmxa=%.a) \
$(INTERFACE_FILES) $(INTERFACE_FILES:%.mli=%.cmi) \
$(EXTRA_OBJECTS_TO_INSTALL)
-$(ARCHIVE): $(IMPLEMENTATION_FILES:%.ml=%.cmo)
- $(OCAMLC) -a -o $@ $^
+$(ARCHIVE): $(IMPLEMENTATION_FILES:%.ml=%.cmo) $(LIBRARIES)
+ $(OCAMLC) -a -o $@ $(IMPLEMENTATION_FILES:%.ml=%.cmo)
-$(ARCHIVE_OPT): $(IMPLEMENTATION_FILES:%.ml=%.cmx)
- $(OCAMLOPT) -a -o $@ $^
+$(ARCHIVE_OPT): $(IMPLEMENTATION_FILES:%.ml=%.cmx) $(LIBRARIES_OPT)
+ $(OCAMLOPT) -a -o $@ $(IMPLEMENTATION_FILES:%.ml=%.cmx)
-all: $(ARCHIVE)
-opt: $(ARCHIVE_OPT)
+all: $(IMPLEMENTATION_FILES:%.ml=%.cmo) $(ARCHIVE)
+opt: $(IMPLEMENTATION_FILES:%.ml=%.cmx) $(ARCHIVE_OPT)
depend:
$(OCAMLDEP) $(INTERFACE_FILES) $(IMPLEMENTATION_FILES) > .depend
.SUFFIXES: .ml .mli .cmo .cmi .cmx
-.ml.cmo:
+.ml.cmo: $(LIBRARIES)
$(OCAMLC) -c $<
-.mli.cmi:
+.mli.cmi: $(LIBRARIES)
$(OCAMLC) -c $<
-.ml.cmx:
+.ml.cmx: $(LIBRARIES_OPT)
$(OCAMLOPT) -c $<
clean: