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