Coccinelle release 1.0.0-rc14
[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 \
90aeb998 67 commons/commons_sexp.cma \
b1b2de81 68 globals/globals.cma \
34e49164
C
69 ctl/ctl.cma \
70 parsing_cocci/cocci_parser.cma parsing_c/parsing_c.cma \
951c7801 71 engine/cocciengine.cma popl09/popl.cma \
174d1640 72 extra/extra.cma python/coccipython.cma ocaml/cocciocaml.cma
90aeb998 73
feec80c3
C
74MAKESUBDIRS=$(MAKELIBS) commons \
75 globals ctl parsing_cocci parsing_c \
76 engine popl09 extra python ocaml
34e49164 77
feec80c3
C
78CLEANSUBDIRS=commons \
79 globals ctl parsing_cocci parsing_c \
80 engine popl09 extra python ocaml docs \
97111a47 81 $(MAKELIBS)
174d1640 82
feec80c3
C
83INCLUDEDIRSDEP=commons commons/ocamlextra \
84 globals ctl \
97111a47 85 parsing_cocci parsing_c engine popl09 extra python ocaml \
feec80c3 86 $(MAKELIBS)
97111a47 87
feec80c3 88INCLUDEDIRS=$(INCLUDEDIRSDEP) $(PCREDIR) $(INCLIBS)
90aeb998 89
34e49164
C
90##############################################################################
91# Generic variables
92##############################################################################
93
feec80c3
C
94# sort to remove duplicates
95INCLUDESET=$(sort $(INCLUDEDIRS))
96INCLUDES=$(INCLUDESET:%=-I %)
34e49164
C
97
98OBJS= $(SRC:.ml=.cmo)
99OPTOBJS= $(SRC:.ml=.cmx)
100
101EXEC=$(TARGET)
102
103##############################################################################
104# Generic ocaml variables
105##############################################################################
106
feec80c3
C
107OCAMLC_CMD=$(OCAMLC) $(OCAMLCFLAGS) $(INCLUDES)
108OCAMLOPT_CMD=$(OCAMLOPT) $(OPTFLAGS) $(INCLUDES)
109OCAMLYACC_CMD=$(OCAMLYACC) -v
110OCAMLDEP_CMD=$(OCAMLDEP) $(INCLUDEDIRSDEP:%=-I %)
111OCAMLMKTOP_CMD=$(OCAMLMKTOP) -g -custom $(INCLUDES)
34e49164 112
d6ce1786
C
113# these are unused at the moment (todo: remove)
114EXTRA_CFLAGS= # -static -pie -fpie -fPIE -static-libgcc
115EXTRA_OCAML_CFLAGS=$(EXTRA_CFLAGS:%=-ccopt %)
34e49164 116
d6ce1786
C
117# 'make purebytecode' unsets this definition
118BYTECODE_EXTRA=-custom $(EXTRA_OCAML_FLAGS)
34e49164
C
119
120##############################################################################
121# Top rules
122##############################################################################
feec80c3
C
123.PHONY:: all all.opt byte opt top clean distclean configure opt-compil
124.PHONY:: $(MAKESUBDIRS:%=%.all) $(MAKESUBDIRS:%=%.opt) subdirs.all subdirs.opt
125.PHONY:: all-opt all-byte byte-only opt-only
d6ce1786 126.PHONY:: copy-stubs install-stubs install install-man install-python install-common
b1b2de81 127
b1b2de81 128
feec80c3
C
129# All make targets that are expected to be an entry point have a dependency on
130# 'Makefile.config' to ensure that if Makefile.config is not present, an error
131# message is printed first before any other actions are executed.
132# In addition, the targets that actually build something have a dependency on
133# '.depend' and 'version.ml'.
faf9a90c 134
d6ce1786
C
135# dispatches to either 'all-dev' or 'all-release'
136all: Makefile.config
137 @$(MAKE) .depend
138 $(MAKE) $(TARGET_ALL)
feec80c3
C
139
140# make "all" comes in three flavours
d6ce1786 141world: Makefile.config version.ml
feec80c3 142 @echo "building both versions of spatch"
d6ce1786 143 $(MAKE) .depend
b1b2de81 144 $(MAKE) byte
708f4980 145 $(MAKE) opt-compil
feec80c3
C
146 $(MAKE) preinstall
147 $(MAKE) docs
148 @echo ""
149 @echo -e "\tcoccinelle can now be installed via 'make install'"
150
151# note: the 'all-dev' target excludes the documentation
d6ce1786
C
152all-dev: Makefile.config version.ml
153 @$(MAKE) .depend
feec80c3
C
154 @echo "building the unoptimized version of spatch"
155 $(MAKE) byte
d6ce1786 156 @$(MAKE) preinstall
feec80c3
C
157 @echo ""
158 @echo -e "\tcoccinelle can now be installed via 'make install'"
159
d6ce1786
C
160all-release: Makefile.config version.ml
161 @echo building $(TARGET_SPATCH)
162 $(MAKE) .depend
163 $(MAKE) $(TARGET_SPATCH)
feec80c3
C
164 $(MAKE) preinstall
165 $(MAKE) docs
166 @echo ""
167 @echo -e "\tcoccinelle can now be installed via 'make install'"
168
d6ce1786
C
169all.opt: Makefile.config
170 @$(MAKE) .depend
171 $(MAKE) opt-only
172 $(MAKE) preinstall
b1b2de81 173
feec80c3
C
174# aliases for "byte" and "opt-compil"
175opt opt-only: Makefile.config opt-compil
176byte-only: Makefile.config byte
177
d6ce1786
C
178byte: Makefile.config version.ml
179 @$(MAKE) .depend
180 @$(MAKE) subdirs.all
181 @$(MAKE) $(EXEC)
feec80c3
C
182 @echo the compilation of $(EXEC) finished
183 @echo $(EXEC) can be installed or used
faf9a90c 184
d6ce1786
C
185opt-compil: Makefile.config version.ml
186 $(MAKE) .depend
187 $(MAKE) subdirs.opt BUILD_OPT=yes
188 $(MAKE) $(EXEC).opt BUILD_OPT=yes
feec80c3
C
189 @echo the compilation of $(EXEC).opt finished
190 @echo $(EXEC).opt can be installed or used
faf9a90c 191
485bce71 192top: $(EXEC).top
34e49164 193
feec80c3 194subdirs.all:
d6ce1786
C
195 @+for D in $(MAKESUBDIRS); do $(MAKE) $$D.all || exit 1 ; done
196 @$(MAKE) -C commons sexp.all
0708f913
C
197
198subdirs.opt:
d6ce1786
C
199 @+for D in $(MAKESUBDIRS); do $(MAKE) $$D.opt || exit 1 ; done
200 @$(MAKE) -C commons sexp.opt
faf9a90c 201
feec80c3 202$(MAKESUBDIRS:%=%.all):
d6ce1786 203 @$(MAKE) -C $(@:%.all=%) all
faf9a90c
C
204
205$(MAKESUBDIRS:%=%.opt):
d6ce1786 206 @$(MAKE) -C $(@:%.opt=%) all.opt
faf9a90c 207
b1b2de81 208#dependencies:
0708f913
C
209# commons:
210# globals:
feec80c3
C
211# menhirLib:
212# parsing_cocci: commons globals menhirLib
0708f913 213# parsing_c:parsing_cocci
d6ce1786 214# ctl:globals commonsg
0708f913 215# engine: parsing_cocci parsing_c ctl
951c7801 216# popl09:engine
0708f913
C
217# extra: parsing_cocci parsing_c ctl
218# pycaml:
219# python:pycaml parsing_cocci parsing_c
faf9a90c 220
feec80c3 221clean:: Makefile.config
d6ce1786
C
222 @set -e; for i in $(CLEANSUBDIRS); do $(MAKE) -C $$i $@; done
223 @$(MAKE) -C demos/spp $@
34e49164 224
feec80c3 225$(LIBS): $(MAKESUBDIRS:%=%.all)
0708f913 226$(LIBS:.cma=.cmxa): $(MAKESUBDIRS:%=%.opt)
feec80c3 227$(LNKLIBS) : $(MAKESUBDIRS:%=%.all)
97111a47 228$(LNKOPTLIBS) : $(MAKESUBDIRS:%=%.opt)
faf9a90c 229
feec80c3
C
230$(OBJS):$(LIBS)
231$(OPTOBJS):$(LIBS:.cma=.cmxa)
faf9a90c 232
d6ce1786
C
233$(EXEC): $(LNKLIBS) $(LIBS) $(OBJS)
234 $(OCAMLC_CMD) -thread $(BYTECODE_EXTRA) $(FLAGSLIBS) -o $@ $(SYSLIBS) $^
34e49164 235
d6ce1786
C
236$(EXEC).opt: $(OPTLNKLIBS) $(LIBS:.cma=.cmxa) $(OPTOBJS)
237 $(OCAMLOPT_CMD) -thread $(OPTFLAGSLIBS) -o $@ $(SYSLIBS:.cma=.cmxa) $^
34e49164 238
d6ce1786
C
239$(EXEC).top: $(LNKLIBS) $(LIBS) $(OBJS)
240 $(OCAMLMKTOP_CMD) -custom -o $@ $(SYSLIBS) $(FLAGSLIBS) $^
34e49164 241
feec80c3 242clean distclean::
34e49164 243 rm -f $(TARGET) $(TARGET).opt $(TARGET).top
34e49164 244
b1b2de81
C
245.PHONY:: tools configure
246
247configure:
d6ce1786 248 ./configure $(CONFIGURE_FLAGS)
34e49164 249
d6ce1786
C
250# the dependencies on Makefile.config should give a hint to the programmer that
251# configure should be run again
252Makefile.config: Makefile.config.in configure.ac
253 @echo "Makefile.config needs to be (re)build. Run ./configure $(CONFIGURE_FLAGS) to generate it."
feec80c3 254 @false
708f4980 255
97111a47 256tools: $(LIBS) $(LNKLIBS)
34e49164 257 $(MAKE) -C tools
b1b2de81 258
c491d8ee 259distclean::
d6ce1786 260 @if [ -d tools ] ; then $(MAKE) -C tools distclean ; fi
34e49164 261
d6ce1786
C
262# it seems impossible to pass "-static" unless all dependent
263# libraries are also available as static archives.
264# set $(STATIC) to -static if you have such libraries.
34e49164
C
265static:
266 rm -f spatch.opt spatch
d6ce1786 267 $(MAKE) $(STATIC) opt-only
34e49164
C
268 cp spatch.opt spatch
269
d6ce1786
C
270# creates a portable version of spatch, which, however, may
271# be dependent on non-portably dynamic libraries. You
272# may need the stubs, see 'copy-stubs'.
34e49164
C
273purebytecode:
274 rm -f spatch.opt spatch
d6ce1786
C
275 $(MAKE) BYTECODE_EXTRA="" byte-only
276 sed -i '1 s,^#!.*$$,#!/usr/bin/ocamlrun,g' spatch
277
278# copies the stubs libraries (if any) to the root directory
279copy-stubs:
280 @if test -f ./bundles/pycaml/dllpycaml_stubs.so; then \
281 cp -fv ./bundles/pycaml/dllpycaml_stubs.so .; fi
282 @if test -f ./bundles/pcre/dllpcre_stubs.so; then \
283 cp -fv ./bundles/pcre/dllpcre_stubs.so .; fi
feec80c3
C
284
285##############################################################################
286# Build version information
287##############################################################################
34e49164 288
feec80c3
C
289version.ml:
290 @echo "version.ml is missing. Run ./configure to generate it."
291 @false
34e49164 292
b1b2de81
C
293##############################################################################
294# Build documentation
295##############################################################################
296.PHONY:: docs
297
298docs:
feec80c3
C
299 @$(MAKE) -C docs || (echo "warning: ignored the failed construction of the manual" 1>&2)
300 @if test "x$(FEATURE_OCAML)" = x1; then \
d6ce1786 301 if test -f ./parsing_c/ast_c.cmo -o -f ./parsing_c/ast_c.cmx; then \
feec80c3 302 $(MAKE) -C ocaml doc; \
d6ce1786 303 else echo "note: to obtain coccilib documenation, it is required to build 'spatch' first so that ./parsing_c/ast_c.cm* gets build."; \
feec80c3
C
304 fi fi
305 @echo "finished building manuals"
306
307clean:: Makefile.config
f3c4ece6
C
308 $(MAKE) -C docs clean
309 $(MAKE) -C ocaml cleandoc
b1b2de81 310
b1b2de81
C
311##############################################################################
312# Pre-Install (customization of spatch frontend script)
313##############################################################################
b1b2de81 314
90aeb998 315preinstall: docs/spatch.1 scripts/spatch scripts/spatch.opt scripts/spatch.byte
d6ce1786 316 @echo "generated the wrapper scripts for spatch (the frontends)"
90aeb998
C
317
318docs/spatch.1: Makefile.config
319 $(MAKE) -C docs spatch.1
b1b2de81
C
320
321# user will use spatch to run spatch.opt (native)
feec80c3
C
322scripts/spatch: Makefile.config scripts/spatch.sh
323 cp scripts/spatch.sh scripts/spatch
324 chmod +x scripts/spatch
b1b2de81
C
325
326# user will use spatch to run spatch (bytecode)
feec80c3
C
327scripts/spatch.byte: Makefile.config scripts/spatch.sh
328 cp scripts/spatch.sh scripts/spatch.byte
329 chmod +x scripts/spatch.byte
b1b2de81
C
330
331# user will use spatch.opt to run spatch.opt (native)
feec80c3
C
332scripts/spatch.opt: Makefile.config scripts/spatch.sh
333 cp scripts/spatch.sh scripts/spatch.opt
334 chmod +x scripts/spatch.opt
335
336distclean::
b1b2de81
C
337 rm -f scripts/spatch scripts/spatch.byte scripts/spatch.opt
338
34e49164
C
339##############################################################################
340# Install
341##############################################################################
342
343# don't remove DESTDIR, it can be set by package build system like ebuild
8ba84ae2 344# for staged installation.
0708f913 345install-common:
feec80c3
C
346 $(MKDIR_P) $(DESTDIR)$(BINDIR)
347 $(MKDIR_P) $(DESTDIR)$(LIBDIR)
348 $(MKDIR_P) $(DESTDIR)$(SHAREDIR)/ocaml
349 $(MKDIR_P) $(DESTDIR)$(SHAREDIR)/commons
350 $(MKDIR_P) $(DESTDIR)$(SHAREDIR)/globals
351 $(MKDIR_P) $(DESTDIR)$(SHAREDIR)/parsing_c
8ba84ae2
C
352 $(INSTALL_DATA) standard.h $(DESTDIR)$(SHAREDIR)
353 $(INSTALL_DATA) standard.iso $(DESTDIR)$(SHAREDIR)
174d1640 354 $(INSTALL_DATA) ocaml/coccilib.cmi $(DESTDIR)$(SHAREDIR)/ocaml/
413ffc02
C
355 $(INSTALL_DATA) parsing_c/*.cmi $(DESTDIR)$(SHAREDIR)/parsing_c/
356 $(INSTALL_DATA) commons/*.cmi $(DESTDIR)$(SHAREDIR)/commons/
ca417fcf 357 $(INSTALL_DATA) globals/iteration.cmi $(DESTDIR)$(SHAREDIR)/globals/
f3c4ece6
C
358
359install-man:
feec80c3
C
360 @echo "Installing manuals in: ${DESTDIR}${MANDIR}"
361 $(MKDIR_P) $(DESTDIR)$(MANDIR)/man1
362 $(MKDIR_P) $(DESTDIR)$(MANDIR)/man3
8ba84ae2 363 $(INSTALL_DATA) docs/spatch.1 $(DESTDIR)$(MANDIR)/man1/
65038c61 364 $(INSTALL_DATA) docs/Coccilib.3cocci $(DESTDIR)$(MANDIR)/man3/
174d1640
C
365
366install-bash:
feec80c3
C
367 @echo "Installing bash completion in: ${DESTDIR}${BASH_COMPLETION_DIR}"
368 $(MKDIR_P) $(DESTDIR)$(BASH_COMPLETION_DIR)
174d1640
C
369 $(INSTALL_DATA) scripts/spatch.bash_completion \
370 $(DESTDIR)$(BASH_COMPLETION_DIR)/spatch
0708f913 371
c491d8ee 372install-tools:
feec80c3
C
373 @echo "Installing tools in: ${DESTDIR}${BINDIR}"
374 $(MKDIR_P) $(DESTDIR)$(BINDIR)
c491d8ee
C
375 $(INSTALL_PROGRAM) tools/splitpatch \
376 $(DESTDIR)$(BINDIR)/splitpatch
377 $(INSTALL_PROGRAM) tools/cocci-send-email.perl \
378 $(DESTDIR)$(BINDIR)/cocci-send-email.perl
379
8ba84ae2 380install-python:
feec80c3
C
381 @echo "Installing python support in: ${DESTDIR}${SHAREDIR}/python"
382 $(MKDIR_P) $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui
8ba84ae2
C
383 $(INSTALL_DATA) python/coccilib/*.py \
384 $(DESTDIR)$(SHAREDIR)/python/coccilib
385 $(INSTALL_DATA) python/coccilib/coccigui/*.py \
386 $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui
b1b2de81
C
387 $(INSTALL_DATA) python/coccilib/coccigui/pygui.glade \
388 $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui
389 $(INSTALL_DATA) python/coccilib/coccigui/pygui.gladep \
390 $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui
feec80c3 391
d6ce1786
C
392install-stubs:
393 $(MKDIR_P) $(DESTDIR)$(SHAREDIR)
394 @if test -f ./bundles/pycaml/dllpycaml_stubs.so; then \
395 cp -fv ./bundles/pycaml/dllpycaml_stubs.so $(DESTDIR)$(SHAREDIR); fi
396 @if test -f ./bundles/pcre/dllpcre_stubs.so; then \
397 cp -fv ./bundles/pcre/dllpcre_stubs.so $(DESTDIR)$(SHAREDIR); fi
398
399install: install-man install-common install-stubs $(PYTHON_INSTALL_TARGET)
400 rm -f $(DESTDIR)$(SHAREDIR)/spatch
401 rm -f $(DESTDIR)$(SHAREDIR)/spatch.opt
feec80c3
C
402 @if test -x spatch -o -x spatch.opt; then \
403 $(MAKE) install-def;fi
404 @if test -x spatch ; then \
405 $(MAKE) install-byte; fi
406 @if test -x spatch.opt ; then \
407 $(MAKE) install-opt;fi
b1b2de81 408 @if test ! -x spatch -a ! -x spatch.opt ; then \
feec80c3 409 echo -e "\n\n\t==> Run 'make', 'make opt', or both first. <==\n\n";fi
708f4980 410 @echo ""
feec80c3
C
411 @echo -e "\tYou can also install spatch by copying the program spatch"
412 @echo -e "\t(available in this directory) anywhere you want and"
413 @echo -e "\tgive it the right options to find its configuration files."
708f4980 414 @echo ""
b1b2de81 415
feec80c3
C
416#
417# Installation of spatch and spatch.opt and their wrappers
418#
419
420# user will use spatch to run one of the binaries
708f4980 421install-def:
b1b2de81 422 $(INSTALL_PROGRAM) scripts/spatch $(DESTDIR)$(BINDIR)/spatch
0708f913 423
feec80c3 424# user will use spatch.byte to run spatch (bytecode)
708f4980 425install-byte:
8ba84ae2 426 $(INSTALL_PROGRAM) spatch $(DESTDIR)$(SHAREDIR)
feec80c3 427 $(INSTALL_PROGRAM) scripts/spatch.byte $(DESTDIR)$(BINDIR)/spatch.byte
0708f913
C
428
429# user will use spatch.opt to run spatch.opt (native)
708f4980 430install-opt:
8ba84ae2 431 $(INSTALL_PROGRAM) spatch.opt $(DESTDIR)$(SHAREDIR)
b1b2de81 432 $(INSTALL_PROGRAM) scripts/spatch.opt $(DESTDIR)$(BINDIR)/spatch.opt
34e49164
C
433
434uninstall:
435 rm -f $(DESTDIR)$(BINDIR)/spatch
8ba84ae2 436 rm -f $(DESTDIR)$(BINDIR)/spatch.opt
feec80c3 437 rm -f $(DESTDIR)$(BINDIR)/spatch.byte
d6ce1786
C
438 rm -f $(DESTDIR)$(SHAREDIR)/dllpycaml_stubs.so
439 rm -f $(DESTDIR)$(SHAREDIR)/dllpcre_stubs.so
90aeb998
C
440 rm -f $(DESTDIR)$(SHAREDIR)/spatch
441 rm -f $(DESTDIR)$(SHAREDIR)/spatch.opt
34e49164
C
442 rm -f $(DESTDIR)$(SHAREDIR)/standard.h
443 rm -f $(DESTDIR)$(SHAREDIR)/standard.iso
174d1640 444 rm -f $(DESTDIR)$(SHAREDIR)/ocaml/coccilib.cmi
413ffc02 445 rm -f $(DESTDIR)$(SHAREDIR)/parsing_c/*.cmi
ca417fcf
C
446 rm -f $(DESTDIR)$(SHAREDIR)/commons/*.cmi
447 rm -f $(DESTDIR)$(SHAREDIR)/globals/*.cmi
90aeb998
C
448 rm -f $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui/*
449 rm -f $(DESTDIR)$(SHAREDIR)/python/coccilib/*.py
450 rmdir --ignore-fail-on-non-empty -p \
451 $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui
ca417fcf
C
452 rmdir $(DESTDIR)$(SHAREDIR)/globals
453 rmdir $(DESTDIR)$(SHAREDIR)/commons
454 rmdir $(DESTDIR)$(SHAREDIR)/parsing_c
455 rmdir $(DESTDIR)$(SHAREDIR)/ocaml
456 rmdir $(DESTDIR)$(SHAREDIR)
faf9a90c 457 rm -f $(DESTDIR)$(MANDIR)/man1/spatch.1
65038c61 458 rm -f $(DESTDIR)$(MANDIR)/man3/Coccilib.3cocci
34e49164 459
aba5c457
C
460uninstall-bash:
461 rm -f $(DESTDIR)$(BASH_COMPLETION_DIR)/spatch
462 rmdir --ignore-fail-on-non-empty -p \
463 $(DESTDIR)$(BASH_COMPLETION_DIR)
464
c491d8ee
C
465uninstall-tools:
466 rm -f $(DESTDIR)$(BINDIR)/splitpatch
467 rm -f $(DESTDIR)$(BINDIR)/cocci-send-email.perl
468
34e49164 469version:
951c7801 470 @echo "spatch $(VERSION)"
c3e37e97 471 @echo "spatch $(PKGVERSION) ($(DISTRIB_ID))"
951c7801 472 @echo "coccicheck $(CCVERSION)"
34e49164
C
473
474
475##############################################################################
5636bb2c 476# Deb package (for Ubuntu) and release rules
34e49164
C
477##############################################################################
478
5636bb2c 479include Makefile.release
c3e37e97 480
34e49164
C
481##############################################################################
482# Developer rules
483##############################################################################
484
7f004419
C
485-include Makefile.dev
486
34e49164
C
487test: $(TARGET)
488 ./$(TARGET) -testall
489
490testparsing:
491 ./$(TARGET) -D standard.h -parse_c -dir tests/
492
d6ce1786
C
493# the check target runs:
494# * some feature tests (depending on what is enabled)
495# * the test suite
496check: scripts/spatch
497 @echo "testing if spatch works on hello world..."
498 @COCCINELLE_HOME="$$(pwd)" ./scripts/spatch --sp-file demos/hello/hello-smpl.cocci demos/hello/helloworld.c --very-quiet | grep -q '+ printf("world, hello!");'
499 @echo "testing if spatch works with regexes..."
500 @COCCINELLE_HOME="$$(pwd)" ./scripts/spatch --sp-file demos/hello/hello-regexp.cocci demos/hello/helloworld.c --very-quiet | grep -q '+ printf("world, hello!");'
501 @if test "x${FEATURE_OCAML}" = x1 -a -z "${NO_OCAMLFIND}"; then \
502 echo "testing if spatch works with ocaml scripts..."; \
503 COCCINELLE_HOME="$$(pwd)" ./scripts/spatch --sp-file demos/hello/hello-ocaml.cocci demos/hello/helloworld.c --very-quiet | grep -q 'Hello at: 2'; fi
504 @if test "x${FEATURE_PYTHON}" = x1; then \
505 echo "testing if spatch works with python scripts..."; \
506 COCCINELLE_HOME="$$(pwd)" ./scripts/spatch --sp-file demos/hello/hello-python.cocci demos/hello/helloworld.c --very-quiet | grep -q 'Hello at: 2'; fi
507 @echo running the test suite
508 COCCINELLE_HOME="$$(pwd)" ./scripts/spatch --testall --no-update-score-file
34e49164 509
faf9a90c
C
510# -inline 0 to see all the functions in the profile.
511# Can also use the profile framework in commons/ and run your program
34e49164
C
512# with -profile.
513forprofiling:
d6ce1786 514 $(MAKE) OPTFLAGS="-p -inline 0 ${EXTRA_OCAML_FLAGS}" opt
34e49164 515
feec80c3 516clean distclean::
faf9a90c 517 rm -f gmon.out
34e49164
C
518
519tags:
520 otags -no-mli-tags -r .
521
522dependencygraph:
feec80c3 523 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 524 ocamldot -lr /tmp/dependfull.depend > /tmp/dependfull.dot
34e49164 525 dot -Tps /tmp/dependfull.dot > /tmp/dependfull.ps
485bce71 526 ps2pdf /tmp/dependfull.ps /tmp/dependfull.pdf
34e49164
C
527
528##############################################################################
529# Misc rules
530##############################################################################
531
faf9a90c 532# each member of the project can have its own test.ml. this file is
34e49164 533# not under CVS.
faf9a90c 534test.ml:
34e49164
C
535 echo "let foo_ctl () = failwith \"there is no foo_ctl formula\"" \
536 > test.ml
537
34e49164
C
538##############################################################################
539# Generic ocaml rules
540##############################################################################
541
542.SUFFIXES: .ml .mli .cmo .cmi .cmx
543
544.ml.cmo:
feec80c3 545 $(OCAMLC_CMD) -c $<
34e49164 546.mli.cmi:
feec80c3 547 $(OCAMLC_CMD) -c $<
34e49164 548.ml.cmx:
feec80c3 549 $(OCAMLOPT_CMD) -c $<
34e49164 550
faf9a90c 551.ml.mldepend:
feec80c3 552 $(OCAMLC_CMD) -i $<
34e49164 553
feec80c3
C
554clean distclean::
555 rm -f .depend
34e49164 556 rm -f *.cm[iox] *.o *.annot
34e49164
C
557 rm -f *~ .*~ *.exe #*#
558
feec80c3 559distclean::
d6ce1786 560 set -e; for i in $(CLEANSUBDIRS); do $(MAKE) -C $$i $@; done
feec80c3 561 rm -f test.ml
b1b2de81
C
562 rm -f TAGS
563 rm -f tests/SCORE_actual.sexp
564 rm -f tests/SCORE_best_of_both.sexp
17ba0788 565 find . -name ".#*1.*" | xargs rm -f
feec80c3 566 rm -f $(EXEC) $(EXEC).opt $(EXEC).top
b1b2de81 567
d6ce1786 568# using 'touch' to prevent infinite recursion with 'make depend'
feec80c3
C
569.PHONY:: depend
570.depend: Makefile.config test.ml version
d6ce1786
C
571 @touch .depend
572 @$(MAKE) depend
34e49164 573
feec80c3
C
574depend: Makefile.config test.ml version
575 @echo constructing '.depend'
d6ce1786
C
576 @rm -f .depend
577 @set -e; for i in $(MAKESUBDIRS); do $(MAKE) -C $$i depend; done
feec80c3 578 $(OCAMLDEP_CMD) *.mli *.ml > .depend
b1b2de81 579
feec80c3
C
580##############################################################################
581# configure-related
582##############################################################################
34e49164 583
feec80c3
C
584distclean::
585 @echo "cleaning configured files"
586 if test -z "${KEEP_CONFIG}"; then rm -f Makefile.config; fi
587 rm -rf autom4te.cache
588 rm -f config.status
589 rm -f config.log
590 rm -f version.ml
591 rm -f globals/config.ml
592 rm -f globals/regexp.ml python/pycocci.ml ocaml/prepare_ocamlcocci.ml
593 rm -f scripts/spatch.sh
d6ce1786 594 rm -f aclocal.m4
feec80c3
C
595 @echo "run 'configure' again prior to building coccinelle"
596
597
d6ce1786
C
598# don't include depend for those actions that either don't need
599# depend or that call 'make .depend' explicitly.
600# TODO: find a nicer way to express this
feec80c3
C
601ifneq ($(MAKECMDGOALS),clean)
602ifneq ($(MAKECMDGOALS),distclean)
603ifneq ($(MAKECMDGOALS),configure)
604ifneq ($(MAKECMDGOALS),prerelease)
605ifneq ($(MAKECMDGOALS),release)
606ifneq ($(MAKECMDGOALS),package)
d6ce1786
C
607ifneq ($(MAKECMDGOALS),all-release)
608ifneq ($(MAKECMDGOALS),all-dev)
609ifneq ($(MAKECMDGOALS),all)
610ifneq ($(MAKECMDGOALS),.depend)
611ifneq ($(MAKECMDGOALS),depend)
34e49164 612-include .depend
feec80c3
C
613endif
614endif
615endif
616endif
617endif
618endif
d6ce1786
C
619endif
620endif
621endif
622endif
623endif
624
625include Makefile.common