1 # Copyright 2012, INRIA
2 # Julia Lawall, Gilles Muller
3 # Copyright 2010-2011, INRIA, University of Copenhagen
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.
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.
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.
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/>.
21 # The authors reserve the right to distribute this or future versions of
22 # Coccinelle under other licenses.
25 #############################################################################
26 # Configuration section
27 #############################################################################
31 # 'distclean' does not require configure to have run, and should also
32 # clean all the bundled directories. Hence, a special case.
33 ifeq ($(MAKECMDGOALS
),distclean)
34 MAKELIBS
:=$(dir $(wildcard .
/bundles
/*/Makefile
))
36 ifneq ($(MAKECMDGOALS
),configure
)
37 -include Makefile.config
41 -include /etc
/lsb-release
42 -include Makefile.
override # local customizations, if any
43 -include /etc
/Makefile.coccinelle
# local customizations, if any
46 VERSION
=$(shell cat .
/version | tr
-d
'\n')
47 CCVERSION
=$(shell cat scripts
/coccicheck
/README | egrep
-o
'[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+' | head
-n1
)
48 PKGVERSION
=$(shell dpkg-parsechangelog
-ldebian
/changelog.
$(DISTRIB_CODENAME
) 2> /dev
/null \
49 | sed
-n
's/^Version: \(.*\)/\1/p' )
51 ##############################################################################
53 ##############################################################################
57 SRC
=flag_cocci.ml cocci.ml testing.ml
test.ml
$(LEXER_SOURCES
:.mll
=.ml
) main.ml
59 ifeq ($(FEATURE_PYTHON
),1)
60 PYTHON_INSTALL_TARGET
=install-python
62 PYTHON_INSTALL_TARGET
=
65 SYSLIBS
=str.cma unix.cma bigarray.cma nums.cma
66 LIBS
=commons
/commons.cma \
69 parsing_cocci
/cocci_parser.cma parsing_c
/parsing_c.cma \
70 engine
/cocciengine.cma popl09
/popl.cma \
71 extra
/extra.cma python
/coccipython.cma ocaml
/cocciocaml.cma
73 MAKESUBDIRS
=$(MAKELIBS
) commons \
74 globals ctl parsing_cocci parsing_c \
75 engine popl09 extra python ocaml
77 CLEANSUBDIRS
=commons \
78 globals ctl parsing_cocci parsing_c \
79 engine popl09 extra python ocaml docs \
82 INCLUDEDIRSDEP
=commons commons
/ocamlextra \
84 parsing_cocci parsing_c engine popl09 extra python ocaml \
87 INCLUDEDIRS
=$(INCLUDEDIRSDEP
) $(PCREDIR
) $(INCLIBS
)
89 ##############################################################################
91 ##############################################################################
93 # sort to remove duplicates
94 INCLUDESET
=$(sort $(INCLUDEDIRS
))
95 INCLUDES
=$(INCLUDESET
:%=-I
%)
98 OPTOBJS
= $(SRC
:.ml
=.cmx
)
102 ##############################################################################
103 # Generic ocaml variables
104 ##############################################################################
106 OCAMLC_CMD
=$(OCAMLC
) $(OCAMLCFLAGS
) $(INCLUDES
)
107 OCAMLOPT_CMD
=$(OCAMLOPT
) $(OPTFLAGS
) $(INCLUDES
)
108 OCAMLYACC_CMD
=$(OCAMLYACC
) -v
109 OCAMLDEP_CMD
=$(OCAMLDEP
) $(INCLUDEDIRSDEP
:%=-I
%)
110 OCAMLMKTOP_CMD
=$(OCAMLMKTOP
) -g
-custom
$(INCLUDES
)
112 # these are unused at the moment (todo: remove)
113 EXTRA_CFLAGS
= # -static -pie -fpie -fPIE -static-libgcc
114 EXTRA_OCAML_CFLAGS
=$(EXTRA_CFLAGS
:%=-ccopt
%)
116 # 'make purebytecode' unsets this definition
117 BYTECODE_EXTRA
=-custom
$(EXTRA_OCAML_FLAGS
)
119 ##############################################################################
121 ##############################################################################
122 .PHONY
:: all all.opt byte opt top
clean distclean configure opt-compil
123 .PHONY
:: $(MAKESUBDIRS
:%=%.
all) $(MAKESUBDIRS
:%=%.opt
) subdirs.
all subdirs.opt
124 .PHONY
:: all-opt all-byte byte-only opt-only pure-byte
125 .PHONY
:: copy-stubs install-stubs
install install-man install-python install-common
128 # below follow the main make targets when ocamlbuild is not enabled
129 ifneq ($(FEATURE_OCAMLBUILD
),yes
)
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'.
137 # dispatches to either 'all-dev' or 'all-release'
140 $(MAKE
) $(TARGET_ALL
)
142 # make "all" comes in three flavours
143 world
: Makefile.config version.ml
144 @echo
"building both versions of spatch"
151 @echo
-e
"\tcoccinelle can now be installed via 'make install'"
153 # note: the 'all-dev' target excludes the documentation
154 all-dev
: Makefile.config version.ml
156 @echo
"building the unoptimized version of spatch"
160 @echo
-e
"\tcoccinelle can now be installed via 'make install'"
162 all-release
: Makefile.config version.ml
163 @echo building
$(TARGET_SPATCH
)
165 $(MAKE
) $(TARGET_SPATCH
)
169 @echo
-e
"\tcoccinelle can now be installed via 'make install'"
171 all.opt
: Makefile.config
176 byte
: Makefile.config version.ml
180 @echo the compilation of
$(EXEC
) finished
181 @echo
$(EXEC
) can be installed or used
183 opt-compil
: Makefile.config version.ml
185 $(MAKE
) subdirs.opt BUILD_OPT
=yes
186 $(MAKE
) $(EXEC
).opt BUILD_OPT
=yes
187 @echo the compilation of
$(EXEC
).opt finished
188 @echo
$(EXEC
).opt can be installed or used
192 # the .cmi file of coccilib
193 ocaml
/coccilib
/coccilib.cmi
: ocaml
/coccilib.cmi
194 cp ocaml
/coccilib.cmi ocaml
/coccilib
/coccilib.cmi
196 # ocamlbuild version of the main make targets
200 $(MAKE
) $(TARGET_ALL
)
202 world
: Makefile.config myocamlbuild.ml version.ml prepare-bundles
203 @echo
"building both versions of spatch"
206 @
$(MAKE
) coccilib-cmi
210 @echo
-e
"\tcoccinelle can now be installed via 'make install'"
212 # note: the 'all-dev' target excludes the documentation and is less noisy
213 all-dev
: Makefile.config myocamlbuild.ml version.ml prepare-bundles
215 @
$(MAKE
) coccilib-cmi
218 all-release
: Makefile.config myocamlbuild.ml version.ml prepare-bundles
219 @echo building
$(TARGET_SPATCH
)
220 $(MAKE
) $(TARGET_SPATCH
)
221 @
$(MAKE
) coccilib-cmi
225 @echo
-e
"\tcoccinelle can now be installed via 'make install'"
227 all.opt
: Makefile.config myocamlbuild.ml version.ml prepare-bundles
229 @
$(MAKE
) coccilib-cmi
232 byte
: Makefile.config myocamlbuild.ml version.ml prepare-bundles
233 $(OCAMLBUILD
) -j
0 main.byte
234 cp _build
/main.byte
$(EXEC
)
236 pure-byte
: Makefile.config myocamlbuild.ml version.ml prepare-bundles
237 $(OCAMLBUILD
) -j
0 -tag nocustom main.byte
238 cp _build
/main.byte
$(EXEC
)
240 opt-compil
: Makefile.config myocamlbuild.ml version.ml prepare-bundles
241 $(OCAMLBUILD
) -j
0 main.native
242 cp _build
/main.native
$(EXEC
).opt
244 # the .cmi file of coccilib
245 _build
/ocaml
/coccilib.cmi
:
246 $(OCAMLBUILD
) -j
0 ocaml
/coccilib.cmi
247 ocaml
/coccilib
/coccilib.cmi
: _build
/ocaml
/coccilib.cmi
248 cp _build
/ocaml
/coccilib.cmi ocaml
/coccilib
/coccilib.cmi
250 # end of main build target distinction on ocamlbuild
253 # aliases for "byte" and "opt-compil"
254 opt opt-only
: Makefile.config opt-compil
255 byte-only
: Makefile.config byte
258 # ensures that coccilib.cmi gets build
259 .PHONY
:: coccilib-cmi
260 coccilib-cmi
: ocaml
/coccilib
/coccilib.cmi
262 rm -f ocaml
/coccilib
/coccilib.cmi
266 @
+for D in
$(MAKESUBDIRS
); do
$(MAKE
) $$D.
all || exit
1 ; done
269 @
+for D in
$(MAKESUBDIRS
); do
$(MAKE
) $$D.opt || exit
1 ; done
271 $(MAKESUBDIRS
:%=%.
all):
272 @
$(MAKE
) -C
$(@
:%.
all=%) all
274 $(MAKESUBDIRS
:%=%.opt
):
275 @
$(MAKE
) -C
$(@
:%.opt
=%) all.opt
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
281 prepare-bundles
: $(MAKELIBS
:%=%/.prepare
)
283 $(MAKELIBS
:%=%/.prepare
):
285 @
$(MAKE
) -C
$(@
:%.prepare
=%) .prepare
291 # parsing_cocci: commons globals menhirLib
292 # parsing_c:parsing_cocci
293 # ctl:globals commonsg
294 # engine: parsing_cocci parsing_c ctl
296 # extra: parsing_cocci parsing_c ctl
298 # python:pycaml parsing_cocci parsing_c
300 clean:: Makefile.config
301 @set
-e
; for i in
$(CLEANSUBDIRS
); do
$(MAKE
) -C
$$i $@
; done
302 @
$(MAKE
) -C demos
/spp
$@
304 $(LIBS
): $(MAKESUBDIRS
:%=%.
all)
305 $(LIBS
:.cma
=.cmxa
): $(MAKESUBDIRS
:%=%.opt
)
306 $(LNKLIBS
) : $(MAKESUBDIRS
:%=%.
all)
307 $(LNKOPTLIBS
) : $(MAKESUBDIRS
:%=%.opt
)
310 $(OPTOBJS
):$(LIBS
:.cma
=.cmxa
)
312 $(EXEC
): $(LNKLIBS
) $(LIBS
) $(OBJS
)
313 $(OCAMLC_CMD
) $(BYTECODE_EXTRA
) $(FLAGSLIBS
) -o
$@
$(SYSLIBS
) $^
315 $(EXEC
).opt
: $(OPTLNKLIBS
) $(LIBS
:.cma
=.cmxa
) $(OPTOBJS
)
316 $(OCAMLOPT_CMD
) $(OPTFLAGSLIBS
) -o
$@
$(SYSLIBS
:.cma
=.cmxa
) $^
318 $(EXEC
).top
: $(LNKLIBS
) $(LIBS
) $(OBJS
)
319 $(OCAMLMKTOP_CMD
) -custom
-o
$@
$(SYSLIBS
) $(FLAGSLIBS
) $^
322 rm -f
$(TARGET
) $(TARGET
).opt
$(TARGET
).top
325 @if
test -n
"${OCAMLBUILD}" -d _build
; then \
326 $(OCAMLBUILD
) -clean; fi
328 # distclean can run without ocamlbuild configured.
330 -@if
test -d _build
; then \
331 ocamlbuild
-clean; fi
334 .PHONY
:: tools configure
337 .
/configure
$(CONFIGURE_FLAGS
)
339 # the dependencies on Makefile.config should give a hint to the programmer that
340 # configure should be run again
341 Makefile.config
: Makefile.config.in configure.ac
342 @echo
"Makefile.config needs to be (re)build. Run ./configure $(CONFIGURE_FLAGS) to generate it."
345 # as above, also for the ocamlbuild plugin
346 myocamlbuild.ml
: myocamlbuild.ml.in configure.ac
348 tools
: $(LIBS
) $(LNKLIBS
)
352 @if
[ -d tools
] ; then
$(MAKE
) -C tools
distclean ; fi
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.
358 rm -f spatch.opt spatch
359 $(MAKE
) $(STATIC
) opt-only
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'.
366 rm -f spatch.opt spatch
367 ifneq ($(FEATURE_OCAMLBUILD
),yes
)
368 $(MAKE
) BYTECODE_EXTRA
="" byte-only
372 sed
-i
'1 s,^#!.*$$,#!/usr/bin/ocamlrun,g' spatch
374 # copies the stubs libraries (if any) to the root directory
375 ifneq ($(FEATURE_OCAMLBUILD
),yes
)
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
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
389 ##############################################################################
390 # Build version information
391 ##############################################################################
394 @echo
"version.ml is missing. Run ./configure to generate it."
397 ##############################################################################
398 # Build documentation
399 ##############################################################################
402 ifneq ($(FEATURE_OCAMLBUILD
),yes
)
405 docs
: prepare-bundles
407 @
$(MAKE
) -C docs ||
(echo
"warning: ignored the failed construction of the manual" 1>&2)
408 ifneq ($(FEATURE_OCAMLBUILD
),yes
)
409 @if
test "x$(FEATURE_OCAML)" = x1
; then \
410 if
test -f .
/parsing_c
/ast_c.cmo
-o
-f .
/parsing_c
/ast_c.cmx
; then \
411 $(MAKE
) -C ocaml doc
; \
412 else echo
"note: to obtain coccilib documenation, it is required to build 'spatch' first so that ./parsing_c/ast_c.cm* gets build."; \
415 @if
test "x$(FEATURE_OCAML)" = x1
; then \
416 $(MAKE
) -C ocaml doc
; fi
418 @echo
"finished building manuals"
420 clean:: Makefile.config
421 $(MAKE
) -C docs
clean
422 $(MAKE
) -C ocaml cleandoc
424 ##############################################################################
425 # Pre-Install (customization of spatch frontend script)
426 ##############################################################################
428 preinstall
: docs
/spatch
.1 scripts
/spatch scripts
/spatch.opt scripts
/spatch.byte
430 docs
/spatch
.1: Makefile.config
431 $(MAKE
) -C docs spatch
.1
433 # user will use spatch to run spatch.opt (native)
434 scripts
/spatch
: Makefile.config scripts
/spatch.sh
435 cp scripts
/spatch.sh scripts
/spatch
436 chmod
+x scripts
/spatch
438 # user will use spatch to run spatch (bytecode)
439 scripts
/spatch.byte
: Makefile.config scripts
/spatch.sh
440 cp scripts
/spatch.sh scripts
/spatch.byte
441 chmod
+x scripts
/spatch.byte
443 # user will use spatch.opt to run spatch.opt (native)
444 scripts
/spatch.opt
: Makefile.config scripts
/spatch.sh
445 cp scripts
/spatch.sh scripts
/spatch.opt
446 chmod
+x scripts
/spatch.opt
449 rm -f scripts
/spatch scripts
/spatch.byte scripts
/spatch.opt
451 ##############################################################################
453 ##############################################################################
455 # don't remove DESTDIR, it can be set by package build system like ebuild
456 # for staged installation.
457 install-common
: ocaml
/coccilib
/coccilib.cmi
458 $(MKDIR_P
) $(DESTDIR
)$(BINDIR
)
459 $(MKDIR_P
) $(DESTDIR
)$(LIBDIR
)
460 $(MKDIR_P
) $(DESTDIR
)$(SHAREDIR
)/ocaml
461 # $(MKDIR_P) $(DESTDIR)$(SHAREDIR)/commons
462 # $(MKDIR_P) $(DESTDIR)$(SHAREDIR)/globals
463 # $(MKDIR_P) $(DESTDIR)$(SHAREDIR)/parsing_c
464 $(INSTALL_DATA
) standard.h
$(DESTDIR
)$(SHAREDIR
)
465 $(INSTALL_DATA
) standard.iso
$(DESTDIR
)$(SHAREDIR
)
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/
472 @echo
"Installing manuals in: ${DESTDIR}${MANDIR}"
473 $(MKDIR_P
) $(DESTDIR
)$(MANDIR
)/man1
474 $(MKDIR_P
) $(DESTDIR
)$(MANDIR
)/man3
475 $(INSTALL_DATA
) docs
/spatch
.1 $(DESTDIR
)$(MANDIR
)/man1
/
476 $(INSTALL_DATA
) docs
/Coccilib
.3cocci
$(DESTDIR
)$(MANDIR
)/man3
/
479 @echo
"Installing bash completion in: ${DESTDIR}${BASH_COMPLETION_DIR}"
480 $(MKDIR_P
) $(DESTDIR
)$(BASH_COMPLETION_DIR
)
481 $(INSTALL_DATA
) scripts
/spatch.bash_completion \
482 $(DESTDIR
)$(BASH_COMPLETION_DIR
)/spatch
485 @echo
"Installing tools in: ${DESTDIR}${BINDIR}"
486 $(MKDIR_P
) $(DESTDIR
)$(BINDIR
)
487 $(INSTALL_PROGRAM
) tools
/splitpatch \
488 $(DESTDIR
)$(BINDIR
)/splitpatch
489 $(INSTALL_PROGRAM
) tools
/cocci-send-email.perl \
490 $(DESTDIR
)$(BINDIR
)/cocci-send-email.perl
493 @echo
"Installing python support in: ${DESTDIR}${SHAREDIR}/python"
494 $(MKDIR_P
) $(DESTDIR
)$(SHAREDIR
)/python
/coccilib
/coccigui
495 $(INSTALL_DATA
) python
/coccilib
/*.py \
496 $(DESTDIR
)$(SHAREDIR
)/python
/coccilib
497 $(INSTALL_DATA
) python
/coccilib
/coccigui
/*.py \
498 $(DESTDIR
)$(SHAREDIR
)/python
/coccilib
/coccigui
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
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
511 install: install-man install-common install-stubs
$(PYTHON_INSTALL_TARGET
)
512 rm -f
$(DESTDIR
)$(SHAREDIR
)/spatch
513 rm -f
$(DESTDIR
)$(SHAREDIR
)/spatch.opt
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
520 @if
test ! -x spatch
-a
! -x spatch.opt
; then \
521 echo
-e
"\n\n\t==> Run 'make', 'make opt', or both first. <==\n\n";fi
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."
529 # Installation of spatch and spatch.opt and their wrappers
532 # user will use spatch to run one of the binaries
534 $(INSTALL_PROGRAM
) scripts
/spatch
$(DESTDIR
)$(BINDIR
)/spatch
536 # user will use spatch.byte to run spatch (bytecode)
538 $(INSTALL_PROGRAM
) spatch
$(DESTDIR
)$(SHAREDIR
)
539 $(INSTALL_PROGRAM
) scripts
/spatch.byte
$(DESTDIR
)$(BINDIR
)/spatch.byte
541 # user will use spatch.opt to run spatch.opt (native)
543 $(INSTALL_PROGRAM
) spatch.opt
$(DESTDIR
)$(SHAREDIR
)
544 $(INSTALL_PROGRAM
) scripts
/spatch.opt
$(DESTDIR
)$(BINDIR
)/spatch.opt
547 rm -f
$(DESTDIR
)$(BINDIR
)/spatch
548 rm -f
$(DESTDIR
)$(BINDIR
)/spatch.opt
549 rm -f
$(DESTDIR
)$(BINDIR
)/spatch.byte
550 rm -f
$(DESTDIR
)$(SHAREDIR
)/dllpycaml_stubs.so
551 rm -f
$(DESTDIR
)$(SHAREDIR
)/dllpcre_stubs.so
552 rm -f
$(DESTDIR
)$(SHAREDIR
)/spatch
553 rm -f
$(DESTDIR
)$(SHAREDIR
)/spatch.opt
554 rm -f
$(DESTDIR
)$(SHAREDIR
)/standard.h
555 rm -f
$(DESTDIR
)$(SHAREDIR
)/standard.iso
556 rm -f
$(DESTDIR
)$(SHAREDIR
)/ocaml
/coccilib.cmi
557 rm -f
$(DESTDIR
)$(SHAREDIR
)/parsing_c
/*.cmi
558 rm -f
$(DESTDIR
)$(SHAREDIR
)/commons
/*.cmi
559 rm -f
$(DESTDIR
)$(SHAREDIR
)/globals
/*.cmi
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
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
)
569 rm -f
$(DESTDIR
)$(MANDIR
)/man1
/spatch
.1
570 rm -f
$(DESTDIR
)$(MANDIR
)/man3
/Coccilib
.3cocci
573 rm -f
$(DESTDIR
)$(BASH_COMPLETION_DIR
)/spatch
574 rmdir
--ignore-fail-on-non-empty
-p \
575 $(DESTDIR
)$(BASH_COMPLETION_DIR
)
578 rm -f
$(DESTDIR
)$(BINDIR
)/splitpatch
579 rm -f
$(DESTDIR
)$(BINDIR
)/cocci-send-email.perl
582 @echo
"spatch $(VERSION)"
583 @echo
"spatch $(PKGVERSION) ($(DISTRIB_ID))"
584 @echo
"coccicheck $(CCVERSION)"
587 ##############################################################################
588 # Deb package (for Ubuntu) and release rules
589 ##############################################################################
591 include Makefile.release
593 ##############################################################################
595 ##############################################################################
597 -include Makefile.dev
603 .
/$(TARGET
) -D standard.h
-parse_c
-dir tests
/
605 # the check target runs:
606 # * some feature tests (depending on what is enabled)
608 check: 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
622 # -inline 0 to see all the functions in the profile.
623 # Can also use the profile framework in commons/ and run your program
626 $(MAKE
) OPTFLAGS
="-p -inline 0 ${EXTRA_OCAML_FLAGS}" opt
629 rm -f gmon.out ocamlprof.dump
632 otags
-no-mli-tags
-r .
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
636 ocamldot
-lr
/tmp
/dependfull.depend
> /tmp
/dependfull.dot
637 dot
-Tps
/tmp
/dependfull.dot
> /tmp
/dependfull.ps
638 ps2pdf
/tmp
/dependfull.ps
/tmp
/dependfull.pdf
640 ##############################################################################
642 ##############################################################################
644 # each member of the project can have its own test.ml. this file is
647 echo
"let foo_ctl () = failwith \"there is no foo_ctl formula\"" \
650 ##############################################################################
651 # Generic ocaml rules
652 ##############################################################################
654 .SUFFIXES
: .ml .mli .cmo .cmi .cmx
661 $(OCAMLOPT_CMD
) -c
$<
668 rm -f
*.cm
[iox
] *.o
*.annot
669 rm -f
*~ .
*~
*.exe
#*#
672 set
-e
; for i in
$(CLEANSUBDIRS
); do
$(MAKE
) -C
$$i $@
; done
674 rm -f TAGS
*.native
*.byte
*.d.native
*.p.byte
675 if
test -z
"${KEEP_GENERATED}"; then \
676 rm -f tests
/SCORE_actual.sexp tests
/SCORE_best_of_both.sexp
; fi
677 find .
-name
".#*1.*" | xargs
rm -f
678 rm -f
$(EXEC
) $(EXEC
).opt
$(EXEC
).top
681 # using 'touch' to prevent infinite recursion with 'make depend'
683 .depend
: Makefile.config
test.ml version
687 depend
: Makefile.config
test.ml version
688 @echo constructing
'.depend'
690 @set
-e
; for i in
$(MAKESUBDIRS
); do
$(MAKE
) -C
$$i depend
; done
691 $(OCAMLDEP_CMD
) *.mli
*.ml
> .depend
693 ##############################################################################
695 ##############################################################################
698 @echo
"cleaning configured files"
699 if
test -z
"${KEEP_CONFIG}"; then
rm -f Makefile.config
; fi
700 rm -rf autom4te.cache
703 if
test -z
"${KEEP_GENERATED}"; then \
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
709 @echo
"run 'configure' again prior to building coccinelle"
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
715 ifneq ($(MAKECMDGOALS
),clean)
716 ifneq ($(MAKECMDGOALS
),distclean)
717 ifneq ($(MAKECMDGOALS
),configure
)
718 ifneq ($(MAKECMDGOALS
),prerelease
)
719 ifneq ($(MAKECMDGOALS
),release
)
720 ifneq ($(MAKECMDGOALS
),package
)
721 ifneq ($(MAKECMDGOALS
),all-release
)
722 ifneq ($(MAKECMDGOALS
),all-dev
)
723 ifneq ($(MAKECMDGOALS
),all)
724 ifneq ($(MAKECMDGOALS
),.depend
)
725 ifneq ($(MAKECMDGOALS
),depend
)
726 ifneq ($(FEATURE_OCAMLBUILD
),yes
)
741 include Makefile.common