permit multiline comments and strings in macros
[bpt/coccinelle.git] / Makefile
CommitLineData
17ba0788
C
1# Copyright 2012, INRIA
2# Julia Lawall, Gilles Muller
3# Copyright 2010-2011, INRIA, University of Copenhagen
f537ebc4
C
4# Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix
5# Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
6# Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
7# This file is part of Coccinelle.
8#
9# Coccinelle is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, according to version 2 of the License.
12#
13# Coccinelle is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
20#
21# The authors reserve the right to distribute this or future versions of
22# Coccinelle under other licenses.
23
24
34e49164
C
25#############################################################################
26# Configuration section
27#############################################################################
28
feec80c3
C
29include Makefile.libs
30
31# 'distclean' does not require configure to have run, and should also
32# clean all the bundled directories. Hence, a special case.
33ifeq ($(MAKECMDGOALS),distclean)
34MAKELIBS:=$(dir $(wildcard ./bundles/*/Makefile))
35else
36ifneq ($(MAKECMDGOALS),configure)
34e49164 37-include Makefile.config
feec80c3
C
38endif
39endif
40
c3e37e97 41-include /etc/lsb-release
feec80c3
C
42-include Makefile.override # local customizations, if any
43-include /etc/Makefile.coccinelle # local customizations, if any
44
34e49164 45
feec80c3
C
46VERSION=$(shell cat ./version | tr -d '\n')
47CCVERSION=$(shell cat scripts/coccicheck/README | egrep -o '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+' | head -n1)
c3e37e97
C
48PKGVERSION=$(shell dpkg-parsechangelog -ldebian/changelog.$(DISTRIB_CODENAME) 2> /dev/null \
49 | sed -n 's/^Version: \(.*\)/\1/p' )
34e49164
C
50
51##############################################################################
52# Variables
53##############################################################################
feec80c3 54
34e49164 55TARGET=spatch
c3e37e97 56PRJNAME=coccinelle
993936c0 57SRC=flag_cocci.ml cocci.ml testing.ml test.ml $(LEXER_SOURCES:.mll=.ml) main.ml
34e49164 58
34e49164 59ifeq ($(FEATURE_PYTHON),1)
feec80c3 60 PYTHON_INSTALL_TARGET=install-python
34e49164 61else
feec80c3 62 PYTHON_INSTALL_TARGET=
90aeb998 63endif
34e49164 64
feec80c3 65SYSLIBS=str.cma unix.cma bigarray.cma nums.cma
b1b2de81 66LIBS=commons/commons.cma \
b1b2de81 67 globals/globals.cma \
34e49164
C
68 ctl/ctl.cma \
69 parsing_cocci/cocci_parser.cma parsing_c/parsing_c.cma \
951c7801 70 engine/cocciengine.cma popl09/popl.cma \
174d1640 71 extra/extra.cma python/coccipython.cma ocaml/cocciocaml.cma
90aeb998 72
feec80c3
C
73MAKESUBDIRS=$(MAKELIBS) commons \
74 globals ctl parsing_cocci parsing_c \
75 engine popl09 extra python ocaml
34e49164 76
feec80c3
C
77CLEANSUBDIRS=commons \
78 globals ctl parsing_cocci parsing_c \
79 engine popl09 extra python ocaml docs \
97111a47 80 $(MAKELIBS)
174d1640 81
feec80c3
C
82INCLUDEDIRSDEP=commons commons/ocamlextra \
83 globals ctl \
97111a47 84 parsing_cocci parsing_c engine popl09 extra python ocaml \
feec80c3 85 $(MAKELIBS)
97111a47 86
feec80c3 87INCLUDEDIRS=$(INCLUDEDIRSDEP) $(PCREDIR) $(INCLIBS)
90aeb998 88
34e49164
C
89##############################################################################
90# Generic variables
91##############################################################################
92
feec80c3
C
93# sort to remove duplicates
94INCLUDESET=$(sort $(INCLUDEDIRS))
95INCLUDES=$(INCLUDESET:%=-I %)
34e49164
C
96
97OBJS= $(SRC:.ml=.cmo)
98OPTOBJS= $(SRC:.ml=.cmx)
99
100EXEC=$(TARGET)
101
102##############################################################################
103# Generic ocaml variables
104##############################################################################
105
feec80c3
C
106OCAMLC_CMD=$(OCAMLC) $(OCAMLCFLAGS) $(INCLUDES)
107OCAMLOPT_CMD=$(OCAMLOPT) $(OPTFLAGS) $(INCLUDES)
108OCAMLYACC_CMD=$(OCAMLYACC) -v
109OCAMLDEP_CMD=$(OCAMLDEP) $(INCLUDEDIRSDEP:%=-I %)
110OCAMLMKTOP_CMD=$(OCAMLMKTOP) -g -custom $(INCLUDES)
34e49164 111
d6ce1786
C
112# these are unused at the moment (todo: remove)
113EXTRA_CFLAGS= # -static -pie -fpie -fPIE -static-libgcc
114EXTRA_OCAML_CFLAGS=$(EXTRA_CFLAGS:%=-ccopt %)
34e49164 115
d6ce1786
C
116# 'make purebytecode' unsets this definition
117BYTECODE_EXTRA=-custom $(EXTRA_OCAML_FLAGS)
34e49164
C
118
119##############################################################################
120# Top rules
121##############################################################################
feec80c3
C
122.PHONY:: all all.opt byte opt top clean distclean configure opt-compil
123.PHONY:: $(MAKESUBDIRS:%=%.all) $(MAKESUBDIRS:%=%.opt) subdirs.all subdirs.opt
abad11c5 124.PHONY:: all-opt all-byte byte-only opt-only pure-byte
d6ce1786 125.PHONY:: copy-stubs install-stubs install install-man install-python install-common
b1b2de81 126
b1b2de81 127
abad11c5
C
128# below follow the main make targets when ocamlbuild is not enabled
129ifneq ($(FEATURE_OCAMLBUILD),yes)
130
feec80c3
C
131# All make targets that are expected to be an entry point have a dependency on
132# 'Makefile.config' to ensure that if Makefile.config is not present, an error
133# message is printed first before any other actions are executed.
134# In addition, the targets that actually build something have a dependency on
135# '.depend' and 'version.ml'.
faf9a90c 136
d6ce1786
C
137# dispatches to either 'all-dev' or 'all-release'
138all: Makefile.config
139 @$(MAKE) .depend
140 $(MAKE) $(TARGET_ALL)
feec80c3
C
141
142# make "all" comes in three flavours
d6ce1786 143world: Makefile.config version.ml
feec80c3 144 @echo "building both versions of spatch"
d6ce1786 145 $(MAKE) .depend
b1b2de81 146 $(MAKE) byte
708f4980 147 $(MAKE) opt-compil
feec80c3
C
148 $(MAKE) preinstall
149 $(MAKE) docs
150 @echo ""
151 @echo -e "\tcoccinelle can now be installed via 'make install'"
152
153# note: the 'all-dev' target excludes the documentation
d6ce1786
C
154all-dev: Makefile.config version.ml
155 @$(MAKE) .depend
feec80c3
C
156 @echo "building the unoptimized version of spatch"
157 $(MAKE) byte
d6ce1786 158 @$(MAKE) preinstall
feec80c3
C
159 @echo ""
160 @echo -e "\tcoccinelle can now be installed via 'make install'"
161
d6ce1786
C
162all-release: Makefile.config version.ml
163 @echo building $(TARGET_SPATCH)
164 $(MAKE) .depend
165 $(MAKE) $(TARGET_SPATCH)
feec80c3
C
166 $(MAKE) preinstall
167 $(MAKE) docs
168 @echo ""
169 @echo -e "\tcoccinelle can now be installed via 'make install'"
170
d6ce1786
C
171all.opt: Makefile.config
172 @$(MAKE) .depend
173 $(MAKE) opt-only
174 $(MAKE) preinstall
b1b2de81 175
d6ce1786
C
176byte: Makefile.config version.ml
177 @$(MAKE) .depend
178 @$(MAKE) subdirs.all
179 @$(MAKE) $(EXEC)
feec80c3
C
180 @echo the compilation of $(EXEC) finished
181 @echo $(EXEC) can be installed or used
faf9a90c 182
d6ce1786
C
183opt-compil: Makefile.config version.ml
184 $(MAKE) .depend
185 $(MAKE) subdirs.opt BUILD_OPT=yes
186 $(MAKE) $(EXEC).opt BUILD_OPT=yes
feec80c3
C
187 @echo the compilation of $(EXEC).opt finished
188 @echo $(EXEC).opt can be installed or used
faf9a90c 189
485bce71 190top: $(EXEC).top
34e49164 191
abad11c5
C
192# the .cmi file of coccilib
193ocaml/coccilib/coccilib.cmi: ocaml/coccilib.cmi
194 cp ocaml/coccilib.cmi ocaml/coccilib/coccilib.cmi
195
196# ocamlbuild version of the main make targets
197else
198
199all: Makefile.config
200 $(MAKE) $(TARGET_ALL)
201
202world: Makefile.config myocamlbuild.ml version.ml prepare-bundles
203 @echo "building both versions of spatch"
204 $(MAKE) byte
205 $(MAKE) opt-compil
206 @$(MAKE) coccilib-cmi
207 $(MAKE) preinstall
208 $(MAKE) docs
209 @echo ""
210 @echo -e "\tcoccinelle can now be installed via 'make install'"
211
212# note: the 'all-dev' target excludes the documentation and is less noisy
213all-dev: Makefile.config myocamlbuild.ml version.ml prepare-bundles
214 $(MAKE) byte
215 @$(MAKE) coccilib-cmi
216 @$(MAKE) preinstall
217
218all-release: Makefile.config myocamlbuild.ml version.ml prepare-bundles
219 @echo building $(TARGET_SPATCH)
220 $(MAKE) $(TARGET_SPATCH)
221 @$(MAKE) coccilib-cmi
222 $(MAKE) preinstall
223 $(MAKE) docs
224 @echo ""
225 @echo -e "\tcoccinelle can now be installed via 'make install'"
226
227all.opt: Makefile.config myocamlbuild.ml version.ml prepare-bundles
228 $(MAKE) opt-only
229 @$(MAKE) coccilib-cmi
230 $(MAKE) preinstall
231
232byte: Makefile.config myocamlbuild.ml version.ml prepare-bundles
233 $(OCAMLBUILD) -j 0 main.byte
234 cp _build/main.byte $(EXEC)
235
236pure-byte: Makefile.config myocamlbuild.ml version.ml prepare-bundles
237 $(OCAMLBUILD) -j 0 -tag nocustom main.byte
238 cp _build/main.byte $(EXEC)
239
240opt-compil: Makefile.config myocamlbuild.ml version.ml prepare-bundles
241 $(OCAMLBUILD) -j 0 main.native
242 cp _build/main.native $(EXEC).opt
243
244# the .cmi file of coccilib
245_build/ocaml/coccilib.cmi:
246 $(OCAMLBUILD) -j 0 ocaml/coccilib.cmi
247ocaml/coccilib/coccilib.cmi: _build/ocaml/coccilib.cmi
248 cp _build/ocaml/coccilib.cmi ocaml/coccilib/coccilib.cmi
249
250# end of main build target distinction on ocamlbuild
251endif
252
253# aliases for "byte" and "opt-compil"
254opt opt-only: Makefile.config opt-compil
255byte-only: Makefile.config byte
256
257
258# ensures that coccilib.cmi gets build
259.PHONY:: coccilib-cmi
260coccilib-cmi: ocaml/coccilib/coccilib.cmi
261distclean::
262 rm -f ocaml/coccilib/coccilib.cmi
263
264
feec80c3 265subdirs.all:
d6ce1786 266 @+for D in $(MAKESUBDIRS); do $(MAKE) $$D.all || exit 1 ; done
0708f913
C
267
268subdirs.opt:
d6ce1786 269 @+for D in $(MAKESUBDIRS); do $(MAKE) $$D.opt || exit 1 ; done
faf9a90c 270
feec80c3 271$(MAKESUBDIRS:%=%.all):
d6ce1786 272 @$(MAKE) -C $(@:%.all=%) all
faf9a90c
C
273
274$(MAKESUBDIRS:%=%.opt):
d6ce1786 275 @$(MAKE) -C $(@:%.opt=%) all.opt
faf9a90c 276
abad11c5
C
277# This make target prepares the bundled software for building.
278# Note that running 'make' in these subdirectories will
279# automatically prepare the bundled software.
280.PHONY:: prepare-bundles
281prepare-bundles: $(MAKELIBS:%=%/.prepare)
282
283$(MAKELIBS:%=%/.prepare):
284 echo $@
285 @$(MAKE) -C $(@:%.prepare=%) .prepare
286
b1b2de81 287#dependencies:
0708f913
C
288# commons:
289# globals:
feec80c3
C
290# menhirLib:
291# parsing_cocci: commons globals menhirLib
0708f913 292# parsing_c:parsing_cocci
d6ce1786 293# ctl:globals commonsg
0708f913 294# engine: parsing_cocci parsing_c ctl
951c7801 295# popl09:engine
0708f913
C
296# extra: parsing_cocci parsing_c ctl
297# pycaml:
298# python:pycaml parsing_cocci parsing_c
faf9a90c 299
feec80c3 300clean:: Makefile.config
d6ce1786
C
301 @set -e; for i in $(CLEANSUBDIRS); do $(MAKE) -C $$i $@; done
302 @$(MAKE) -C demos/spp $@
34e49164 303
feec80c3 304$(LIBS): $(MAKESUBDIRS:%=%.all)
0708f913 305$(LIBS:.cma=.cmxa): $(MAKESUBDIRS:%=%.opt)
feec80c3 306$(LNKLIBS) : $(MAKESUBDIRS:%=%.all)
97111a47 307$(LNKOPTLIBS) : $(MAKESUBDIRS:%=%.opt)
faf9a90c 308
feec80c3
C
309$(OBJS):$(LIBS)
310$(OPTOBJS):$(LIBS:.cma=.cmxa)
faf9a90c 311
d6ce1786 312$(EXEC): $(LNKLIBS) $(LIBS) $(OBJS)
755320b0 313 $(OCAMLC_CMD) $(BYTECODE_EXTRA) $(FLAGSLIBS) -o $@ $(SYSLIBS) $^
34e49164 314
d6ce1786 315$(EXEC).opt: $(OPTLNKLIBS) $(LIBS:.cma=.cmxa) $(OPTOBJS)
755320b0 316 $(OCAMLOPT_CMD) $(OPTFLAGSLIBS) -o $@ $(SYSLIBS:.cma=.cmxa) $^
34e49164 317
d6ce1786
C
318$(EXEC).top: $(LNKLIBS) $(LIBS) $(OBJS)
319 $(OCAMLMKTOP_CMD) -custom -o $@ $(SYSLIBS) $(FLAGSLIBS) $^
34e49164 320
feec80c3 321clean distclean::
34e49164 322 rm -f $(TARGET) $(TARGET).opt $(TARGET).top
34e49164 323
abad11c5
C
324clean::
325 @if test -n "${OCAMLBUILD}" -d _build; then \
326 $(OCAMLBUILD) -clean; fi
327
328# distclean can run without ocamlbuild configured.
329distclean::
330 -@if test -d _build; then \
331 ocamlbuild -clean; fi
332 rm -rf _build _log
333
b1b2de81
C
334.PHONY:: tools configure
335
336configure:
d6ce1786 337 ./configure $(CONFIGURE_FLAGS)
34e49164 338
d6ce1786
C
339# the dependencies on Makefile.config should give a hint to the programmer that
340# configure should be run again
341Makefile.config: Makefile.config.in configure.ac
342 @echo "Makefile.config needs to be (re)build. Run ./configure $(CONFIGURE_FLAGS) to generate it."
feec80c3 343 @false
708f4980 344
abad11c5
C
345# as above, also for the ocamlbuild plugin
346myocamlbuild.ml: myocamlbuild.ml.in configure.ac
347
97111a47 348tools: $(LIBS) $(LNKLIBS)
34e49164 349 $(MAKE) -C tools
b1b2de81 350
c491d8ee 351distclean::
d6ce1786 352 @if [ -d tools ] ; then $(MAKE) -C tools distclean ; fi
34e49164 353
d6ce1786
C
354# it seems impossible to pass "-static" unless all dependent
355# libraries are also available as static archives.
356# set $(STATIC) to -static if you have such libraries.
34e49164
C
357static:
358 rm -f spatch.opt spatch
d6ce1786 359 $(MAKE) $(STATIC) opt-only
34e49164
C
360 cp spatch.opt spatch
361
d6ce1786
C
362# creates a portable version of spatch, which, however, may
363# be dependent on non-portably dynamic libraries. You
364# may need the stubs, see 'copy-stubs'.
34e49164
C
365purebytecode:
366 rm -f spatch.opt spatch
abad11c5 367ifneq ($(FEATURE_OCAMLBUILD),yes)
d6ce1786 368 $(MAKE) BYTECODE_EXTRA="" byte-only
abad11c5
C
369else
370 @$(MAKE) pure-byte
371endif
d6ce1786
C
372 sed -i '1 s,^#!.*$$,#!/usr/bin/ocamlrun,g' spatch
373
374# copies the stubs libraries (if any) to the root directory
abad11c5 375ifneq ($(FEATURE_OCAMLBUILD),yes)
d6ce1786
C
376copy-stubs:
377 @if test -f ./bundles/pycaml/dllpycaml_stubs.so; then \
378 cp -fv ./bundles/pycaml/dllpycaml_stubs.so .; fi
379 @if test -f ./bundles/pcre/dllpcre_stubs.so; then \
380 cp -fv ./bundles/pcre/dllpcre_stubs.so .; fi
abad11c5
C
381else
382copy-stubs:
383 @if test -f _build/bundles/pycaml/dllpycaml_stubs.so; then \
384 cp -fv _build/bundles/pycaml/dllpycaml_stubs.so .; fi
385 @if test -f _build/bundles/pcre/dllpcre_stubs.so; then \
386 cp -fv _build/bundles/pcre/dllpcre_stubs.so .; fi
387endif
feec80c3
C
388
389##############################################################################
390# Build version information
391##############################################################################
34e49164 392
feec80c3
C
393version.ml:
394 @echo "version.ml is missing. Run ./configure to generate it."
395 @false
34e49164 396
b1b2de81
C
397##############################################################################
398# Build documentation
399##############################################################################
400.PHONY:: docs
401
abad11c5 402ifneq ($(FEATURE_OCAMLBUILD),yes)
b1b2de81 403docs:
abad11c5
C
404else
405docs: prepare-bundles
406endif
feec80c3 407 @$(MAKE) -C docs || (echo "warning: ignored the failed construction of the manual" 1>&2)
abad11c5 408ifneq ($(FEATURE_OCAMLBUILD),yes)
feec80c3 409 @if test "x$(FEATURE_OCAML)" = x1; then \
d6ce1786 410 if test -f ./parsing_c/ast_c.cmo -o -f ./parsing_c/ast_c.cmx; then \
feec80c3 411 $(MAKE) -C ocaml doc; \
d6ce1786 412 else echo "note: to obtain coccilib documenation, it is required to build 'spatch' first so that ./parsing_c/ast_c.cm* gets build."; \
feec80c3 413 fi fi
abad11c5
C
414else
415 @if test "x$(FEATURE_OCAML)" = x1; then \
416 $(MAKE) -C ocaml doc; fi
417endif
feec80c3
C
418 @echo "finished building manuals"
419
420clean:: Makefile.config
f3c4ece6
C
421 $(MAKE) -C docs clean
422 $(MAKE) -C ocaml cleandoc
b1b2de81 423
b1b2de81
C
424##############################################################################
425# Pre-Install (customization of spatch frontend script)
426##############################################################################
b1b2de81 427
90aeb998
C
428preinstall: docs/spatch.1 scripts/spatch scripts/spatch.opt scripts/spatch.byte
429
430docs/spatch.1: Makefile.config
431 $(MAKE) -C docs spatch.1
b1b2de81
C
432
433# user will use spatch to run spatch.opt (native)
feec80c3
C
434scripts/spatch: Makefile.config scripts/spatch.sh
435 cp scripts/spatch.sh scripts/spatch
436 chmod +x scripts/spatch
b1b2de81
C
437
438# user will use spatch to run spatch (bytecode)
feec80c3
C
439scripts/spatch.byte: Makefile.config scripts/spatch.sh
440 cp scripts/spatch.sh scripts/spatch.byte
441 chmod +x scripts/spatch.byte
b1b2de81
C
442
443# user will use spatch.opt to run spatch.opt (native)
feec80c3
C
444scripts/spatch.opt: Makefile.config scripts/spatch.sh
445 cp scripts/spatch.sh scripts/spatch.opt
446 chmod +x scripts/spatch.opt
447
448distclean::
b1b2de81
C
449 rm -f scripts/spatch scripts/spatch.byte scripts/spatch.opt
450
34e49164
C
451##############################################################################
452# Install
453##############################################################################
454
455# don't remove DESTDIR, it can be set by package build system like ebuild
8ba84ae2 456# for staged installation.
abad11c5 457install-common: ocaml/coccilib/coccilib.cmi
feec80c3
C
458 $(MKDIR_P) $(DESTDIR)$(BINDIR)
459 $(MKDIR_P) $(DESTDIR)$(LIBDIR)
460 $(MKDIR_P) $(DESTDIR)$(SHAREDIR)/ocaml
abad11c5
C
461# $(MKDIR_P) $(DESTDIR)$(SHAREDIR)/commons
462# $(MKDIR_P) $(DESTDIR)$(SHAREDIR)/globals
463# $(MKDIR_P) $(DESTDIR)$(SHAREDIR)/parsing_c
8ba84ae2
C
464 $(INSTALL_DATA) standard.h $(DESTDIR)$(SHAREDIR)
465 $(INSTALL_DATA) standard.iso $(DESTDIR)$(SHAREDIR)
abad11c5
C
466 $(INSTALL_DATA) ocaml/coccilib/coccilib.cmi $(DESTDIR)$(SHAREDIR)/ocaml/
467# $(INSTALL_DATA) parsing_c/*.cmi $(DESTDIR)$(SHAREDIR)/parsing_c/
468# $(INSTALL_DATA) commons/*.cmi $(DESTDIR)$(SHAREDIR)/commons/
469# $(INSTALL_DATA) globals/iteration.cmi $(DESTDIR)$(SHAREDIR)/globals/
f3c4ece6
C
470
471install-man:
feec80c3
C
472 @echo "Installing manuals in: ${DESTDIR}${MANDIR}"
473 $(MKDIR_P) $(DESTDIR)$(MANDIR)/man1
474 $(MKDIR_P) $(DESTDIR)$(MANDIR)/man3
8ba84ae2 475 $(INSTALL_DATA) docs/spatch.1 $(DESTDIR)$(MANDIR)/man1/
65038c61 476 $(INSTALL_DATA) docs/Coccilib.3cocci $(DESTDIR)$(MANDIR)/man3/
174d1640
C
477
478install-bash:
feec80c3
C
479 @echo "Installing bash completion in: ${DESTDIR}${BASH_COMPLETION_DIR}"
480 $(MKDIR_P) $(DESTDIR)$(BASH_COMPLETION_DIR)
174d1640
C
481 $(INSTALL_DATA) scripts/spatch.bash_completion \
482 $(DESTDIR)$(BASH_COMPLETION_DIR)/spatch
0708f913 483
c491d8ee 484install-tools:
feec80c3
C
485 @echo "Installing tools in: ${DESTDIR}${BINDIR}"
486 $(MKDIR_P) $(DESTDIR)$(BINDIR)
c491d8ee
C
487 $(INSTALL_PROGRAM) tools/splitpatch \
488 $(DESTDIR)$(BINDIR)/splitpatch
489 $(INSTALL_PROGRAM) tools/cocci-send-email.perl \
490 $(DESTDIR)$(BINDIR)/cocci-send-email.perl
491
8ba84ae2 492install-python:
feec80c3
C
493 @echo "Installing python support in: ${DESTDIR}${SHAREDIR}/python"
494 $(MKDIR_P) $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui
8ba84ae2
C
495 $(INSTALL_DATA) python/coccilib/*.py \
496 $(DESTDIR)$(SHAREDIR)/python/coccilib
497 $(INSTALL_DATA) python/coccilib/coccigui/*.py \
498 $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui
b1b2de81
C
499 $(INSTALL_DATA) python/coccilib/coccigui/pygui.glade \
500 $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui
501 $(INSTALL_DATA) python/coccilib/coccigui/pygui.gladep \
502 $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui
feec80c3 503
d6ce1786
C
504install-stubs:
505 $(MKDIR_P) $(DESTDIR)$(SHAREDIR)
506 @if test -f ./bundles/pycaml/dllpycaml_stubs.so; then \
507 cp -fv ./bundles/pycaml/dllpycaml_stubs.so $(DESTDIR)$(SHAREDIR); fi
508 @if test -f ./bundles/pcre/dllpcre_stubs.so; then \
509 cp -fv ./bundles/pcre/dllpcre_stubs.so $(DESTDIR)$(SHAREDIR); fi
510
511install: install-man install-common install-stubs $(PYTHON_INSTALL_TARGET)
512 rm -f $(DESTDIR)$(SHAREDIR)/spatch
513 rm -f $(DESTDIR)$(SHAREDIR)/spatch.opt
feec80c3
C
514 @if test -x spatch -o -x spatch.opt; then \
515 $(MAKE) install-def;fi
516 @if test -x spatch ; then \
517 $(MAKE) install-byte; fi
518 @if test -x spatch.opt ; then \
519 $(MAKE) install-opt;fi
b1b2de81 520 @if test ! -x spatch -a ! -x spatch.opt ; then \
feec80c3 521 echo -e "\n\n\t==> Run 'make', 'make opt', or both first. <==\n\n";fi
708f4980 522 @echo ""
feec80c3
C
523 @echo -e "\tYou can also install spatch by copying the program spatch"
524 @echo -e "\t(available in this directory) anywhere you want and"
525 @echo -e "\tgive it the right options to find its configuration files."
708f4980 526 @echo ""
b1b2de81 527
feec80c3
C
528#
529# Installation of spatch and spatch.opt and their wrappers
530#
531
532# user will use spatch to run one of the binaries
708f4980 533install-def:
b1b2de81 534 $(INSTALL_PROGRAM) scripts/spatch $(DESTDIR)$(BINDIR)/spatch
0708f913 535
feec80c3 536# user will use spatch.byte to run spatch (bytecode)
708f4980 537install-byte:
8ba84ae2 538 $(INSTALL_PROGRAM) spatch $(DESTDIR)$(SHAREDIR)
feec80c3 539 $(INSTALL_PROGRAM) scripts/spatch.byte $(DESTDIR)$(BINDIR)/spatch.byte
0708f913
C
540
541# user will use spatch.opt to run spatch.opt (native)
708f4980 542install-opt:
8ba84ae2 543 $(INSTALL_PROGRAM) spatch.opt $(DESTDIR)$(SHAREDIR)
b1b2de81 544 $(INSTALL_PROGRAM) scripts/spatch.opt $(DESTDIR)$(BINDIR)/spatch.opt
34e49164
C
545
546uninstall:
547 rm -f $(DESTDIR)$(BINDIR)/spatch
8ba84ae2 548 rm -f $(DESTDIR)$(BINDIR)/spatch.opt
feec80c3 549 rm -f $(DESTDIR)$(BINDIR)/spatch.byte
d6ce1786
C
550 rm -f $(DESTDIR)$(SHAREDIR)/dllpycaml_stubs.so
551 rm -f $(DESTDIR)$(SHAREDIR)/dllpcre_stubs.so
90aeb998
C
552 rm -f $(DESTDIR)$(SHAREDIR)/spatch
553 rm -f $(DESTDIR)$(SHAREDIR)/spatch.opt
34e49164
C
554 rm -f $(DESTDIR)$(SHAREDIR)/standard.h
555 rm -f $(DESTDIR)$(SHAREDIR)/standard.iso
174d1640 556 rm -f $(DESTDIR)$(SHAREDIR)/ocaml/coccilib.cmi
413ffc02 557 rm -f $(DESTDIR)$(SHAREDIR)/parsing_c/*.cmi
ca417fcf
C
558 rm -f $(DESTDIR)$(SHAREDIR)/commons/*.cmi
559 rm -f $(DESTDIR)$(SHAREDIR)/globals/*.cmi
90aeb998
C
560 rm -f $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui/*
561 rm -f $(DESTDIR)$(SHAREDIR)/python/coccilib/*.py
562 rmdir --ignore-fail-on-non-empty -p \
563 $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui
ca417fcf
C
564 rmdir $(DESTDIR)$(SHAREDIR)/globals
565 rmdir $(DESTDIR)$(SHAREDIR)/commons
566 rmdir $(DESTDIR)$(SHAREDIR)/parsing_c
567 rmdir $(DESTDIR)$(SHAREDIR)/ocaml
568 rmdir $(DESTDIR)$(SHAREDIR)
faf9a90c 569 rm -f $(DESTDIR)$(MANDIR)/man1/spatch.1
65038c61 570 rm -f $(DESTDIR)$(MANDIR)/man3/Coccilib.3cocci
34e49164 571
aba5c457
C
572uninstall-bash:
573 rm -f $(DESTDIR)$(BASH_COMPLETION_DIR)/spatch
574 rmdir --ignore-fail-on-non-empty -p \
575 $(DESTDIR)$(BASH_COMPLETION_DIR)
576
c491d8ee
C
577uninstall-tools:
578 rm -f $(DESTDIR)$(BINDIR)/splitpatch
579 rm -f $(DESTDIR)$(BINDIR)/cocci-send-email.perl
580
34e49164 581version:
951c7801 582 @echo "spatch $(VERSION)"
c3e37e97 583 @echo "spatch $(PKGVERSION) ($(DISTRIB_ID))"
951c7801 584 @echo "coccicheck $(CCVERSION)"
34e49164
C
585
586
587##############################################################################
5636bb2c 588# Deb package (for Ubuntu) and release rules
34e49164
C
589##############################################################################
590
5636bb2c 591include Makefile.release
c3e37e97 592
34e49164
C
593##############################################################################
594# Developer rules
595##############################################################################
596
7f004419
C
597-include Makefile.dev
598
34e49164
C
599test: $(TARGET)
600 ./$(TARGET) -testall
601
602testparsing:
603 ./$(TARGET) -D standard.h -parse_c -dir tests/
604
d6ce1786
C
605# the check target runs:
606# * some feature tests (depending on what is enabled)
607# * the test suite
608check: scripts/spatch
609 @echo "testing if spatch works on hello world..."
610 @COCCINELLE_HOME="$$(pwd)" ./scripts/spatch --sp-file demos/hello/hello-smpl.cocci demos/hello/helloworld.c --very-quiet | grep -q '+ printf("world, hello!");'
611 @echo "testing if spatch works with regexes..."
612 @COCCINELLE_HOME="$$(pwd)" ./scripts/spatch --sp-file demos/hello/hello-regexp.cocci demos/hello/helloworld.c --very-quiet | grep -q '+ printf("world, hello!");'
613 @if test "x${FEATURE_OCAML}" = x1 -a -z "${NO_OCAMLFIND}"; then \
614 echo "testing if spatch works with ocaml scripts..."; \
615 COCCINELLE_HOME="$$(pwd)" ./scripts/spatch --sp-file demos/hello/hello-ocaml.cocci demos/hello/helloworld.c --very-quiet | grep -q 'Hello at: 2'; fi
616 @if test "x${FEATURE_PYTHON}" = x1; then \
617 echo "testing if spatch works with python scripts..."; \
618 COCCINELLE_HOME="$$(pwd)" ./scripts/spatch --sp-file demos/hello/hello-python.cocci demos/hello/helloworld.c --very-quiet | grep -q 'Hello at: 2'; fi
619 @echo running the test suite
620 COCCINELLE_HOME="$$(pwd)" ./scripts/spatch --testall --no-update-score-file
34e49164 621
faf9a90c
C
622# -inline 0 to see all the functions in the profile.
623# Can also use the profile framework in commons/ and run your program
34e49164
C
624# with -profile.
625forprofiling:
d6ce1786 626 $(MAKE) OPTFLAGS="-p -inline 0 ${EXTRA_OCAML_FLAGS}" opt
34e49164 627
feec80c3 628clean distclean::
755320b0 629 rm -f gmon.out ocamlprof.dump
34e49164
C
630
631tags:
632 otags -no-mli-tags -r .
633
634dependencygraph:
feec80c3 635 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 636 ocamldot -lr /tmp/dependfull.depend > /tmp/dependfull.dot
34e49164 637 dot -Tps /tmp/dependfull.dot > /tmp/dependfull.ps
485bce71 638 ps2pdf /tmp/dependfull.ps /tmp/dependfull.pdf
34e49164
C
639
640##############################################################################
641# Misc rules
642##############################################################################
643
faf9a90c 644# each member of the project can have its own test.ml. this file is
34e49164 645# not under CVS.
faf9a90c 646test.ml:
34e49164
C
647 echo "let foo_ctl () = failwith \"there is no foo_ctl formula\"" \
648 > test.ml
649
34e49164
C
650##############################################################################
651# Generic ocaml rules
652##############################################################################
653
654.SUFFIXES: .ml .mli .cmo .cmi .cmx
655
656.ml.cmo:
feec80c3 657 $(OCAMLC_CMD) -c $<
34e49164 658.mli.cmi:
feec80c3 659 $(OCAMLC_CMD) -c $<
34e49164 660.ml.cmx:
feec80c3 661 $(OCAMLOPT_CMD) -c $<
34e49164 662
faf9a90c 663.ml.mldepend:
feec80c3 664 $(OCAMLC_CMD) -i $<
34e49164 665
feec80c3
C
666clean distclean::
667 rm -f .depend
34e49164 668 rm -f *.cm[iox] *.o *.annot
34e49164
C
669 rm -f *~ .*~ *.exe #*#
670
feec80c3 671distclean::
d6ce1786 672 set -e; for i in $(CLEANSUBDIRS); do $(MAKE) -C $$i $@; done
feec80c3 673 rm -f test.ml
755320b0 674 rm -f TAGS *.native *.byte *.d.native *.p.byte
abad11c5
C
675 if test -z "${KEEP_GENERATED}"; then \
676 rm -f tests/SCORE_actual.sexp tests/SCORE_best_of_both.sexp; fi
17ba0788 677 find . -name ".#*1.*" | xargs rm -f
feec80c3 678 rm -f $(EXEC) $(EXEC).opt $(EXEC).top
abad11c5 679 rm -f setup/Makefile
b1b2de81 680
d6ce1786 681# using 'touch' to prevent infinite recursion with 'make depend'
feec80c3
C
682.PHONY:: depend
683.depend: Makefile.config test.ml version
d6ce1786
C
684 @touch .depend
685 @$(MAKE) depend
34e49164 686
feec80c3
C
687depend: Makefile.config test.ml version
688 @echo constructing '.depend'
d6ce1786
C
689 @rm -f .depend
690 @set -e; for i in $(MAKESUBDIRS); do $(MAKE) -C $$i depend; done
feec80c3 691 $(OCAMLDEP_CMD) *.mli *.ml > .depend
b1b2de81 692
feec80c3
C
693##############################################################################
694# configure-related
695##############################################################################
34e49164 696
feec80c3
C
697distclean::
698 @echo "cleaning configured files"
699 if test -z "${KEEP_CONFIG}"; then rm -f Makefile.config; fi
700 rm -rf autom4te.cache
701 rm -f config.status
702 rm -f config.log
abad11c5
C
703 if test -z "${KEEP_GENERATED}"; then \
704 rm -f version.ml; fi
feec80c3
C
705 rm -f globals/config.ml
706 rm -f globals/regexp.ml python/pycocci.ml ocaml/prepare_ocamlcocci.ml
707 rm -f scripts/spatch.sh
d6ce1786 708 rm -f aclocal.m4
feec80c3
C
709 @echo "run 'configure' again prior to building coccinelle"
710
711
d6ce1786
C
712# don't include depend for those actions that either don't need
713# depend or that call 'make .depend' explicitly.
714# TODO: find a nicer way to express this
feec80c3
C
715ifneq ($(MAKECMDGOALS),clean)
716ifneq ($(MAKECMDGOALS),distclean)
717ifneq ($(MAKECMDGOALS),configure)
718ifneq ($(MAKECMDGOALS),prerelease)
719ifneq ($(MAKECMDGOALS),release)
720ifneq ($(MAKECMDGOALS),package)
d6ce1786
C
721ifneq ($(MAKECMDGOALS),all-release)
722ifneq ($(MAKECMDGOALS),all-dev)
723ifneq ($(MAKECMDGOALS),all)
724ifneq ($(MAKECMDGOALS),.depend)
725ifneq ($(MAKECMDGOALS),depend)
abad11c5 726ifneq ($(FEATURE_OCAMLBUILD),yes)
34e49164 727-include .depend
feec80c3
C
728endif
729endif
730endif
731endif
732endif
733endif
d6ce1786
C
734endif
735endif
736endif
737endif
738endif
abad11c5 739endif
d6ce1786
C
740
741include Makefile.common