1 # Copyright 2005-2008, 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.
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.
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.
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/>.
17 # The authors reserve the right to distribute this or future versions of
18 # Coccinelle under other licenses.
21 #############################################################################
22 # Configuration section
23 #############################################################################
25 -include Makefile.config
27 VERSION
=$(shell cat globals
/config.ml |grep version |perl
-p
-e
's/.*"(.*)".*/$$1/;')
29 ##############################################################################
31 ##############################################################################
34 SRC
=flag_cocci.ml cocci.ml testing.ml
test.ml main.ml
37 ifeq ($(FEATURE_PYTHON
),1)
38 PYCMA
=pycaml
/pycaml.cma
40 PYLIB
=dllpycaml_stubs.so
41 # the following is essential for Coccinelle to compile under gentoo (wierd)
42 OPTLIBFLAGS
=-cclib dllpycaml_stubs.so
51 SYSLIBS
=str.cma unix.cma
52 LIBS
=commons
/commons.cma globals
/globals.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
58 MAKESUBDIRS
=commons globals menhirlib
$(PYDIR
) ctl parsing_cocci parsing_c \
59 engine popl09 extra python
60 INCLUDEDIRS
=commons globals menhirlib
$(PYDIR
) ctl parsing_cocci parsing_c \
61 engine popl09 extra python
63 ##############################################################################
65 ##############################################################################
67 INCLUDES
=$(INCLUDEDIRS
:%=-I
%)
70 OPTOBJS
= $(SRC
:.ml
=.cmx
)
74 ##############################################################################
75 # Generic ocaml variables
76 ##############################################################################
78 OCAMLCFLAGS
= #-g -dtypes # -w A
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.
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
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.
94 OCAMLC
=ocamlc
$(OPTBIN
) $(OCAMLCFLAGS
) $(INCLUDES
)
95 OCAMLOPT
=ocamlopt
$(OPTBIN
) $(OPTFLAGS
) $(INCLUDES
)
96 OCAMLLEX
=ocamllex
#-ml # -ml for debugging lexer, but slightly slower
97 OCAMLYACC
=ocamlyacc
-v
98 OCAMLDEP
=ocamldep
$(INCLUDES
)
99 OCAMLMKTOP
=ocamlmktop
-g
-custom
$(INCLUDES
)
101 # can also be set via 'make static'
102 STATIC
= #-ccopt -static
104 # can also be unset via 'make purebytecode'
105 BYTECODE_STATIC
=-custom
107 ##############################################################################
109 ##############################################################################
112 opt
: rec.opt
$(EXEC
).opt
116 set
-e
; for i in
$(MAKESUBDIRS
); \
117 do
$(MAKE
) -C
$$i OCAMLCFLAGS
="$(OCAMLCFLAGS)" all; done
119 set
-e
; for i in
$(MAKESUBDIRS
); do
$(MAKE
) -C
$$i all.opt
; done
121 set
-e
; for i in
$(MAKESUBDIRS
); do
$(MAKE
) -C
$$i clean; done
124 $(EXEC
): $(LIBS
) $(OBJS
)
125 $(OCAMLC
) $(BYTECODE_STATIC
) -o
$@
$(SYSLIBS
) $^
127 $(EXEC
).opt
: $(LIBS
:.cma
=.cmxa
) $(OPTOBJS
)
128 $(OCAMLOPT
) $(STATIC
) -o
$@
$(SYSLIBS
:.cma
=.cmxa
) $(OPTLIBFLAGS
) $^
130 $(EXEC
).top
: $(LIBS
) $(OBJS
)
131 $(OCAMLMKTOP
) -custom
-o
$@
$(SYSLIBS
) $^
134 rm -f
$(TARGET
) $(TARGET
).opt
$(TARGET
).top
138 rm -f dllpycaml_stubs.so
146 $(MAKE
) -C tools
clean
150 rm -f spatch.opt spatch
151 $(MAKE
) STATIC
="-ccopt -static" spatch.opt
155 rm -f spatch.opt spatch
156 $(MAKE
) BYTECODE_STATIC
="" spatch
159 ##############################################################################
161 ##############################################################################
163 # don't remove DESTDIR, it can be set by package build system like ebuild
165 mkdir
-p
$(DESTDIR
)$(BINDIR
)
166 mkdir
-p
$(DESTDIR
)$(LIBDIR
)
167 mkdir
-p
$(DESTDIR
)$(SHAREDIR
)
168 cp spatch
$(DESTDIR
)$(BINDIR
)
169 cp
-f dllpycaml_stubs.so
$(DESTDIR
)$(LIBDIR
)
170 cp standard.h
$(DESTDIR
)$(SHAREDIR
)
171 cp standard.iso
$(DESTDIR
)$(SHAREDIR
)
172 mkdir
-p
$(DESTDIR
)$(SHAREDIR
)/python
173 cp
-a python
/coccilib
$(DESTDIR
)$(SHAREDIR
)/python
175 @echo
"You can also install spatch by copying the program spatch"
176 @echo
"(available in this directory) anywhere you want and"
177 @echo
"give it the right options to find its configuration files."
180 rm -f
$(DESTDIR
)$(BINDIR
)/spatch
181 rm -f
$(DESTDIR
)$(LIBDIR
)/dllpycaml_stubs.so
182 rm -f
$(DESTDIR
)$(SHAREDIR
)/standard.h
183 rm -f
$(DESTDIR
)$(SHAREDIR
)/standard.iso
184 rm -rf
$(DESTDIR
)$(SHAREDIR
)/python
/coccilib
192 ##############################################################################
194 ##############################################################################
196 PACKAGE
=coccinelle-
$(VERSION
)
198 BINSRC
=spatch env.sh env.csh standard.h standard.iso \
200 demos
/foo.
* demos
/simple.
*
201 # $(PYLIB) python/coccilib/ demos/printloc.*
202 BINSRC2
=$(BINSRC
:%=$(PACKAGE
)/%)
205 OCAMLVERSION
=$(shell ocaml
-version |perl
-p
-e
's/.*version (.*)/$$1/;')
207 # Procedure to do first time:
209 # cvs checkout coccinelle
215 # Procedure to do each time:
217 # ./configure --without-python
220 # Check also that run an ocaml in /usr/bin
222 # To test you can try compile and run spatch from different instances
223 # like my ~/coccinelle, ~/release/coccinelle, and the /tmp/coccinelle-0.X
224 # downloaded from the website.
226 # For 'make srctar' it must done from a clean
227 # repo such as ~/release/coccinelle. It must also be a repo where
228 # the scripts/licensify has been run at least once.
229 # For the 'make bintar' I can do it from my original repo.
238 # I currently pre-generate the parser so the user does not have to
239 # install menhir on his machine. I also do a few cleanups like 'rm todo_pos'.
240 # You may have first to do a 'make licensify'.
243 cp
-a .
$(TMP
)/$(PACKAGE
)
244 cd
$(TMP
)/$(PACKAGE
); cd parsing_cocci
/; make parser_cocci_menhir.ml
245 cd
$(TMP
)/$(PACKAGE
); rm todo_pos
246 cd
$(TMP
); tar cvfz
$(PACKAGE
).tgz
--exclude
=CVS
$(PACKAGE
)
247 rm -rf
$(TMP
)/$(PACKAGE
)
251 rm -f
$(TMP
)/$(PACKAGE
)
252 ln
-s
`pwd` $(TMP
)/$(PACKAGE
)
253 cd
$(TMP
); tar cvfz
$(PACKAGE
)-bin-x86.tgz
$(BINSRC2
)
254 rm -f
$(TMP
)/$(PACKAGE
)
256 staticbintar
: all.opt
257 rm -f
$(TMP
)/$(PACKAGE
)
258 ln
-s
`pwd` $(TMP
)/$(PACKAGE
)
260 cd
$(TMP
); tar cvfz
$(PACKAGE
)-bin-x86-static.tgz
$(BINSRC2
)
261 rm -f
$(TMP
)/$(PACKAGE
)
263 # add ocaml version in name ?
265 rm -f
$(TMP
)/$(PACKAGE
)
266 ln
-s
`pwd` $(TMP
)/$(PACKAGE
)
268 cd
$(TMP
); tar cvfz
$(PACKAGE
)-bin-bytecode-
$(OCAMLVERSION
).tgz
$(BINSRC2
)
269 rm -f
$(TMP
)/$(PACKAGE
)
273 rm -f
$(PACKAGE
)-bin-x86.tgz
274 rm -f
$(PACKAGE
)-bin-x86-static.tgz
275 rm -f
$(PACKAGE
)-bin-bytecode-
$(OCAMLVERSION
).tgz
279 TOLICENSIFY
=ctl engine parsing_cocci popl popl09 python
281 ocaml tools
/licensify.ml
282 set
-e
; for i in
$(TOLICENSIFY
); do cd
$$i; ocaml ..
/tools
/licensify.ml
; cd ..
; done
284 # When checking out the source from diku sometimes I have some "X in the future"
287 echo do
'touch **/*.*'
291 # echo do 'rm -rf **/CVS'
294 @echo
$(OCAMLVERSION
)
297 ##############################################################################
299 ##############################################################################
301 #TOP=/home/pad/mobile/project-coccinelle
302 WEBSITE
=/home
/pad
/mobile
/homepage
/software
/project-coccinelle
305 cp
$(TMP
)/$(PACKAGE
).tgz
$(WEBSITE
)
306 cp
$(TMP
)/$(PACKAGE
)-bin-x86.tgz
$(WEBSITE
)
307 cp
$(TMP
)/$(PACKAGE
)-bin-x86-static.tgz
$(WEBSITE
)
308 cp
$(TMP
)/$(PACKAGE
)-bin-bytecode-
$(OCAMLVERSION
).tgz
$(WEBSITE
)
311 #TXT=$(wildcard *.txt)
313 # unison ~/public_html/wiki/wiki-LFS/data/pages/ docs/wiki/
314 # set -e; for i in $(TXT); do unison $$i docs/wiki/$$i; done
317 # @echo pull from ~/public_html/darcs/c-coccinelle and c-commons and lib-xxx
320 ##############################################################################
322 ##############################################################################
328 .
/$(TARGET
) -D standard.h
-parse_c
-dir tests
/
332 # -inline 0 to see all the functions in the profile.
333 # Can also use the profile framework in commons/ and run your program
336 $(MAKE
) OPTFLAGS
="-p -inline 0 " opt
342 otags
-no-mli-tags
-r .
345 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
346 ocamldot
-fullgraph
/tmp
/dependfull.depend
> /tmp
/dependfull.dot
347 dot
-Tps
/tmp
/dependfull.dot
> /tmp
/dependfull.ps
349 ##############################################################################
351 ##############################################################################
353 # each member of the project can have its own test.ml. this file is
356 echo
"let foo_ctl () = failwith \"there is no foo_ctl formula\"" \
359 beforedepend
:: test.ml
362 #INC=$(dir $(shell which ocaml))
365 #INCZ=$(INCY:/=)/lib/ocaml
368 # gcc -c -o prim.o -I $(INCZ) prim.c
371 ##############################################################################
372 # Generic ocaml rules
373 ##############################################################################
375 .SUFFIXES
: .ml .mli .cmo .cmi .cmx
388 rm -f
*.cm
[iox
] *.o
*.annot
391 rm -f
*~ .
*~
*.exe
#*#
395 depend
:: beforedepend
396 $(OCAMLDEP
) *.mli
*.ml
> .depend
397 set
-e
; for i in
$(MAKESUBDIRS
); do
$(MAKE
) -C
$$i depend
; done