Release coccinelle-0.2.0
[bpt/coccinelle.git] / Makefile
CommitLineData
9f8e26f4
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, Nicolas Palix
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
951c7801 21
34e49164
C
22#############################################################################
23# Configuration section
24#############################################################################
25
26-include Makefile.config
27
b1b2de81 28VERSION=$(shell cat globals/config.ml.in |grep version |perl -p -e 's/.*"(.*)".*/$$1/;')
951c7801 29CCVERSION=$(shell cat scripts/coccicheck/README |grep "Coccicheck version" |perl -p -e 's/.*version (.*)[ ]*/$$1/;')
34e49164
C
30
31##############################################################################
32# Variables
33##############################################################################
34TARGET=spatch
35
36SRC=flag_cocci.ml cocci.ml testing.ml test.ml main.ml
37
34e49164
C
38ifeq ($(FEATURE_PYTHON),1)
39PYCMA=pycaml/pycaml.cma
40PYDIR=pycaml
41PYLIB=dllpycaml_stubs.so
b1b2de81 42# the following is essential for Coccinelle to compile under gentoo (weird)
34e49164
C
43OPTLIBFLAGS=-cclib dllpycaml_stubs.so
44else
45PYCMA=
46PYDIR=
47PYLIB=
48OPTLIBFLAGS=
49endif
50
b1b2de81 51SEXPSYSCMA=bigarray.cma nums.cma
34e49164 52
b1b2de81
C
53SYSLIBS=str.cma unix.cma $(SEXPSYSCMA)
54LIBS=commons/commons.cma \
55 ocamlsexp/sexplib1.cma commons/commons_sexp.cma \
56 globals/globals.cma \
34e49164
C
57 ctl/ctl.cma \
58 parsing_cocci/cocci_parser.cma parsing_c/parsing_c.cma \
951c7801 59 engine/cocciengine.cma popl09/popl.cma \
34e49164
C
60 extra/extra.cma $(PYCMA) python/coccipython.cma
61
b1b2de81
C
62#used for clean: and depend: and a little for rec & rec.opt
63MAKESUBDIRS=commons ocamlsexp \
64 globals menhirlib $(PYDIR) ctl parsing_cocci parsing_c \
951c7801 65 engine popl09 extra python
b1b2de81
C
66INCLUDEDIRS=commons commons/ocamlextra ocamlsexp \
67 globals menhirlib $(PYDIR) ctl \
951c7801 68 parsing_cocci parsing_c engine popl09 extra python
34e49164
C
69
70##############################################################################
71# Generic variables
72##############################################################################
73
74INCLUDES=$(INCLUDEDIRS:%=-I %)
75
76OBJS= $(SRC:.ml=.cmo)
77OPTOBJS= $(SRC:.ml=.cmx)
78
79EXEC=$(TARGET)
80
81##############################################################################
82# Generic ocaml variables
83##############################################################################
84
7f004419 85OCAMLCFLAGS=# -g -dtypes # -w A
34e49164
C
86
87# for profiling add -p -inline 0
88# but 'make forprofiling' below does that for you.
89# This flag is also used in subdirectories so don't change its name here.
708f4980
C
90# To enable backtrace support for native code, you need to put -g in OPTFLAGS
91# to also link with -g, but even in 3.11 the backtrace support seems buggy so
92# not worth it.
34e49164
C
93OPTFLAGS=
94# the following is essential for Coccinelle to compile under gentoo
95# but is now defined above in this file
96#OPTLIBFLAGS=-cclib dllpycaml_stubs.so
97
34e49164 98OCAMLC=ocamlc$(OPTBIN) $(OCAMLCFLAGS) $(INCLUDES)
faf9a90c 99OCAMLOPT=ocamlopt$(OPTBIN) $(OPTFLAGS) $(INCLUDES)
34e49164
C
100OCAMLLEX=ocamllex #-ml # -ml for debugging lexer, but slightly slower
101OCAMLYACC=ocamlyacc -v
0708f913 102OCAMLDEP=ocamldep $(INCLUDES)
34e49164
C
103OCAMLMKTOP=ocamlmktop -g -custom $(INCLUDES)
104
105# can also be set via 'make static'
106STATIC= #-ccopt -static
107
108# can also be unset via 'make purebytecode'
109BYTECODE_STATIC=-custom
110
111##############################################################################
112# Top rules
113##############################################################################
b1b2de81
C
114.PHONY:: all all.opt byte opt top clean distclean configure
115.PHONY:: $(MAKESUBDIRS) $(MAKESUBDIRS:%=%.opt) subdirs subdirs.opt
116
708f4980 117all: Makefile.config byte preinstall
b1b2de81
C
118
119opt: all.opt
708f4980 120all.opt: opt-compil preinstall
faf9a90c 121
708f4980 122world: preinstall
b1b2de81 123 $(MAKE) byte
708f4980 124 $(MAKE) opt-compil
b1b2de81
C
125
126byte: .depend
faf9a90c
C
127 $(MAKE) subdirs
128 $(MAKE) $(EXEC)
129
b1b2de81 130opt-compil: .depend
faf9a90c
C
131 $(MAKE) subdirs.opt
132 $(MAKE) $(EXEC).opt
133
485bce71 134top: $(EXEC).top
34e49164 135
0708f913 136subdirs:
b1b2de81
C
137 $(MAKE) -C commons OCAMLCFLAGS="$(OCAMLCFLAGS)"
138 $(MAKE) -C ocamlsexp OCAMLCFLAGS="$(OCAMLCFLAGS)"
139 $(MAKE) -C commons sexp OCAMLCFLAGS="$(OCAMLCFLAGS)"
140 +for D in $(MAKESUBDIRS); do $(MAKE) $$D || exit 1 ; done
0708f913
C
141
142subdirs.opt:
b1b2de81
C
143 $(MAKE) -C commons all.opt OCAMLCFLAGS="$(OCAMLCFLAGS)"
144 $(MAKE) -C ocamlsexp all.opt OCAMLCFLAGS="$(OCAMLCFLAGS)"
145 $(MAKE) -C commons sexp.opt OCAMLCFLAGS="$(OCAMLCFLAGS)"
146 +for D in $(MAKESUBDIRS); do $(MAKE) $$D.opt || exit 1 ; done
faf9a90c
C
147
148$(MAKESUBDIRS):
149 $(MAKE) -C $@ OCAMLCFLAGS="$(OCAMLCFLAGS)" all
150
151$(MAKESUBDIRS:%=%.opt):
152 $(MAKE) -C $(@:%.opt=%) OCAMLCFLAGS="$(OCAMLCFLAGS)" all.opt
153
b1b2de81 154#dependencies:
0708f913
C
155# commons:
156# globals:
157# menhirlib:
158# parsing_cocci: commons globals menhirlib
159# parsing_c:parsing_cocci
160# ctl:globals commons
161# engine: parsing_cocci parsing_c ctl
951c7801 162# popl09:engine
0708f913
C
163# extra: parsing_cocci parsing_c ctl
164# pycaml:
165# python:pycaml parsing_cocci parsing_c
faf9a90c 166
34e49164 167clean::
b1b2de81 168 set -e; for i in $(MAKESUBDIRS); do $(MAKE) -C $$i $@; done
34e49164 169
0708f913
C
170$(LIBS): $(MAKESUBDIRS)
171$(LIBS:.cma=.cmxa): $(MAKESUBDIRS:%=%.opt)
faf9a90c
C
172
173$(OBJS):$(LIBS)
174$(OPTOBJS):$(LIBS:.cma=.cmxa)
175
34e49164
C
176$(EXEC): $(LIBS) $(OBJS)
177 $(OCAMLC) $(BYTECODE_STATIC) -o $@ $(SYSLIBS) $^
178
faf9a90c 179$(EXEC).opt: $(LIBS:.cma=.cmxa) $(OPTOBJS)
34e49164
C
180 $(OCAMLOPT) $(STATIC) -o $@ $(SYSLIBS:.cma=.cmxa) $(OPTLIBFLAGS) $^
181
faf9a90c 182$(EXEC).top: $(LIBS) $(OBJS)
34e49164
C
183 $(OCAMLMKTOP) -custom -o $@ $(SYSLIBS) $^
184
185clean::
186 rm -f $(TARGET) $(TARGET).opt $(TARGET).top
34e49164
C
187 rm -f dllpycaml_stubs.so
188
b1b2de81
C
189.PHONY:: tools configure
190
191configure:
192 ./configure
34e49164 193
7f004419 194Makefile.config:
708f4980
C
195 @echo "Makefile.config is missing. Have you run ./configure?"
196 @exit 1
197
34e49164
C
198tools:
199 $(MAKE) -C tools
b1b2de81 200
34e49164
C
201clean::
202 $(MAKE) -C tools clean
203
34e49164
C
204static:
205 rm -f spatch.opt spatch
206 $(MAKE) STATIC="-ccopt -static" spatch.opt
207 cp spatch.opt spatch
208
209purebytecode:
210 rm -f spatch.opt spatch
211 $(MAKE) BYTECODE_STATIC="" spatch
fc1ad971 212 perl -p -i -e 's/^#!.*/#!\/usr\/bin\/ocamlrun/' spatch
34e49164
C
213
214
b1b2de81
C
215##############################################################################
216# Build documentation
217##############################################################################
218.PHONY:: docs
219
220docs:
221 make -C docs
222
223clean::
224 make -C docs clean
225
226distclean::
227 make -C docs distclean
228
229##############################################################################
230# Pre-Install (customization of spatch frontend script)
231##############################################################################
b1b2de81 232
708f4980 233preinstall: scripts/spatch scripts/spatch.opt scripts/spatch.byte
b1b2de81
C
234
235# user will use spatch to run spatch.opt (native)
708f4980 236scripts/spatch:
b1b2de81
C
237 cp scripts/spatch.sh scripts/spatch.tmp2
238 sed "s|SHAREDIR|$(SHAREDIR)|g" scripts/spatch.tmp2 > scripts/spatch.tmp
239 sed "s|LIBDIR|$(LIBDIR)|g" scripts/spatch.tmp > scripts/spatch
240 rm -f scripts/spatch.tmp2 scripts/spatch.tmp
241
242# user will use spatch to run spatch (bytecode)
708f4980
C
243scripts/spatch.byte:
244 cp scripts/spatch.sh scripts/spatch.byte.tmp3
245 sed "s|\.opt||" scripts/spatch.byte.tmp3 > scripts/spatch.byte.tmp2
246 sed "s|SHAREDIR|$(SHAREDIR)|g" scripts/spatch.byte.tmp2 \
247 > scripts/spatch.byte.tmp
248 sed "s|LIBDIR|$(LIBDIR)|g" scripts/spatch.byte.tmp \
249 > scripts/spatch.byte
250 rm -f scripts/spatch.byte.tmp3 \
251 scripts/spatch.byte.tmp2 \
252 scripts/spatch.byte.tmp
b1b2de81
C
253
254# user will use spatch.opt to run spatch.opt (native)
708f4980 255scripts/spatch.opt:
b1b2de81 256 cp scripts/spatch.sh scripts/spatch.opt.tmp2
708f4980
C
257 sed "s|SHAREDIR|$(SHAREDIR)|g" scripts/spatch.opt.tmp2 \
258 > scripts/spatch.opt.tmp
259 sed "s|LIBDIR|$(LIBDIR)|g" scripts/spatch.opt.tmp \
260 > scripts/spatch.opt
b1b2de81
C
261 rm -f scripts/spatch.opt.tmp scripts/spatch.opt.tmp2
262
263clean::
264 rm -f scripts/spatch scripts/spatch.byte scripts/spatch.opt
265
34e49164
C
266##############################################################################
267# Install
268##############################################################################
269
270# don't remove DESTDIR, it can be set by package build system like ebuild
8ba84ae2 271# for staged installation.
0708f913 272install-common:
34e49164
C
273 mkdir -p $(DESTDIR)$(BINDIR)
274 mkdir -p $(DESTDIR)$(LIBDIR)
275 mkdir -p $(DESTDIR)$(SHAREDIR)
faf9a90c 276 mkdir -p $(DESTDIR)$(MANDIR)/man1
8ba84ae2
C
277 $(INSTALL_DATA) standard.h $(DESTDIR)$(SHAREDIR)
278 $(INSTALL_DATA) standard.iso $(DESTDIR)$(SHAREDIR)
279 $(INSTALL_DATA) docs/spatch.1 $(DESTDIR)$(MANDIR)/man1/
280 @if [ $(FEATURE_PYTHON) -eq 1 ]; then $(MAKE) install-python; fi
0708f913 281
8ba84ae2
C
282install-python:
283 mkdir -p $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui
284 $(INSTALL_DATA) python/coccilib/*.py \
285 $(DESTDIR)$(SHAREDIR)/python/coccilib
286 $(INSTALL_DATA) python/coccilib/coccigui/*.py \
287 $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui
b1b2de81
C
288 $(INSTALL_DATA) python/coccilib/coccigui/pygui.glade \
289 $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui
290 $(INSTALL_DATA) python/coccilib/coccigui/pygui.gladep \
291 $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui
8ba84ae2
C
292 $(INSTALL_LIB) dllpycaml_stubs.so $(DESTDIR)$(LIBDIR)
293
951c7801 294install: install-common
b1b2de81
C
295 @if test -x spatch -a ! -x spatch.opt ; then \
296 $(MAKE) install-byte;fi
297 @if test ! -x spatch -a -x spatch.opt ; then \
298 $(MAKE) install-def; $(MAKE) install-opt;fi
299 @if test -x spatch -a -x spatch.opt ; then \
300 $(MAKE) install-byte; $(MAKE) install-opt;fi
301 @if test ! -x spatch -a ! -x spatch.opt ; then \
302 echo "\n\n\t==> Run 'make', 'make opt', or both first. <==\n\n";fi
708f4980
C
303 @echo ""
304 @echo "\tYou can also install spatch by copying the program spatch"
305 @echo "\t(available in this directory) anywhere you want and"
306 @echo "\tgive it the right options to find its configuration files."
307 @echo ""
b1b2de81 308
0708f913 309# user will use spatch to run spatch.opt (native)
708f4980 310install-def:
8ba84ae2 311 $(INSTALL_PROGRAM) spatch.opt $(DESTDIR)$(SHAREDIR)
b1b2de81 312 $(INSTALL_PROGRAM) scripts/spatch $(DESTDIR)$(BINDIR)/spatch
0708f913
C
313
314# user will use spatch to run spatch (bytecode)
708f4980 315install-byte:
8ba84ae2 316 $(INSTALL_PROGRAM) spatch $(DESTDIR)$(SHAREDIR)
b1b2de81 317 $(INSTALL_PROGRAM) scripts/spatch.byte $(DESTDIR)$(BINDIR)/spatch
0708f913
C
318
319# user will use spatch.opt to run spatch.opt (native)
708f4980 320install-opt:
8ba84ae2 321 $(INSTALL_PROGRAM) spatch.opt $(DESTDIR)$(SHAREDIR)
b1b2de81 322 $(INSTALL_PROGRAM) scripts/spatch.opt $(DESTDIR)$(BINDIR)/spatch.opt
34e49164
C
323
324uninstall:
325 rm -f $(DESTDIR)$(BINDIR)/spatch
8ba84ae2 326 rm -f $(DESTDIR)$(BINDIR)/spatch.opt
34e49164
C
327 rm -f $(DESTDIR)$(LIBDIR)/dllpycaml_stubs.so
328 rm -f $(DESTDIR)$(SHAREDIR)/standard.h
329 rm -f $(DESTDIR)$(SHAREDIR)/standard.iso
330 rm -rf $(DESTDIR)$(SHAREDIR)/python/coccilib
faf9a90c 331 rm -f $(DESTDIR)$(MANDIR)/man1/spatch.1
34e49164 332
34e49164 333version:
951c7801
C
334 @echo "spatch $(VERSION)"
335 @echo "coccicheck $(CCVERSION)"
34e49164
C
336
337
338##############################################################################
339# Package rules
340##############################################################################
341
342PACKAGE=coccinelle-$(VERSION)
951c7801 343CCPACKAGE=coccicheck-$(CCVERSION)
34e49164
C
344
345BINSRC=spatch env.sh env.csh standard.h standard.iso \
b1b2de81 346 *.txt \
fc1ad971 347 docs/manual/manual.pdf docs/manual/options.pdf docs/manual/main_grammar.pdf docs/spatch.1 \
708f4980 348 docs/manual/cocci-python.txt \
faf9a90c 349 demos/foo.* demos/simple.*
34e49164
C
350# $(PYLIB) python/coccilib/ demos/printloc.*
351BINSRC2=$(BINSRC:%=$(PACKAGE)/%)
352
353TMP=/tmp
354OCAMLVERSION=$(shell ocaml -version |perl -p -e 's/.*version (.*)/$$1/;')
355
356# Procedure to do first time:
357# cd ~/release
7f004419 358# cvs checkout coccinelle -dP
34e49164 359# cd coccinelle
7f004419
C
360#
361# Procedure to do each time:
362#
363# 1) make prepackage # WARN: These will clean your local rep. of pending modifications
364#
365# UPDATE VERSION number in globals/config.ml.in
366# and commit it with
367#
368# 2) make release
369#
370# The project is then automatically licensified.
371#
372# Remember to comment the -g -dtypes in this Makefile
b1b2de81
C
373# You can also remove a few things, for instance I removed in this
374# Makefile things related to popl/ and popl09/
113803cf 375# make sure that ocaml is the distribution ocaml of /usr/bin, not ~pad/...
7f004419
C
376#
377# 3) make package
378#
379# if WEBSITE is set properly, you can also run 'make website'
113803cf 380# Check that run an ocaml in /usr/bin
34e49164 381
faf9a90c
C
382# To test you can try compile and run spatch from different instances
383# like my ~/coccinelle, ~/release/coccinelle, and the /tmp/coccinelle-0.X
384# downloaded from the website.
34e49164
C
385
386# For 'make srctar' it must done from a clean
faf9a90c
C
387# repo such as ~/release/coccinelle. It must also be a repo where
388# the scripts/licensify has been run at least once.
34e49164
C
389# For the 'make bintar' I can do it from my original repo.
390
7f004419
C
391prepackage:
392 cvs up -CdP
393 $(MAKE) distclean
394
395release:
9f8e26f4 396 cvs ci -m "Release $(VERSION)" globals/config.ml.in
7f004419 397 $(MAKE) licensify
34e49164 398
faf9a90c 399package:
7f004419 400 $(MAKE) distclean # Clean project
951c7801 401 $(MAKE) srctar
b1b2de81 402 ./configure --without-python
951c7801
C
403 $(MAKE) docs
404 $(MAKE) bintar
405 $(MAKE) bytecodetar
406 $(MAKE) staticbintar
7f004419
C
407 $(MAKE) distclean # Clean project
408 ./configure # Reconfigure project with Python support
409 $(MAKE) docs
410 $(MAKE) bintar-python
411 $(MAKE) bytecodetar-python
951c7801 412 $(MAKE) coccicheck
fc1ad971 413
34e49164 414
faf9a90c 415# I currently pre-generate the parser so the user does not have to
b1b2de81 416# install menhir on his machine. We could also do a few cleanups.
34e49164 417# You may have first to do a 'make licensify'.
b1b2de81 418#
951c7801 419# update: make docs generates pdf but also some ugly .log files, so
b1b2de81
C
420# make clean is there to remove them while not removing the pdf
421# (only distclean remove the pdfs).
34e49164 422srctar:
b1b2de81
C
423 make distclean
424 make docs
34e49164
C
425 make clean
426 cp -a . $(TMP)/$(PACKAGE)
427 cd $(TMP)/$(PACKAGE); cd parsing_cocci/; make parser_cocci_menhir.ml
faf9a90c 428 cd $(TMP); tar cvfz $(PACKAGE).tgz --exclude-vcs $(PACKAGE)
34e49164
C
429 rm -rf $(TMP)/$(PACKAGE)
430
431
432bintar: all
433 rm -f $(TMP)/$(PACKAGE)
434 ln -s `pwd` $(TMP)/$(PACKAGE)
faf9a90c 435 cd $(TMP); tar cvfz $(PACKAGE)-bin-x86.tgz --exclude-vcs $(BINSRC2)
34e49164
C
436 rm -f $(TMP)/$(PACKAGE)
437
438staticbintar: all.opt
439 rm -f $(TMP)/$(PACKAGE)
440 ln -s `pwd` $(TMP)/$(PACKAGE)
441 make static
faf9a90c 442 cd $(TMP); tar cvfz $(PACKAGE)-bin-x86-static.tgz --exclude-vcs $(BINSRC2)
34e49164
C
443 rm -f $(TMP)/$(PACKAGE)
444
445# add ocaml version in name ?
446bytecodetar: all
447 rm -f $(TMP)/$(PACKAGE)
448 ln -s `pwd` $(TMP)/$(PACKAGE)
449 make purebytecode
faf9a90c 450 cd $(TMP); tar cvfz $(PACKAGE)-bin-bytecode-$(OCAMLVERSION).tgz --exclude-vcs $(BINSRC2)
34e49164
C
451 rm -f $(TMP)/$(PACKAGE)
452
7f004419
C
453bintar-python: all
454 rm -f $(TMP)/$(PACKAGE)
455 ln -s `pwd` $(TMP)/$(PACKAGE)
456 cd $(TMP); tar cvfz $(PACKAGE)-bin-x86-python.tgz --exclude-vcs $(BINSRC2)
457 rm -f $(TMP)/$(PACKAGE)
458
459# add ocaml version in name ?
460bytecodetar-python: all
461 rm -f $(TMP)/$(PACKAGE)
462 ln -s `pwd` $(TMP)/$(PACKAGE)
463 make purebytecode
464 cd $(TMP); tar cvfz $(PACKAGE)-bin-bytecode-$(OCAMLVERSION)-python.tgz --exclude-vcs $(BINSRC2)
465 rm -f $(TMP)/$(PACKAGE)
466
951c7801
C
467coccicheck:
468 cp -a `pwd`/scripts/coccicheck $(TMP)/$(CCPACKAGE)
469 tar cvfz $(TMP)/$(CCPACKAGE).tgz -C $(TMP) --exclude-vcs $(CCPACKAGE)
470 rm -rf $(TMP)/$(CCPACKAGE)
34e49164 471
7f004419 472clean-packages::
951c7801
C
473 rm -f $(TMP)/$(PACKAGE).tgz
474 rm -f $(TMP)/$(PACKAGE)-bin-x86.tgz
475 rm -f $(TMP)/$(PACKAGE)-bin-x86-static.tgz
476 rm -f $(TMP)/$(PACKAGE)-bin-bytecode-$(OCAMLVERSION).tgz
7f004419
C
477 rm -f $(TMP)/$(PACKAGE)-bin-x86-python.tgz
478 rm -f $(TMP)/$(PACKAGE)-bin-bytecode-$(OCAMLVERSION)-python.tgz
951c7801 479 rm -f $(TMP)/$(CCPACKAGE).tgz
34e49164 480
951c7801
C
481#
482# No need to licensify 'demos'. Because these is basic building blocks
483# to use SmPL.
484#
485TOLICENSIFY=ctl engine globals parsing_cocci popl popl09 python scripts tools
34e49164 486licensify:
951c7801
C
487 ocaml str.cma tools/licensify.ml
488 set -e; for i in $(TOLICENSIFY); do cd $$i; ocaml str.cma ../tools/licensify.ml; cd ..; done
34e49164
C
489
490# When checking out the source from diku sometimes I have some "X in the future"
491# error messages.
492fixdates:
493 echo do 'touch **/*.*'
494
495#fixCVS:
496# cvs update -d -P
497# echo do 'rm -rf **/CVS'
498
499ocamlversion:
500 @echo $(OCAMLVERSION)
501
34e49164
C
502##############################################################################
503# Developer rules
504##############################################################################
505
7f004419
C
506-include Makefile.dev
507
34e49164
C
508test: $(TARGET)
509 ./$(TARGET) -testall
510
511testparsing:
512 ./$(TARGET) -D standard.h -parse_c -dir tests/
513
514
515
faf9a90c
C
516# -inline 0 to see all the functions in the profile.
517# Can also use the profile framework in commons/ and run your program
34e49164
C
518# with -profile.
519forprofiling:
520 $(MAKE) OPTFLAGS="-p -inline 0 " opt
521
522clean::
faf9a90c 523 rm -f gmon.out
34e49164
C
524
525tags:
526 otags -no-mli-tags -r .
527
528dependencygraph:
951c7801 529 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
485bce71 530 ocamldot -lr /tmp/dependfull.depend > /tmp/dependfull.dot
34e49164 531 dot -Tps /tmp/dependfull.dot > /tmp/dependfull.ps
485bce71 532 ps2pdf /tmp/dependfull.ps /tmp/dependfull.pdf
34e49164
C
533
534##############################################################################
535# Misc rules
536##############################################################################
537
faf9a90c 538# each member of the project can have its own test.ml. this file is
34e49164 539# not under CVS.
faf9a90c 540test.ml:
34e49164
C
541 echo "let foo_ctl () = failwith \"there is no foo_ctl formula\"" \
542 > test.ml
543
544beforedepend:: test.ml
545
546
547#INC=$(dir $(shell which ocaml))
548#INCX=$(INC:/=)
549#INCY=$(dir $(INCX))
550#INCZ=$(INCY:/=)/lib/ocaml
551#
552#prim.o: prim.c
553# gcc -c -o prim.o -I $(INCZ) prim.c
554
555
556##############################################################################
557# Generic ocaml rules
558##############################################################################
559
560.SUFFIXES: .ml .mli .cmo .cmi .cmx
561
562.ml.cmo:
563 $(OCAMLC) -c $<
564.mli.cmi:
565 $(OCAMLC) -c $<
566.ml.cmx:
567 $(OCAMLOPT) -c $<
568
faf9a90c 569.ml.mldepend:
34e49164
C
570 $(OCAMLC) -i $<
571
572clean::
573 rm -f *.cm[iox] *.o *.annot
34e49164
C
574 rm -f *~ .*~ *.exe #*#
575
b1b2de81
C
576distclean:: clean
577 set -e; for i in $(MAKESUBDIRS); do $(MAKE) -C $$i $@; done
578 rm -f .depend
579 rm -f Makefile.config
580 rm -f python/coccilib/output.py
581 rm -f python/pycocci.ml
582 rm -f python/pycocci_aux.ml
583 rm -f globals/config.ml
584 rm -f TAGS
585 rm -f tests/SCORE_actual.sexp
586 rm -f tests/SCORE_best_of_both.sexp
587 find -name ".#*1.*" | xargs rm -f
588
34e49164
C
589beforedepend::
590
591depend:: beforedepend
592 $(OCAMLDEP) *.mli *.ml > .depend
b1b2de81
C
593 set -e; for i in $(MAKESUBDIRS); do $(MAKE) -C $$i $@; done
594
595.depend::
596 @if [ ! -f .depend ] ; then $(MAKE) depend ; fi
34e49164
C
597
598-include .depend