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