Commit | Line | Data |
---|---|---|
34e49164 C |
1 | ############################################################################## |
2 | # Variables | |
3 | ############################################################################## | |
b1b2de81 C |
4 | |
5 | # The main library | |
feec80c3 C |
6 | ifneq ($(MAKECMDGOALS),distclean) |
7 | include ../Makefile.config | |
8 | endif | |
0708f913 | 9 | |
34e49164 C |
10 | TARGET=commons |
11 | ||
12 | # note: if you add a file (a .mli or .ml), dont forget to redo a 'make depend' | |
feec80c3 C |
13 | MYSRC= commands.ml \ |
14 | common.ml common_extra.ml \ | |
90aeb998 C |
15 | interfaces.ml objet.ml \ |
16 | ocollection.ml \ | |
17 | seti.ml \ | |
18 | oset.ml oassoc.ml osequence.ml ograph.ml \ | |
19 | ocollection/oseti.ml \ | |
20 | ocollection/oseth.ml \ | |
21 | ocollection/osetb.ml \ | |
22 | ocollection/osetpt.ml \ | |
23 | ocollection/oassocb.ml \ | |
24 | ocollection/oassoch.ml \ | |
25 | ocollection/oassoc_buffer.ml \ | |
26 | ocollection/oassoc_cache.ml \ | |
27 | ocollection/oassocid.ml \ | |
28 | oarray.ml \ | |
29 | ocollection/ograph2way.ml \ | |
30 | ograph_simple.ml ograph_extended.ml \ | |
90aeb998 | 31 | glimpse.ml parser_combinators.ml |
34e49164 C |
32 | |
33 | # src from other authors, got from the web or caml hump | |
b1b2de81 C |
34 | SRC=ocamlextra/dumper.ml |
35 | SRC+=ocamlextra/ANSITerminal.ml | |
34e49164 C |
36 | SRC+=ocamlextra/setb.ml ocamlextra/mapb.ml # defunctorized version of standard set/map |
37 | SRC+=ocamlextra/setPt.ml | |
38 | SRC+=$(MYSRC) | |
39 | SRC+=ocamlextra/enum.ml ocamlextra/dynArray.ml | |
b1b2de81 | 40 | SRC+=ocamlextra/suffix_tree.ml ocamlextra/suffix_tree_ext.ml |
34e49164 | 41 | |
708f4980 | 42 | SYSLIBS=str.cma bigarray.cma unix.cma |
34e49164 | 43 | |
91eba41f C |
44 | INCLUDEDIRS=ocamlextra ocollection |
45 | SUBDIRS=ocamlextra ocollection | |
34e49164 C |
46 | |
47 | #----------------------------------------------------------------------------- | |
48 | # Other common (thin wrapper) libraries | |
49 | #----------------------------------------------------------------------------- | |
50 | ||
b1b2de81 C |
51 | #format: XXXSRC, XXXINCLUDE, XXXSYSLIBS |
52 | ||
34e49164 | 53 | #gdbm |
91eba41f | 54 | MYGDBMSRC=ocollection/oassocdbm.ml |
34e49164 C |
55 | GDBMSYSLIBS=dbm.cma |
56 | ||
91eba41f | 57 | #berkeley db (ocamlbdb) |
91eba41f | 58 | MYBDBSRC=ocollection/oassocbdb.ml ocollection/oassocbdb_string.ml |
b1b2de81 | 59 | BDBINCLUDES=-I ../ocamlbdb |
34e49164 C |
60 | BDBSYSLIBS=bdb.cma |
61 | ||
62 | ||
91eba41f | 63 | #lablgtk (ocamlgtk) |
34e49164 | 64 | MYGUISRC=gui.ml |
b1b2de81 | 65 | GUIINCLUDES=-I +lablgtk2 -I +lablgtksourceview -I ../ocamlgtk/src |
34e49164 C |
66 | GUISYSLIBS=lablgtk.cma lablgtksourceview.cma |
67 | ||
91eba41f | 68 | #pycaml (ocamlpython) |
34e49164 | 69 | MYPYSRC=python.ml |
b1b2de81 | 70 | PYINCLUDES=-I ../ocamlpython -I ../../ocamlpython |
34e49164 C |
71 | PYSYSLIBS=python.cma |
72 | ||
73 | #ocamlmpi | |
34e49164 | 74 | MYMPISRC=distribution.ml |
90aeb998 | 75 | MPIINCLUDES=-I ../ocamlmpi -I ../../ocamlmpi -I +ocamlmpi |
34e49164 C |
76 | MPISYSLIBS=mpi.cma |
77 | ||
b1b2de81 C |
78 | #binprot |
79 | MYBINSRC=bin_common.ml | |
80 | BININCLUDES=-I ../ocamltarzan/lib-binprot -I ../../ocamltarzan/lib-binprot | |
91eba41f | 81 | |
34e49164 C |
82 | #----------------------------------------------------------------------------- |
83 | # Other stuff | |
84 | #----------------------------------------------------------------------------- | |
85 | ||
86 | #backtrace | |
34e49164 | 87 | MYBACKTRACESRC=backtrace.ml |
d6ce1786 | 88 | BACKTRACEINCLUDES=-I $(shell $(OCAMLC) -where) |
b1b2de81 | 89 | |
34e49164 C |
90 | |
91 | ############################################################################## | |
92 | # Generic variables | |
93 | ############################################################################## | |
94 | ||
95 | INCLUDES=$(INCLUDEDIRS:%=-I %) $(INCLUDESEXTRA) | |
96 | ||
97 | ############################################################################## | |
98 | # Generic ocaml variables | |
99 | ############################################################################## | |
100 | ||
101 | # This flag can also be used in subdirectories so don't change its name here. | |
102 | # For profiling use: -p -inline 0 | |
755320b0 C |
103 | OCAMLCFLAGS ?= -g |
104 | OPTFLAGS ?= -g | |
34e49164 | 105 | |
90aeb998 | 106 | # The OPTBIN variable is here to allow to use ocamlc.opt instead of |
b1b2de81 | 107 | # ocaml, when it is available, which speeds up compilation. So |
90aeb998 | 108 | # if you want the fast version of the ocaml chain tools, set this var |
b1b2de81 | 109 | # or setenv it to ".opt" in your startup script. |
708f4980 | 110 | OPTBIN ?= #.opt |
b1b2de81 | 111 | |
34e49164 | 112 | # The OCaml tools. |
755320b0 C |
113 | OCAMLC_CMD=$(OCAMLC) $(OCAMLCFLAGS) $(INCLUDES) |
114 | OCAMLOPT_CMD=$(OCAMLOPT) $(OPTFLAGS) $(INCLUDES) | |
feec80c3 C |
115 | OCAMLDEP_CMD=$(OCAMLDEP) $(INCLUDES) |
116 | OCAMLMKTOP_CMD=$(OCAMLMKTOP) -g -custom $(INCLUDES) | |
34e49164 C |
117 | |
118 | ############################################################################## | |
119 | # Top rules | |
120 | ############################################################################## | |
121 | LIB=$(TARGET).cma | |
122 | OPTLIB=$(LIB:.cma=.cmxa) | |
123 | ||
124 | OBJS = $(SRC:.ml=.cmo) | |
125 | OPTOBJS = $(SRC:.ml=.cmx) | |
126 | ||
127 | ||
abad11c5 | 128 | ifneq ($(FEATURE_OCAMLBUILD),yes) |
34e49164 | 129 | all: $(LIB) |
d6ce1786 C |
130 | all.opt: |
131 | @$(MAKE) $(OPTLIB) BUILD_OPT=yes | |
34e49164 C |
132 | opt: all.opt |
133 | top: $(TARGET).top | |
134 | ||
135 | $(LIB): $(OBJS) | |
feec80c3 | 136 | $(OCAMLC_CMD) -a -o $@ $^ |
34e49164 C |
137 | |
138 | $(OPTLIB): $(OPTOBJS) | |
feec80c3 | 139 | $(OCAMLOPT_CMD) -a -o $@ $^ |
34e49164 C |
140 | |
141 | $(TARGET).top: $(OBJS) | |
feec80c3 | 142 | $(OCAMLMKTOP_CMD) -o $@ $(SYSLIBS) $^ |
34e49164 C |
143 | |
144 | clean:: | |
145 | rm -f $(TARGET).top | |
abad11c5 C |
146 | else |
147 | all: | |
148 | cd .. && $(OCAMLBUILD) commons/commons.cma | |
149 | all.opt: | |
150 | cd .. && $(OCAMLBUILD) commons/commons.cmxa | |
151 | clean:: | |
152 | cd .. && $(OCAMLBUILD) -clean | |
153 | endif | |
34e49164 C |
154 | |
155 | ############################################################################## | |
156 | # Other commons libs target | |
157 | ############################################################################## | |
158 | ||
993936c0 | 159 | all_libs: gdbm bdb gui mpi backtrace |
34e49164 | 160 | |
91eba41f | 161 | #----------------------------------------------------------------------------- |
34e49164 C |
162 | gdbm: commons_gdbm.cma |
163 | gdbm.opt: commons_gdbm.cmxa | |
164 | ||
165 | commons_gdbm.cma: $(MYGDBMSRC:.ml=.cmo) | |
feec80c3 | 166 | $(OCAMLC_CMD) -a -o $@ $^ |
34e49164 C |
167 | |
168 | commons_gdbm.cmxa: $(MYGDBMSRC:.ml=.cmx) | |
feec80c3 | 169 | $(OCAMLOPT_CMD) -a -o $@ $^ |
34e49164 C |
170 | |
171 | ||
91eba41f | 172 | #----------------------------------------------------------------------------- |
b1b2de81 | 173 | bdb: |
34e49164 | 174 | $(MAKE) INCLUDESEXTRA="$(BDBINCLUDES)" commons_bdb.cma |
b1b2de81 | 175 | bdb.opt: |
34e49164 C |
176 | $(MAKE) INCLUDESEXTRA="$(BDBINCLUDES)" commons_bdb.cmxa |
177 | ||
178 | commons_bdb.cma: $(MYBDBSRC:.ml=.cmo) | |
feec80c3 | 179 | $(OCAMLC_CMD) -a -o $@ $^ |
34e49164 C |
180 | |
181 | commons_bdb.cmxa: $(MYBDBSRC:.ml=.cmx) | |
feec80c3 | 182 | $(OCAMLOPT_CMD) -a -o $@ $^ |
34e49164 C |
183 | |
184 | ||
185 | ||
91eba41f | 186 | #----------------------------------------------------------------------------- |
34e49164 C |
187 | gui: |
188 | $(MAKE) INCLUDESEXTRA="$(GUIINCLUDES)" commons_gui.cma | |
189 | gui.opt: | |
190 | $(MAKE) INCLUDESEXTRA="$(GUIINCLUDES)" commons_gui.cmxa | |
191 | ||
192 | commons_gui.cma: $(MYGUISRC:.ml=.cmo) | |
feec80c3 | 193 | $(OCAMLC_CMD) -a -o $@ $^ |
34e49164 C |
194 | |
195 | commons_gui.cmxa: $(MYGUISRC:.ml=.cmx) | |
feec80c3 | 196 | $(OCAMLOPT_CMD) -a -o $@ $^ |
34e49164 C |
197 | |
198 | ||
199 | ||
91eba41f | 200 | #----------------------------------------------------------------------------- |
b1b2de81 | 201 | mpi: |
34e49164 | 202 | $(MAKE) INCLUDESEXTRA="$(MPIINCLUDES)" commons_mpi.cma |
b1b2de81 | 203 | mpi.opt: |
34e49164 C |
204 | $(MAKE) INCLUDESEXTRA="$(MPIINCLUDES)" commons_mpi.cmxa |
205 | ||
206 | commons_mpi.cma: $(MYMPISRC:.ml=.cmo) | |
feec80c3 | 207 | $(OCAMLC_CMD) -a -o $@ $^ |
34e49164 C |
208 | |
209 | commons_mpi.cmxa: $(MYMPISRC:.ml=.cmx) | |
feec80c3 | 210 | $(OCAMLOPT_CMD) -a -o $@ $^ |
34e49164 C |
211 | |
212 | #alias | |
213 | distribution: mpi | |
214 | distribution.opt: mpi.opt | |
215 | ||
216 | ||
217 | ||
91eba41f | 218 | #----------------------------------------------------------------------------- |
b1b2de81 | 219 | python: |
34e49164 | 220 | $(MAKE) INCLUDESEXTRA="$(PYINCLUDES)" commons_python.cma |
b1b2de81 | 221 | python.opt: |
34e49164 C |
222 | $(MAKE) INCLUDESEXTRA="$(PYINCLUDES)" commons_python.cmxa |
223 | ||
224 | ||
225 | commons_python.cma: $(MYPYSRC:.ml=.cmo) | |
feec80c3 | 226 | $(OCAMLC_CMD) -a -o $@ $^ |
34e49164 C |
227 | |
228 | commons_python.cmxa: $(MYPYSRC:.ml=.cmx) | |
feec80c3 | 229 | $(OCAMLOPT_CMD) -a -o $@ $^ |
34e49164 | 230 | |
91eba41f | 231 | #----------------------------------------------------------------------------- |
34e49164 C |
232 | backtrace: commons_backtrace.cma |
233 | backtrace.opt: commons_backtrace.cmxa | |
234 | ||
235 | backtrace_c.o: backtrace_c.c | |
236 | $(CC) $(BACKTRACEINCLUDES) -c $^ | |
237 | ||
238 | commons_backtrace.cma: $(MYBACKTRACESRC:.ml=.cmo) backtrace_c.o | |
239 | $(OCAMLMKLIB) -o commons_backtrace $^ | |
240 | ||
241 | commons_backtrace.cmxa: $(MYBACKTRACESRC:.ml=.cmx) backtrace_c.o | |
242 | $(OCAMLMKLIB) -o commons_backtrace $^ | |
243 | ||
244 | clean:: | |
245 | rm -f dllcommons_backtrace.so | |
246 | ||
247 | ||
b1b2de81 C |
248 | |
249 | #----------------------------------------------------------------------------- | |
b1b2de81 C |
250 | binprot: |
251 | $(MAKE) INCLUDESEXTRA="$(BININCLUDES)" commons_bin.cma | |
252 | binprot.opt: | |
253 | $(MAKE) INCLUDESEXTRA="$(BININCLUDES)" commons_bin.cmxa | |
254 | ||
255 | commons_bin.cma: $(MYBINSRC:.ml=.cmo) | |
feec80c3 | 256 | $(OCAMLC_CMD) -a -o $@ $^ |
b1b2de81 C |
257 | |
258 | commons_bin.cmxa: $(MYBINSRC:.ml=.cmx) | |
feec80c3 | 259 | $(OCAMLOPT_CMD) -a -o $@ $^ |
b1b2de81 C |
260 | |
261 | ############################################################################## | |
262 | # The global "features" lib wrapper | |
263 | ############################################################################## | |
264 | ||
265 | features: commons_features.cma | |
266 | features.opt: commons_features.cmxa | |
267 | ||
268 | commons_features.cma: features.cmo | |
feec80c3 | 269 | $(OCAMLC_CMD) -a -o $@ $^ |
b1b2de81 C |
270 | |
271 | commons_features.cmxa: features.cmx | |
feec80c3 | 272 | $(OCAMLOPT_CMD) -a -o $@ $^ |
b1b2de81 C |
273 | |
274 | ||
34e49164 C |
275 | ############################################################################## |
276 | # Developer rules | |
277 | ############################################################################## | |
278 | ||
279 | tags: | |
280 | otags -no-mli-tags -r . | |
281 | ||
282 | clean:: | |
b1b2de81 | 283 | rm -f gmon.out |
34e49164 C |
284 | |
285 | forprofiling: | |
286 | $(MAKE) OPTFLAGS="-p -inline 0 " opt | |
287 | ||
288 | dependencygraph: | |
289 | ocamldep *.mli *.ml > /tmp/dependfull.depend | |
290 | ocamldot -fullgraph /tmp/dependfull.depend > /tmp/dependfull.dot | |
291 | dot -Tps /tmp/dependfull.dot > /tmp/dependfull.ps | |
292 | ||
293 | dependencygraph2: | |
294 | find -name "*.ml" |grep -v "scripts" | xargs ocamldep -I commons -I globals -I ctl -I parsing_cocci -I parsing_c -I engine -I popl -I extra > /tmp/dependfull.depend | |
295 | ocamldot -fullgraph /tmp/dependfull.depend > /tmp/dependfull.dot | |
296 | dot -Tps /tmp/dependfull.dot > /tmp/dependfull.ps | |
297 | ||
298 | ||
299 | ############################################################################## | |
300 | # Generic rules | |
301 | ############################################################################## | |
302 | .SUFFIXES: | |
303 | .SUFFIXES: .ml .mli .cmo .cmi .cmx | |
304 | ||
305 | .ml.cmo: | |
feec80c3 | 306 | $(OCAMLC_CMD) -c $< |
34e49164 | 307 | .mli.cmi: |
feec80c3 | 308 | $(OCAMLC_CMD) -c $< |
34e49164 | 309 | .ml.cmx: |
feec80c3 | 310 | $(OCAMLOPT_CMD) -c $< |
34e49164 C |
311 | |
312 | clean:: | |
313 | rm -f *.cm[iox] *.o *.a *.cma *.cmxa *.annot | |
b1b2de81 | 314 | rm -f *~ .*~ #*# |
34e49164 C |
315 | |
316 | clean:: | |
91eba41f C |
317 | for i in $(SUBDIRS); do (cd $$i; \ |
318 | rm -f *.cm[iox] *.o *.a *.cma *.cmxa *.annot *~ .*~ ; \ | |
319 | cd ..; ) \ | |
320 | done | |
feec80c3 | 321 | rm -f .depend |
34e49164 | 322 | |
feec80c3 C |
323 | distclean: clean |
324 | rm -f commands.ml | |
34e49164 | 325 | |
feec80c3 C |
326 | .PHONEY: depend |
327 | .depend depend: | |
328 | $(OCAMLDEP_CMD) *.mli *.ml > .depend | |
329 | for i in $(SUBDIRS); do $(OCAMLDEP_CMD) $$i/*.ml $$i/*.mli >> .depend; done | |
34e49164 | 330 | |
feec80c3 C |
331 | ifneq ($(MAKECMDGOALS),clean) |
332 | ifneq ($(MAKECMDGOALS),distclean) | |
abad11c5 | 333 | ifneq ($(FEATURE_OCAMLBUILD),yes) |
34e49164 | 334 | -include .depend |
feec80c3 C |
335 | endif |
336 | endif | |
abad11c5 | 337 | endif |
d6ce1786 C |
338 | |
339 | include ../Makefile.common |