Release coccinelle-0.1.6
[bpt/coccinelle.git] / .#Makefile.1.121
CommitLineData
113803cf
C
1# Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
2# Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller
3# This file is part of Coccinelle.
4#
5# Coccinelle is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, according to version 2 of the License.
8#
9# Coccinelle is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
16#
17# The authors reserve the right to distribute this or future versions of
18# Coccinelle under other licenses.
19
20
21#############################################################################
22# Configuration section
23#############################################################################
24
25-include Makefile.config
26
27VERSION=$(shell cat globals/config.ml |grep version |perl -p -e 's/.*"(.*)".*/$$1/;')
28
29##############################################################################
30# Variables
31##############################################################################
32TARGET=spatch
33
34SRC=flag_cocci.ml cocci.ml testing.ml test.ml main.ml
35
36
37ifeq ($(FEATURE_PYTHON),1)
38PYCMA=pycaml/pycaml.cma
39PYDIR=pycaml
40PYLIB=dllpycaml_stubs.so
41# the following is essential for Coccinelle to compile under gentoo (wierd)
42OPTLIBFLAGS=-cclib dllpycaml_stubs.so
43else
44PYCMA=
45PYDIR=
46PYLIB=
47OPTLIBFLAGS=
48endif
49
50
51SYSLIBS=str.cma unix.cma
52LIBS=commons/commons.cma globals/globals.cma\
53 ctl/ctl.cma \
54 parsing_cocci/cocci_parser.cma parsing_c/parsing_c.cma \
55 engine/cocciengine.cma popl09/popl.cma \
56 extra/extra.cma $(PYCMA) python/coccipython.cma
57
58MAKESUBDIRS=commons globals menhirlib $(PYDIR) ctl parsing_cocci parsing_c \
59 engine popl09 extra python
60INCLUDEDIRS=commons commons/ocamlextra globals menhirlib $(PYDIR) ctl \
61 parsing_cocci parsing_c engine popl09 extra python
62
63##############################################################################
64# Generic variables
65##############################################################################
66
67INCLUDES=$(INCLUDEDIRS:%=-I %)
68
69OBJS= $(SRC:.ml=.cmo)
70OPTOBJS= $(SRC:.ml=.cmx)
71
72EXEC=$(TARGET)
73
74##############################################################################
75# Generic ocaml variables
76##############################################################################
77
78OCAMLCFLAGS= #-g -dtypes # -w A
79
80# for profiling add -p -inline 0
81# but 'make forprofiling' below does that for you.
82# This flag is also used in subdirectories so don't change its name here.
83OPTFLAGS=
84# the following is essential for Coccinelle to compile under gentoo
85# but is now defined above in this file
86#OPTLIBFLAGS=-cclib dllpycaml_stubs.so
87
88# the OPTBIN variable is here to allow to use ocamlc.opt instead of
89# ocaml, when it is available, which speeds up compilation. So
90# if you want the fast version of the ocaml chain tools, set this var
91# or setenv it to ".opt" in your startup script.
92OPTBIN= #.opt
93
94OCAMLC=ocamlc$(OPTBIN) $(OCAMLCFLAGS) $(INCLUDES)
95OCAMLOPT=ocamlopt$(OPTBIN) $(OPTFLAGS) $(INCLUDES)
96OCAMLLEX=ocamllex #-ml # -ml for debugging lexer, but slightly slower
97OCAMLYACC=ocamlyacc -v
98OCAMLDEP=ocamldep #$(INCLUDES)
99OCAMLMKTOP=ocamlmktop -g -custom $(INCLUDES)
100
101# can also be set via 'make static'
102STATIC= #-ccopt -static
103
104# can also be unset via 'make purebytecode'
105BYTECODE_STATIC=-custom
106
107##############################################################################
108# Top rules
109##############################################################################
110.PHONY: all all.opt opt top clean configure
111.PHONY: $(MAKESUBDIRS) $(MAKESUBDIRS:%=%.opt)
112
113all:
114 $(MAKE) subdirs
115 $(MAKE) $(EXEC)
116
117opt:
118 $(MAKE) subdirs.opt
119 $(MAKE) $(EXEC).opt
120
121all.opt: opt
122top: $(EXEC).top
123
124subdirs: $(MAKESUBDIRS)
125subdirs.opt: $(MAKESUBDIRS:%=%.opt)
126
127$(MAKESUBDIRS):
128 $(MAKE) -C $@ OCAMLCFLAGS="$(OCAMLCFLAGS)" all
129
130$(MAKESUBDIRS:%=%.opt):
131 $(MAKE) -C $(@:%.opt=%) OCAMLCFLAGS="$(OCAMLCFLAGS)" all.opt
132
133commons:
134globals:
135menhirlib:
136parsing_cocci:globals menhirlib
137parsing_c:parsing_cocci
138ctl:globals commons
139engine: parsing_cocci parsing_c ctl
140popl09:engine
141extra: parsing_cocci parsing_c ctl
142pycaml:
143python:pycaml parsing_cocci parsing_c
144
145commons.opt:
146globals.opt:
147menhirlib.opt:
148parsing_cocci.opt:globals.opt menhirlib.opt
149parsing_c.opt:parsing_cocci.opt
150ctl.opt:globals.opt commons.opt
151engine.opt: parsing_cocci.opt parsing_c.opt ctl.opt
152popl09.opt:engine.opt
153extra.opt: parsing_cocci.opt parsing_c.opt ctl.opt
154pycaml.opt:
155python.opt:pycaml.opt parsing_cocci.opt parsing_c.opt
156
157clean::
158 set -e; for i in $(MAKESUBDIRS); do $(MAKE) -C $$i clean; done
159
160configure:
161 ./configure
162
163$(LIBS): #$(MAKESUBDIRS)
164$(LIBS:.cma=.cmxa): #$(MAKESUBDIRS:%=%.opt)
165
166$(OBJS):$(LIBS)
167$(OPTOBJS):$(LIBS:.cma=.cmxa)
168
169$(EXEC): $(LIBS) $(OBJS)
170 $(OCAMLC) $(BYTECODE_STATIC) -o $@ $(SYSLIBS) $^
171
172$(EXEC).opt: $(LIBS:.cma=.cmxa) $(OPTOBJS)
173 $(OCAMLOPT) $(STATIC) -o $@ $(SYSLIBS:.cma=.cmxa) $(OPTLIBFLAGS) $^
174
175$(EXEC).top: $(LIBS) $(OBJS)
176 $(OCAMLMKTOP) -custom -o $@ $(SYSLIBS) $^
177
178clean::
179 rm -f $(TARGET) $(TARGET).opt $(TARGET).top
180
181clean::
182 rm -f dllpycaml_stubs.so
183
184
185.PHONY: tools all configure
186
187tools:
188 $(MAKE) -C tools
189clean::
190 $(MAKE) -C tools clean
191
192
193static:
194 rm -f spatch.opt spatch
195 $(MAKE) STATIC="-ccopt -static" spatch.opt
196 cp spatch.opt spatch
197
198purebytecode:
199 rm -f spatch.opt spatch
200 $(MAKE) BYTECODE_STATIC="" spatch
201
202
203##############################################################################
204# Install
205##############################################################################
206
207# don't remove DESTDIR, it can be set by package build system like ebuild
208install: all
209 mkdir -p $(DESTDIR)$(BINDIR)
210 mkdir -p $(DESTDIR)$(LIBDIR)
211 mkdir -p $(DESTDIR)$(SHAREDIR)
212 mkdir -p $(DESTDIR)$(MANDIR)/man1
213 cp spatch $(DESTDIR)$(BINDIR)
214 cp standard.h $(DESTDIR)$(SHAREDIR)
215 cp standard.iso $(DESTDIR)$(SHAREDIR)
216 cp docs/spatch.1 $(DESTDIR)$(MANDIR)/man1/
217 mkdir -p $(DESTDIR)$(SHAREDIR)/python
218 cp -a python/coccilib $(DESTDIR)$(SHAREDIR)/python
219 cp -f dllpycaml_stubs.so $(DESTDIR)$(LIBDIR)
220 @echo ""
221 @echo "You can also install spatch by copying the program spatch"
222 @echo "(available in this directory) anywhere you want and"
223 @echo "give it the right options to find its configuration files."
224
225uninstall:
226 rm -f $(DESTDIR)$(BINDIR)/spatch
227 rm -f $(DESTDIR)$(LIBDIR)/dllpycaml_stubs.so
228 rm -f $(DESTDIR)$(SHAREDIR)/standard.h
229 rm -f $(DESTDIR)$(SHAREDIR)/standard.iso
230 rm -rf $(DESTDIR)$(SHAREDIR)/python/coccilib
231 rm -f $(DESTDIR)$(MANDIR)/man1/spatch.1
232
233
234
235version:
236 @echo $(VERSION)
237
238
239##############################################################################
240# Package rules
241##############################################################################
242
243PACKAGE=coccinelle-$(VERSION)
244
245BINSRC=spatch env.sh env.csh standard.h standard.iso \
246 *.txt docs/* \
247 demos/foo.* demos/simple.*
248# $(PYLIB) python/coccilib/ demos/printloc.*
249BINSRC2=$(BINSRC:%=$(PACKAGE)/%)
250
251TMP=/tmp
252OCAMLVERSION=$(shell ocaml -version |perl -p -e 's/.*version (.*)/$$1/;')
253
254# Procedure to do first time:
255# cd ~/release
256# cvs checkout coccinelle
257# cd coccinelle
258# cvs update -d -P
259# touch **/*
260# make licensify
261# remember to comment the -g -dtypes in this Makefile
262
263# Procedure to do each time:
264# cvs update
265# modify globals/config.ml
266# cd globals/; cvs commit -m"new version" (do not commit from the root!)
267# ./configure --without-python
268# make package
269# make website
270# Check also that run an ocaml in /usr/bin
271
272# To test you can try compile and run spatch from different instances
273# like my ~/coccinelle, ~/release/coccinelle, and the /tmp/coccinelle-0.X
274# downloaded from the website.
275
276# For 'make srctar' it must done from a clean
277# repo such as ~/release/coccinelle. It must also be a repo where
278# the scripts/licensify has been run at least once.
279# For the 'make bintar' I can do it from my original repo.
280
281
282package:
283 make srctar
284 make bintar
285 make staticbintar
286 make bytecodetar
287
288# I currently pre-generate the parser so the user does not have to
289# install menhir on his machine. I also do a few cleanups like 'rm todo_pos'.
290# You may have first to do a 'make licensify'.
291srctar:
292 make clean
293 cp -a . $(TMP)/$(PACKAGE)
294 cd $(TMP)/$(PACKAGE); cd parsing_cocci/; make parser_cocci_menhir.ml
295 cd $(TMP)/$(PACKAGE); rm todo_pos
296 cd $(TMP); tar cvfz $(PACKAGE).tgz --exclude-vcs $(PACKAGE)
297 rm -rf $(TMP)/$(PACKAGE)
298
299
300bintar: all
301 rm -f $(TMP)/$(PACKAGE)
302 ln -s `pwd` $(TMP)/$(PACKAGE)
303 cd $(TMP); tar cvfz $(PACKAGE)-bin-x86.tgz --exclude-vcs $(BINSRC2)
304 rm -f $(TMP)/$(PACKAGE)
305
306staticbintar: all.opt
307 rm -f $(TMP)/$(PACKAGE)
308 ln -s `pwd` $(TMP)/$(PACKAGE)
309 make static
310 cd $(TMP); tar cvfz $(PACKAGE)-bin-x86-static.tgz --exclude-vcs $(BINSRC2)
311 rm -f $(TMP)/$(PACKAGE)
312
313# add ocaml version in name ?
314bytecodetar: all
315 rm -f $(TMP)/$(PACKAGE)
316 ln -s `pwd` $(TMP)/$(PACKAGE)
317 make purebytecode
318 cd $(TMP); tar cvfz $(PACKAGE)-bin-bytecode-$(OCAMLVERSION).tgz --exclude-vcs $(BINSRC2)
319 rm -f $(TMP)/$(PACKAGE)
320
321clean::
322 rm -f $(PACKAGE)
323 rm -f $(PACKAGE)-bin-x86.tgz
324 rm -f $(PACKAGE)-bin-x86-static.tgz
325 rm -f $(PACKAGE)-bin-bytecode-$(OCAMLVERSION).tgz
326
327
328
329TOLICENSIFY=ctl engine parsing_cocci popl popl09 python
330licensify:
331 ocaml tools/licensify.ml
332 set -e; for i in $(TOLICENSIFY); do cd $$i; ocaml ../tools/licensify.ml; cd ..; done
333
334# When checking out the source from diku sometimes I have some "X in the future"
335# error messages.
336fixdates:
337 echo do 'touch **/*.*'
338
339#fixCVS:
340# cvs update -d -P
341# echo do 'rm -rf **/CVS'
342
343ocamlversion:
344 @echo $(OCAMLVERSION)
345
346
347##############################################################################
348# Pad specific rules
349##############################################################################
350
351#TOP=/home/pad/mobile/project-coccinelle
352WEBSITE=/home/pad/mobile/homepage/software/project-coccinelle
353
354website:
355 cp $(TMP)/$(PACKAGE).tgz $(WEBSITE)
356 cp $(TMP)/$(PACKAGE)-bin-x86.tgz $(WEBSITE)
357 cp $(TMP)/$(PACKAGE)-bin-x86-static.tgz $(WEBSITE)
358 cp $(TMP)/$(PACKAGE)-bin-bytecode-$(OCAMLVERSION).tgz $(WEBSITE)
359
360
361#TXT=$(wildcard *.txt)
362syncwiki:
363# unison ~/public_html/wiki/wiki-LFS/data/pages/ docs/wiki/
364# set -e; for i in $(TXT); do unison $$i docs/wiki/$$i; done
365
366darcsweb:
367# @echo pull from ~/public_html/darcs/c-coccinelle and c-commons and lib-xxx
368
369DARCSFORESTS=commons \
370 parsing_c parsing_cocci engine
371
372update_darcs:
373 darcs pull
374 set -e; for i in $(DARCSFORESTS); do cd $$i; darcs pull; cd ..; done
375
376#darcs diff -u
377diff_darcs:
378 set -e; for i in $(DARCSFORESTS); do cd $$i; darcs diff -u; cd ..; done
379
380
381##############################################################################
382# Developer rules
383##############################################################################
384
385test: $(TARGET)
386 ./$(TARGET) -testall
387
388testparsing:
389 ./$(TARGET) -D standard.h -parse_c -dir tests/
390
391
392
393# -inline 0 to see all the functions in the profile.
394# Can also use the profile framework in commons/ and run your program
395# with -profile.
396forprofiling:
397 $(MAKE) OPTFLAGS="-p -inline 0 " opt
398
399clean::
400 rm -f gmon.out
401
402tags:
403 otags -no-mli-tags -r .
404
405dependencygraph:
406 find -name "*.ml" |grep -v "scripts" | xargs ocamldep -I commons -I globals -I ctl -I parsing_cocci -I parsing_c -I engine -I popl09 -I extra > /tmp/dependfull.depend
407 ocamldot -lr /tmp/dependfull.depend > /tmp/dependfull.dot
408 dot -Tps /tmp/dependfull.dot > /tmp/dependfull.ps
409 ps2pdf /tmp/dependfull.ps /tmp/dependfull.pdf
410
411##############################################################################
412# Misc rules
413##############################################################################
414
415# each member of the project can have its own test.ml. this file is
416# not under CVS.
417test.ml:
418 echo "let foo_ctl () = failwith \"there is no foo_ctl formula\"" \
419 > test.ml
420
421beforedepend:: test.ml
422
423
424#INC=$(dir $(shell which ocaml))
425#INCX=$(INC:/=)
426#INCY=$(dir $(INCX))
427#INCZ=$(INCY:/=)/lib/ocaml
428#
429#prim.o: prim.c
430# gcc -c -o prim.o -I $(INCZ) prim.c
431
432
433##############################################################################
434# Generic ocaml rules
435##############################################################################
436
437.SUFFIXES: .ml .mli .cmo .cmi .cmx
438
439.ml.cmo:
440 $(OCAMLC) -c $<
441.mli.cmi:
442 $(OCAMLC) -c $<
443.ml.cmx:
444 $(OCAMLOPT) -c $<
445
446.ml.mldepend:
447 $(OCAMLC) -i $<
448
449clean::
450 rm -f *.cm[iox] *.o *.annot
451
452clean::
453 rm -f *~ .*~ *.exe #*#
454
455beforedepend::
456
457depend:: beforedepend
458 $(OCAMLDEP) *.mli *.ml > .depend
459 set -e; for i in $(MAKESUBDIRS); do $(MAKE) -C $$i depend; done
460
461-include .depend