1 # This Makefile must be included by another one defining:
6 # $IMPLEMENTATION_FILES
7 # $EXTRA_OBJECTS_TO_INSTALL
8 # $EXTRA_OBJECTS_TO_CLEAN
9 # and put in a directory where there is a .depend file.
11 OCAMLFIND_DEST_DIR = @OCAMLFIND_DEST_DIR@
13 PREPROCOPTIONS = -pp camlp4o
15 OCAMLOPTIONS = -package "$(REQUIRES)" -predicates "$(PREDICATES)"
16 OCAMLDEBUGOPTIONS = -g
18 OCAMLC = $(OCAMLFIND) ocamlc $(OCAMLDEBUGOPTIONS) $(OCAMLOPTIONS) $(PREPROCOPTIONS)
19 OCAMLOPT = $(OCAMLFIND) opt $(OCAMLOPTIONS) $(PREPROCOPTIONS)
20 OCAMLDEP = $(OCAMLFIND) ocamldep $(PREPROCOPTIONS)
24 LIBRARIES = $(shell ocamlfind query -recursive -predicates "byte $(PREDICATES)" -format "%d/%a" $(REQUIRES))
25 LIBRARIES_OPT = $(shell ocamlfind query -recursive -predicates "native $(PREDICATES)" -format "%d/%a" $(REQUIRES))
28 ARCHIVE = $(PACKAGE).cma
29 ARCHIVE_OPT = $(PACKAGE).cmxa
30 OBJECTS_TO_INSTALL = $(ARCHIVE) $(ARCHIVE_OPT) $(ARCHIVE_OPT:%.cmxa=%.a) \
31 $(INTERFACE_FILES) $(INTERFACE_FILES:%.mli=%.cmi) \
32 $(EXTRA_OBJECTS_TO_INSTALL)
33 DEPEND_FILES = $(INTERFACE_FILES) $(IMPLEMENTATION_FILES)
35 $(ARCHIVE): $(IMPLEMENTATION_FILES:%.ml=%.cmo) $(LIBRARIES)
36 $(OCAMLC) -a -linkall -o $@ $(IMPLEMENTATION_FILES:%.ml=%.cmo)
38 $(ARCHIVE_OPT): $(IMPLEMENTATION_FILES:%.ml=%.cmx) $(LIBRARIES_OPT)
39 $(OCAMLOPT) -a -linkall -o $@ $(IMPLEMENTATION_FILES:%.ml=%.cmx)
42 all: prereq $(IMPLEMENTATION_FILES:%.ml=%.cmo) $(ARCHIVE)
43 opt: prereq $(IMPLEMENTATION_FILES:%.ml=%.cmx) $(ARCHIVE_OPT)
46 depend: $(DEPEND_FILES)
47 $(OCAMLDEP) $(INTERFACE_FILES) $(IMPLEMENTATION_FILES) > .depend
49 $(PACKAGE).ps: .dep.dot
53 ocamldot < .depend > $@
66 $(IMPLEMENTATION_FILES:%.ml=%.cmo): $(LIBRARIES)
67 $(IMPLEMENTATION_FILES:%.ml=%.cmx): $(LIBRARIES_OPT)
70 rm -f *.cm[ioax] *.cmxa *.o *.a $(EXTRA_OBJECTS_TO_CLEAN)
73 mkdir $(OCAMLFIND_DEST_DIR)/$(PACKAGE)
74 cp $(OBJECTS_TO_INSTALL) $(OCAMLFIND_DEST_DIR)/$(PACKAGE)
77 cd $(OCAMLFIND_DEST_DIR)/$(PACKAGE) && rm -f $(OBJECTS_TO_INSTALL)
78 rmdir $(OCAMLFIND_DEST_DIR)/$(PACKAGE)
81 cd ..; tar cvzf $(PACKAGE)_$(shell date +%s).tar.gz $(PACKAGE)
83 .PHONY: all opt world backup depend install uninstall clean
85 ifneq ($(MAKECMDGOALS), depend)
89 ifeq ($(MAKECMDGOALS), all)
90 $(IMPLEMENTATION_FILES:%.ml=%.cmi): $(LIBRARIES)
93 ifeq ($(MAKECMDGOALS), opt)
94 $(IMPLEMENTATION_FILES:%.ml=%.cmi): $(LIBRARIES_OPT)
97 ifeq ($(MAKECMDGOALS),)
98 $(IMPLEMENTATION_FILES:%.ml=%.cmi): $(LIBRARIES)