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@
12 OCAMLPATH = @OCAMLFIND_META_DIR@
14 PREPROCOPTIONS = -pp camlp4o
15 SYNTAXOPTIONS = -syntax camlp4o
17 OCAMLOPTIONS = -package "$(REQUIRES)" -predicates "$(PREDICATES)" -thread
18 OCAMLDEBUGOPTIONS = -g
20 OCAMLFIND = OCAMLPATH=$(OCAMLPATH):$$OCAMLPATH @OCAMLFIND@
21 OCAMLC = $(OCAMLFIND) ocamlc $(OCAMLDEBUGOPTIONS) $(OCAMLOPTIONS) $(PREPROCOPTIONS)
22 OCAMLOPT = $(OCAMLFIND) opt $(OCAMLOPTIONS) $(PREPROCOPTIONS)
23 OCAMLDEP = $(OCAMLFIND) ocamldep -package "camlp4,$(REQUIRES)" $(SYNTAXOPTIONS)
27 OCAMLC_P4 = $(OCAMLFIND) ocamlc $(OCAMLDEBUGOPTIONS) $(OCAMLOPTIONS) $(SYNTAXOPTIONS)
28 OCAMLOPT_P4 = $(OCAMLFIND) opt $(OCAMLOPTIONS) $(SYNTAXOPTIONS)
30 LIBRARIES = $(shell $(OCAMLFIND) query -recursive -predicates "byte $(PREDICATES)" -format "%d/%a" $(REQUIRES))
31 LIBRARIES_OPT = $(shell $(OCAMLFIND) query -recursive -predicates "native $(PREDICATES)" -format "%d/%a" $(REQUIRES))
34 ARCHIVE = $(PACKAGE).cma
35 ARCHIVE_OPT = $(PACKAGE).cmxa
36 OBJECTS_TO_INSTALL = $(ARCHIVE) $(ARCHIVE_OPT) $(ARCHIVE_OPT:%.cmxa=%.a) \
37 $(INTERFACE_FILES) $(INTERFACE_FILES:%.mli=%.cmi) \
38 $(EXTRA_OBJECTS_TO_INSTALL)
39 DEPEND_FILES = $(INTERFACE_FILES) $(IMPLEMENTATION_FILES)
41 $(ARCHIVE): $(IMPLEMENTATION_FILES:%.ml=%.cmo) $(LIBRARIES)
42 $(OCAMLC) $(OCAMLARCHIVEOPTIONS) -a -o $@ \
43 $(IMPLEMENTATION_FILES:%.ml=%.cmo)
45 $(ARCHIVE_OPT): $(IMPLEMENTATION_FILES:%.ml=%.cmx) $(LIBRARIES_OPT)
46 $(OCAMLOPT) $(OCAMLARCHIVEOPTIONS) -a -o $@ \
47 $(IMPLEMENTATION_FILES:%.ml=%.cmx)
50 all: prereq $(IMPLEMENTATION_FILES:%.ml=%.cmo) $(ARCHIVE)
51 opt: prereq $(IMPLEMENTATION_FILES:%.ml=%.cmx) $(ARCHIVE_OPT)
53 test: test.ml $(ARCHIVE)
54 $(OCAMLC) $(ARCHIVE) -linkpkg -o $@ $<
55 test.opt: test.ml $(ARCHIVE_OPT)
56 $(OCAMLOPT) $(ARCHIVE_OPT) -linkpkg -o $@ $<
58 depend: $(DEPEND_FILES)
59 $(OCAMLDEP) $(INTERFACE_FILES) $(IMPLEMENTATION_FILES) > .depend
61 $(PACKAGE).ps: .dep.dot
65 ocamldot < .depend > $@
74 $(OCAMLC) -dtypes $(PKGS) -c $<
80 $(IMPLEMENTATION_FILES:%.ml=%.cmo): $(LIBRARIES)
81 $(IMPLEMENTATION_FILES:%.ml=%.cmx): $(LIBRARIES_OPT)
84 rm -f *.cm[ioax] *.cmxa *.o *.a $(EXTRA_OBJECTS_TO_CLEAN)
85 if [ -f test ]; then rm -f test; else true; fi
86 if [ -f test.opt ]; then rm -f test.opt; else true; fi
89 mkdir $(OCAMLFIND_DEST_DIR)/$(PACKAGE)
90 cp $(OBJECTS_TO_INSTALL) $(OCAMLFIND_DEST_DIR)/$(PACKAGE)
93 cd $(OCAMLFIND_DEST_DIR)/$(PACKAGE) && rm -f $(OBJECTS_TO_INSTALL)
94 rmdir $(OCAMLFIND_DEST_DIR)/$(PACKAGE)
97 cd ..; tar cvzf $(PACKAGE)_$(shell date +%s).tar.gz $(PACKAGE)
100 echo "#use \"topfind\";;" > .ocamlinit
101 echo "#thread;;" >> .ocamlinit
102 for p in $(REQUIRES); do echo "#require \"$$p\";;" >> .ocamlinit; done
103 echo "#load \"$(PACKAGE).cma\";;" >> .ocamlinit
105 .PHONY: all opt world backup depend install uninstall clean ocamlinit
107 ifneq ($(MAKECMDGOALS), depend)
111 ifeq ($(MAKECMDGOALS), all)
112 $(IMPLEMENTATION_FILES:%.ml=%.cmi): $(LIBRARIES)
115 ifeq ($(MAKECMDGOALS), opt)
116 $(IMPLEMENTATION_FILES:%.ml=%.cmi): $(LIBRARIES_OPT)
119 ifeq ($(MAKECMDGOALS),)
120 $(IMPLEMENTATION_FILES:%.ml=%.cmi): $(LIBRARIES)