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