3 # This Makefile must be included by another one defining:
7 # $IMPLEMENTATION_FILES
8 # $EXTRA_OBJECTS_TO_INSTALL
9 # $EXTRA_OBJECTS_TO_CLEAN
10 # and put in a directory where there is a .depend file.
12 # $OCAMLFIND must be set to a meaningful vaule, including OCAMLPATH=
14 PREPROCOPTIONS = -pp camlp4o
15 SYNTAXOPTIONS = -syntax camlp4o
17 OCAMLOPTIONS = -package "$(REQUIRES)" -predicates "$(PREDICATES)" -thread
18 OCAMLDEBUGOPTIONS = -g
20 REQUIRES := $(shell $(OCAMLFIND) -query -format '%(requires)' helm-$(PACKAGE))
21 OCAMLC = $(OCAMLFIND) ocamlc $(OCAMLDEBUGOPTIONS) $(OCAMLOPTIONS) $(PREPROCOPTIONS)
22 OCAMLOPT = $(OCAMLFIND) opt $(OCAMLOPTIONS) $(PREPROCOPTIONS)
23 OCAMLDEP = $(OCAMLFIND) ocamldep -package "camlp4 $(CAMLP4REQUIRES)" $(SYNTAXOPTIONS) $(OCAMLDEPOPTIONS)
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))
33 $(foreach X,$(filter-out /usr/lib/ocaml%,$(LIBRARIES)),\
35 $(shell dirname $(X))/*.mli \
36 $(shell dirname $(X))/*.ml \
37 $(shell dirname $(X))/paramodulation/*.ml \
38 $(shell dirname $(X))/paramodultation/*.mli))
41 ARCHIVE = $(PACKAGE).cma
42 ARCHIVE_OPT = $(PACKAGE).cmxa
43 OBJECTS_TO_INSTALL = $(ARCHIVE) $(ARCHIVE_OPT) $(ARCHIVE_OPT:%.cmxa=%.a) \
44 $(INTERFACE_FILES) $(INTERFACE_FILES:%.mli=%.cmi) \
45 $(EXTRA_OBJECTS_TO_INSTALL)
46 DEPEND_FILES = $(INTERFACE_FILES) $(IMPLEMENTATION_FILES)
48 $(ARCHIVE): $(IMPLEMENTATION_FILES:%.ml=%.cmo) $(LIBRARIES)
49 $(H)if [ $(PACKAGE) != dummy ]; then \
50 echo " OCAMLC -a $@";\
51 $(OCAMLC) $(OCAMLARCHIVEOPTIONS) -a -o $@ \
52 $(IMPLEMENTATION_FILES:%.ml=%.cmo); fi
54 $(ARCHIVE_OPT): $(IMPLEMENTATION_FILES:%.ml=%.cmx) $(LIBRARIES_OPT)
55 $(H)if [ $(PACKAGE) != dummy ]; then \
56 echo " OCAMLOPT -a $@";\
57 $(OCAMLOPT) $(OCAMLARCHIVEOPTIONS) -a -o $@ \
58 $(IMPLEMENTATION_FILES:%.ml=%.cmx); fi
61 all: prereq $(IMPLEMENTATION_FILES:%.ml=%.cmo) $(ARCHIVE)
63 opt: prereq $(IMPLEMENTATION_FILES:%.ml=%.cmx) $(ARCHIVE_OPT)
65 test: test.ml $(ARCHIVE)
66 $(OCAMLC) $(ARCHIVE) -linkpkg -o $@ $<
67 test.opt: test.ml $(ARCHIVE_OPT)
68 $(OCAMLOPT) $(ARCHIVE_OPT) -linkpkg -o $@ $<
72 depend:: $(DEPEND_FILES)
74 $(H)$(OCAMLDEP) $(INTERFACE_FILES) $(IMPLEMENTATION_FILES) > .depend
75 depend.opt:: $(DEPEND_FILES)
76 $(H)echo " OCAMLDEP -native"
77 $(H)$(OCAMLDEP) -native \
78 $(INTERFACE_FILES) $(IMPLEMENTATION_FILES) > .depend
80 $(PACKAGE).ps: .dep.dot
84 ocamldot < .depend > $@
96 $(OCAMLC) -dtypes $(PKGS) -c $<
102 ifneq ($(MAKECMDGOALS), clean)
103 $(IMPLEMENTATION_FILES:%.ml=%.cmo): $(LIBRARIES)
104 $(IMPLEMENTATION_FILES:%.ml=%.cmi): $(LIBRARIES_DEPS)
105 $(IMPLEMENTATION_FILES:%.ml=%.cmx): $(LIBRARIES_OPT)
109 rm -f *.cm[ioax] *.cmxa *.o *.a *.annot $(EXTRA_OBJECTS_TO_CLEAN)
110 if [ -f test ]; then rm -f test; else true; fi
111 if [ -f test.opt ]; then rm -f test.opt; else true; fi
114 cd ..; tar cvzf $(PACKAGE)_$(shell date +%s).tar.gz $(PACKAGE)
117 echo "#use \"topfind\";;" > .ocamlinit
118 echo "#thread;;" >> .ocamlinit
119 for p in $(REQUIRES); do echo "#require \"$$p\";;" >> .ocamlinit; done
120 echo "#load \"$(PACKAGE).cma\";;" >> .ocamlinit
122 # $(STATS_EXCLUDE) may be defined in libraries' Makefile to exclude some file
123 # from statistics collection
125 $(shell find . -maxdepth 1 -type f -name \*.ml $(foreach f,$(STATS_EXCLUDE),-not -name $(f))) \
126 $(shell find . -maxdepth 1 -type f -name \*.mli $(foreach f,$(STATS_EXCLUDE),-not -name $(f)))
127 .stats: $(STATS_FILES)
129 echo -n "LOC:" >> .stats
130 wc -l $(STATS_FILES) | tail -1 | awk '{ print $$1 }' >> .stats
132 .PHONY: all opt world backup depend install uninstall clean ocamlinit
134 ifneq ($(MAKECMDGOALS), depend)
135 ifneq ($(MAKECMDGOALS), depend.opt)