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 or .depend.opt file.
12 # $OCAMLFIND must be set to a meaningful vaule, including OCAMLPATH=
20 PREPROCOPTIONS = -pp camlp5o
21 SYNTAXOPTIONS = -syntax camlp5o
23 OCAMLOPTIONS = -package "$(REQUIRES)" -predicates "$(PREDICATES)" -thread -rectypes $(ANNOTOPTION)
24 OCAMLDEBUGOPTIONS = -g
27 REQUIRES := $(shell $(OCAMLFIND) -query -format '%(requires)' helm-$(PACKAGE))
28 OCAMLC = $(OCAMLFIND) ocamlc$(OCAML_PROF) $(OCAMLDEBUGOPTIONS) $(OCAMLOPTIONS) $(PREPROCOPTIONS)
29 #OCAMLOPT_DEBUG_FLAGS = -p
30 OCAMLOPT = $(OCAMLFIND) opt $(OCAMLOPTIONS) $(PREPROCOPTIONS) $(OCAMLOPT_DEBUG_FLAGS)
31 OCAMLDEP = $(OCAMLFIND) ocamldep -package "camlp5 $(CAMLP5REQUIRES)" $(SYNTAXOPTIONS) $(OCAMLDEPOPTIONS)
35 OCAMLC_P4 = $(OCAMLFIND) ocamlc $(OCAMLDEBUGOPTIONS) $(OCAMLOPTIONS) $(SYNTAXOPTIONS)
36 OCAMLOPT_P4 = $(OCAMLFIND) opt $(OCAMLOPTIONS) $(SYNTAXOPTIONS)
38 LIBRARIES = $(shell $(OCAMLFIND) query -recursive -predicates "byte $(PREDICATES)" -format "%d/%a" $(REQUIRES))
39 LIBRARIES_OPT = $(shell $(OCAMLFIND) query -recursive -predicates "native $(PREDICATES)" -format "%d/%a" $(REQUIRES))
41 $(foreach X,$(filter-out /usr/lib/ocaml%,$(LIBRARIES)),\
43 $(shell dirname $(X))/*.mli \
44 $(shell dirname $(X))/*.ml \
45 $(shell dirname $(X))/paramodulation/*.ml \
46 $(shell dirname $(X))/paramodultation/*.mli))
49 ARCHIVE = $(PACKAGE).cma
50 ARCHIVE_OPT = $(PACKAGE).cmxa
51 OBJECTS_TO_INSTALL = $(ARCHIVE) $(ARCHIVE_OPT) $(ARCHIVE_OPT:%.cmxa=%.a) \
52 $(INTERFACE_FILES) $(INTERFACE_FILES:%.mli=%.cmi) \
53 $(EXTRA_OBJECTS_TO_INSTALL)
54 DEPEND_FILES = $(INTERFACE_FILES) $(IMPLEMENTATION_FILES)
56 $(ARCHIVE): $(IMPLEMENTATION_FILES:%.ml=%.cmo) $(LIBRARIES)
57 $(H)if [ $(PACKAGE) != dummy ]; then \
58 echo " OCAMLC -a $@";\
59 $(OCAMLC) $(OCAMLARCHIVEOPTIONS) -a -o $@ \
60 $(IMPLEMENTATION_FILES:%.ml=%.cmo); fi
62 $(ARCHIVE_OPT): $(IMPLEMENTATION_FILES:%.ml=%.cmx) $(LIBRARIES_OPT)
63 $(H)if [ $(PACKAGE) != dummy ]; then \
64 echo " OCAMLOPT -a $@";\
65 $(OCAMLOPT) $(OCAMLARCHIVEOPTIONS) -a -o $@ \
66 $(IMPLEMENTATION_FILES:%.ml=%.cmx); fi
69 all: prereq $(IMPLEMENTATION_FILES:%.ml=%.cmo) $(ARCHIVE)
71 opt: prereq $(IMPLEMENTATION_FILES:%.ml=%.cmx) $(ARCHIVE_OPT)
73 test: test.ml $(ARCHIVE)
74 $(OCAMLC) $(ARCHIVE) -linkpkg -o $@ $<
75 test.opt: test.ml $(ARCHIVE_OPT)
76 $(OCAMLOPT) $(ARCHIVE_OPT) -linkpkg -o $@ $<
80 depend:: $(DEPEND_FILES)
82 $(H)$(OCAMLDEP) $(INTERFACE_FILES) $(IMPLEMENTATION_FILES) > .depend
83 depend.opt:: $(DEPEND_FILES)
84 $(H)echo " OCAMLDEP -native"
85 $(H)$(OCAMLDEP) -native \
86 $(INTERFACE_FILES) $(IMPLEMENTATION_FILES) > .depend.opt
88 $(PACKAGE).ps: .dep.dot
91 # FG: .depend or .depend.opt?
93 ocamldot < .depend > $@
103 $(H)$(OCAMLOPT) -c $<
105 $(OCAMLC) -dtypes $(PKGS) -c $<
111 ifneq ($(MAKECMDGOALS), clean)
112 $(IMPLEMENTATION_FILES:%.ml=%.cmo): $(LIBRARIES)
113 $(IMPLEMENTATION_FILES:%.ml=%.cmi): $(LIBRARIES_DEPS)
114 $(IMPLEMENTATION_FILES:%.ml=%.cmx): $(LIBRARIES_OPT)
118 rm -f *.cm[ioax] *.cmxa *.o *.a *.annot $(EXTRA_OBJECTS_TO_CLEAN)
119 if [ -f test ]; then rm -f test; else true; fi
120 if [ -f test.opt ]; then rm -f test.opt; else true; fi
123 cd ..; tar cvzf $(PACKAGE)_$(shell date +%s).tar.gz $(PACKAGE)
126 echo "#use \"topfind\";;" > .ocamlinit
127 echo "#thread;;" >> .ocamlinit
128 for p in $(REQUIRES); do echo "#require \"$$p\";;" >> .ocamlinit; done
129 echo "#load \"$(PACKAGE).cma\";;" >> .ocamlinit
131 # $(STATS_EXCLUDE) may be defined in libraries' Makefile to exclude some file
132 # from statistics collection
134 $(shell find . -maxdepth 1 -type f -name \*.ml $(foreach f,$(STATS_EXCLUDE),-not -name $(f))) \
135 $(shell find . -maxdepth 1 -type f -name \*.mli $(foreach f,$(STATS_EXCLUDE),-not -name $(f)))
136 .stats: $(STATS_FILES)
138 echo -n "LOC:" >> .stats
139 wc -l $(STATS_FILES) | tail -1 | awk '{ print $$1 }' >> .stats
141 .PHONY: all opt backup depend depend.opt install uninstall clean ocamlinit
143 ifeq ($(MAKECMDGOALS),)
147 ifeq ($(MAKECMDGOALS), all)
151 ifeq ($(MAKECMDGOALS), opt)