permit multiline comments and strings in macros
[bpt/coccinelle.git] / commons / Makefile
CommitLineData
34e49164
C
1##############################################################################
2# Variables
3##############################################################################
b1b2de81
C
4
5# The main library
feec80c3
C
6ifneq ($(MAKECMDGOALS),distclean)
7include ../Makefile.config
8endif
0708f913 9
34e49164
C
10TARGET=commons
11
12# note: if you add a file (a .mli or .ml), dont forget to redo a 'make depend'
feec80c3
C
13MYSRC= 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
34SRC=ocamlextra/dumper.ml
35SRC+=ocamlextra/ANSITerminal.ml
34e49164
C
36SRC+=ocamlextra/setb.ml ocamlextra/mapb.ml # defunctorized version of standard set/map
37SRC+=ocamlextra/setPt.ml
38SRC+=$(MYSRC)
39SRC+=ocamlextra/enum.ml ocamlextra/dynArray.ml
b1b2de81 40SRC+=ocamlextra/suffix_tree.ml ocamlextra/suffix_tree_ext.ml
34e49164 41
708f4980 42SYSLIBS=str.cma bigarray.cma unix.cma
34e49164 43
91eba41f
C
44INCLUDEDIRS=ocamlextra ocollection
45SUBDIRS=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 54MYGDBMSRC=ocollection/oassocdbm.ml
34e49164
C
55GDBMSYSLIBS=dbm.cma
56
91eba41f 57#berkeley db (ocamlbdb)
91eba41f 58MYBDBSRC=ocollection/oassocbdb.ml ocollection/oassocbdb_string.ml
b1b2de81 59BDBINCLUDES=-I ../ocamlbdb
34e49164
C
60BDBSYSLIBS=bdb.cma
61
62
91eba41f 63#lablgtk (ocamlgtk)
34e49164 64MYGUISRC=gui.ml
b1b2de81 65GUIINCLUDES=-I +lablgtk2 -I +lablgtksourceview -I ../ocamlgtk/src
34e49164
C
66GUISYSLIBS=lablgtk.cma lablgtksourceview.cma
67
91eba41f 68#pycaml (ocamlpython)
34e49164 69MYPYSRC=python.ml
b1b2de81 70PYINCLUDES=-I ../ocamlpython -I ../../ocamlpython
34e49164
C
71PYSYSLIBS=python.cma
72
73#ocamlmpi
34e49164 74MYMPISRC=distribution.ml
90aeb998 75MPIINCLUDES=-I ../ocamlmpi -I ../../ocamlmpi -I +ocamlmpi
34e49164
C
76MPISYSLIBS=mpi.cma
77
b1b2de81
C
78#binprot
79MYBINSRC=bin_common.ml
80BININCLUDES=-I ../ocamltarzan/lib-binprot -I ../../ocamltarzan/lib-binprot
91eba41f 81
34e49164
C
82#-----------------------------------------------------------------------------
83# Other stuff
84#-----------------------------------------------------------------------------
85
86#backtrace
34e49164 87MYBACKTRACESRC=backtrace.ml
d6ce1786 88BACKTRACEINCLUDES=-I $(shell $(OCAMLC) -where)
b1b2de81 89
34e49164
C
90
91##############################################################################
92# Generic variables
93##############################################################################
94
95INCLUDES=$(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
103OCAMLCFLAGS ?= -g
104OPTFLAGS ?= -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 110OPTBIN ?= #.opt
b1b2de81 111
34e49164 112# The OCaml tools.
755320b0
C
113OCAMLC_CMD=$(OCAMLC) $(OCAMLCFLAGS) $(INCLUDES)
114OCAMLOPT_CMD=$(OCAMLOPT) $(OPTFLAGS) $(INCLUDES)
feec80c3
C
115OCAMLDEP_CMD=$(OCAMLDEP) $(INCLUDES)
116OCAMLMKTOP_CMD=$(OCAMLMKTOP) -g -custom $(INCLUDES)
34e49164
C
117
118##############################################################################
119# Top rules
120##############################################################################
121LIB=$(TARGET).cma
122OPTLIB=$(LIB:.cma=.cmxa)
123
124OBJS = $(SRC:.ml=.cmo)
125OPTOBJS = $(SRC:.ml=.cmx)
126
127
abad11c5 128ifneq ($(FEATURE_OCAMLBUILD),yes)
34e49164 129all: $(LIB)
d6ce1786
C
130all.opt:
131 @$(MAKE) $(OPTLIB) BUILD_OPT=yes
34e49164
C
132opt: all.opt
133top: $(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
144clean::
145 rm -f $(TARGET).top
abad11c5
C
146else
147all:
148 cd .. && $(OCAMLBUILD) commons/commons.cma
149all.opt:
150 cd .. && $(OCAMLBUILD) commons/commons.cmxa
151clean::
152 cd .. && $(OCAMLBUILD) -clean
153endif
34e49164
C
154
155##############################################################################
156# Other commons libs target
157##############################################################################
158
993936c0 159all_libs: gdbm bdb gui mpi backtrace
34e49164 160
91eba41f 161#-----------------------------------------------------------------------------
34e49164
C
162gdbm: commons_gdbm.cma
163gdbm.opt: commons_gdbm.cmxa
164
165commons_gdbm.cma: $(MYGDBMSRC:.ml=.cmo)
feec80c3 166 $(OCAMLC_CMD) -a -o $@ $^
34e49164
C
167
168commons_gdbm.cmxa: $(MYGDBMSRC:.ml=.cmx)
feec80c3 169 $(OCAMLOPT_CMD) -a -o $@ $^
34e49164
C
170
171
91eba41f 172#-----------------------------------------------------------------------------
b1b2de81 173bdb:
34e49164 174 $(MAKE) INCLUDESEXTRA="$(BDBINCLUDES)" commons_bdb.cma
b1b2de81 175bdb.opt:
34e49164
C
176 $(MAKE) INCLUDESEXTRA="$(BDBINCLUDES)" commons_bdb.cmxa
177
178commons_bdb.cma: $(MYBDBSRC:.ml=.cmo)
feec80c3 179 $(OCAMLC_CMD) -a -o $@ $^
34e49164
C
180
181commons_bdb.cmxa: $(MYBDBSRC:.ml=.cmx)
feec80c3 182 $(OCAMLOPT_CMD) -a -o $@ $^
34e49164
C
183
184
185
91eba41f 186#-----------------------------------------------------------------------------
34e49164
C
187gui:
188 $(MAKE) INCLUDESEXTRA="$(GUIINCLUDES)" commons_gui.cma
189gui.opt:
190 $(MAKE) INCLUDESEXTRA="$(GUIINCLUDES)" commons_gui.cmxa
191
192commons_gui.cma: $(MYGUISRC:.ml=.cmo)
feec80c3 193 $(OCAMLC_CMD) -a -o $@ $^
34e49164
C
194
195commons_gui.cmxa: $(MYGUISRC:.ml=.cmx)
feec80c3 196 $(OCAMLOPT_CMD) -a -o $@ $^
34e49164
C
197
198
199
91eba41f 200#-----------------------------------------------------------------------------
b1b2de81 201mpi:
34e49164 202 $(MAKE) INCLUDESEXTRA="$(MPIINCLUDES)" commons_mpi.cma
b1b2de81 203mpi.opt:
34e49164
C
204 $(MAKE) INCLUDESEXTRA="$(MPIINCLUDES)" commons_mpi.cmxa
205
206commons_mpi.cma: $(MYMPISRC:.ml=.cmo)
feec80c3 207 $(OCAMLC_CMD) -a -o $@ $^
34e49164
C
208
209commons_mpi.cmxa: $(MYMPISRC:.ml=.cmx)
feec80c3 210 $(OCAMLOPT_CMD) -a -o $@ $^
34e49164
C
211
212#alias
213distribution: mpi
214distribution.opt: mpi.opt
215
216
217
91eba41f 218#-----------------------------------------------------------------------------
b1b2de81 219python:
34e49164 220 $(MAKE) INCLUDESEXTRA="$(PYINCLUDES)" commons_python.cma
b1b2de81 221python.opt:
34e49164
C
222 $(MAKE) INCLUDESEXTRA="$(PYINCLUDES)" commons_python.cmxa
223
224
225commons_python.cma: $(MYPYSRC:.ml=.cmo)
feec80c3 226 $(OCAMLC_CMD) -a -o $@ $^
34e49164
C
227
228commons_python.cmxa: $(MYPYSRC:.ml=.cmx)
feec80c3 229 $(OCAMLOPT_CMD) -a -o $@ $^
34e49164 230
91eba41f 231#-----------------------------------------------------------------------------
34e49164
C
232backtrace: commons_backtrace.cma
233backtrace.opt: commons_backtrace.cmxa
234
235backtrace_c.o: backtrace_c.c
236 $(CC) $(BACKTRACEINCLUDES) -c $^
237
238commons_backtrace.cma: $(MYBACKTRACESRC:.ml=.cmo) backtrace_c.o
239 $(OCAMLMKLIB) -o commons_backtrace $^
240
241commons_backtrace.cmxa: $(MYBACKTRACESRC:.ml=.cmx) backtrace_c.o
242 $(OCAMLMKLIB) -o commons_backtrace $^
243
244clean::
245 rm -f dllcommons_backtrace.so
246
247
b1b2de81
C
248
249#-----------------------------------------------------------------------------
b1b2de81
C
250binprot:
251 $(MAKE) INCLUDESEXTRA="$(BININCLUDES)" commons_bin.cma
252binprot.opt:
253 $(MAKE) INCLUDESEXTRA="$(BININCLUDES)" commons_bin.cmxa
254
255commons_bin.cma: $(MYBINSRC:.ml=.cmo)
feec80c3 256 $(OCAMLC_CMD) -a -o $@ $^
b1b2de81
C
257
258commons_bin.cmxa: $(MYBINSRC:.ml=.cmx)
feec80c3 259 $(OCAMLOPT_CMD) -a -o $@ $^
b1b2de81
C
260
261##############################################################################
262# The global "features" lib wrapper
263##############################################################################
264
265features: commons_features.cma
266features.opt: commons_features.cmxa
267
268commons_features.cma: features.cmo
feec80c3 269 $(OCAMLC_CMD) -a -o $@ $^
b1b2de81
C
270
271commons_features.cmxa: features.cmx
feec80c3 272 $(OCAMLOPT_CMD) -a -o $@ $^
b1b2de81
C
273
274
34e49164
C
275##############################################################################
276# Developer rules
277##############################################################################
278
279tags:
280 otags -no-mli-tags -r .
281
282clean::
b1b2de81 283 rm -f gmon.out
34e49164
C
284
285forprofiling:
286 $(MAKE) OPTFLAGS="-p -inline 0 " opt
287
288dependencygraph:
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
293dependencygraph2:
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
312clean::
313 rm -f *.cm[iox] *.o *.a *.cma *.cmxa *.annot
b1b2de81 314 rm -f *~ .*~ #*#
34e49164
C
315
316clean::
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
323distclean: 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
331ifneq ($(MAKECMDGOALS),clean)
332ifneq ($(MAKECMDGOALS),distclean)
abad11c5 333ifneq ($(FEATURE_OCAMLBUILD),yes)
34e49164 334-include .depend
feec80c3
C
335endif
336endif
abad11c5 337endif
d6ce1786
C
338
339include ../Makefile.common