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