forked from coccinelle/coccinelle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
601 lines (494 loc) · 20.1 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
# This file is part of Coccinelle, lincensed under the terms of the GPL v2.
# See copyright.txt in the Coccinelle source code for more information.
# The Coccinelle source code can be obtained at http://coccinelle.lip6.fr
#############################################################################
# Configuration section
#############################################################################
include Makefile.libs
# 'distclean' does not require configure to have run, and should also
# clean all the bundled directories. Hence, a special case.
ifeq ($(MAKECMDGOALS),distclean)
MAKELIBS:=$(dir $(wildcard ./bundles/*/Makefile))
else
ifneq ($(MAKECMDGOALS),configure)
-include Makefile.config
-include Makefile.local
endif
endif
# We inherit the version information *after* the user has run
# ./configure but in the absence of that the build system has
# a few dependencies on the version information, we need a default
# setting then prior to the user running ./configure, this provides
# that, but will only be set if the user hasn't already run ./configure
#
# The only thing we can do is assume that the user relying on this
# variable then was going to make a release, this means we don't
# tell them that the tree is dirty.
VERSION?=$(shell MAKE_COCCI_RELEASE="y" ./version.sh)
CCVERSION=$(shell cat scripts/coccicheck/README | egrep -o '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+' | head -n1)
##############################################################################
# Variables
##############################################################################
TARGET=spatch
PRJNAME=coccinelle
ML_FILES=flag_cocci.ml cocci.ml testing.ml $(LEXER_SOURCES:.mll=.ml) \
read_options.ml main.ml
MLI_FILES=cocci.mli testing.mli
ifeq ($(FEATURE_PYTHON),1)
PYTHON_INSTALL_TARGET=install-python
else
PYTHON_INSTALL_TARGET=
endif
SYSLIBS=str.cma unix.cma bigarray.cma nums.cma
LIBS=commons/commons.cma \
globals/globals.cma \
ctl/ctl.cma \
parsing_cocci/cocci_parser.cma parsing_c/parsing_c.cma \
ocaml/cocciocaml.cma python/coccipython.cma \
engine/cocciengine.cma popl09/popl.cma \
extra/extra.cma
MAKESUBDIRS=commons \
globals ctl parsing_cocci parsing_c \
ocaml python engine popl09 extra tools/spgen
CLEANSUBDIRS=commons \
globals ctl parsing_cocci parsing_c \
ocaml python engine popl09 extra docs \
$(MAKELIBS) tools/spgen
INCLUDEDIRSDEP=commons commons/ocamlextra \
globals ctl \
parsing_cocci parsing_c ocaml python engine popl09 extra \
$(MAKELIBS)
INCLUDEDIRS=$(INCLUDEDIRSDEP) $(PCREDIR) $(PARMAPDIR) $(INCLIBS)
##############################################################################
# Generic variables
##############################################################################
# sort to remove duplicates
INCLUDESET=$(sort $(INCLUDEDIRS))
INCLUDES=$(INCLUDESET:%=-I %)
OBJS= $(ML_FILES:.ml=.cmo)
OPTOBJS= $(ML_FILES:.ml=.cmx)
EXEC=$(TARGET)
##############################################################################
# Generic ocaml variables
##############################################################################
OCAMLC_CMD=$(OCAMLC) $(OCAMLCFLAGS) $(INCLUDES)
OCAMLOPT_CMD=$(OCAMLOPT) $(OPTFLAGS) $(INCLUDES)
OCAMLYACC_CMD=$(OCAMLYACC) -v
OCAMLDEP_CMD=$(OCAMLDEP) $(INCLUDEDIRSDEP:%=-I %)
OCAMLMKTOP_CMD=$(OCAMLMKTOP) -g -custom $(INCLUDES)
# these are unused at the moment (todo: remove)
EXTRA_CFLAGS= # -static -pie -fpie -fPIE -static-libgcc
EXTRA_OCAML_CFLAGS=$(EXTRA_CFLAGS:%=-ccopt %)
# 'make purebytecode' unsets this definition
BYTECODE_EXTRA=-custom $(EXTRA_OCAML_FLAGS)
##############################################################################
# Top rules
##############################################################################
.PHONY:: all all.opt byte opt top clean distclean opt-compil
.PHONY:: $(MAKELIBS:%=%.all) $(MAKESUBDIRS:%=%.all) $(MAKELIBS:%=%.opt) $(MAKESUBDIRS:%=%.opt) subdirs.all subdirs.opt
.PHONY:: byte-only opt-only pure-byte tools
.PHONY:: copy-stubs install-stubs install install-man install-python install-common
# All make targets that are expected to be an entry point have a dependency on
# 'Makefile.config' to ensure that if Makefile.config is not present, an error
# message is printed first before any other actions are executed.
# In addition, the targets that actually build something have a dependency on
# '.depend' and 'version.ml'.
# dispatches to either 'all-dev' or 'all-release'
all: Makefile.config
@$(MAKE) .depend
$(MAKE) $(TARGET_ALL)
# make "all" comes in three flavours
world: Makefile.config version.ml
@$(ECHO) "Building both versions of spatch"
$(MAKE) .depend
$(MAKE) byte
$(MAKE) opt-compil
$(MAKE) preinstall
$(MAKE) docs
@$(ECHO) -e "\n\tcoccinelle can now be installed via 'make install'"
# note: the 'all-dev' target excludes the documentation
all-dev: Makefile.config version.ml
@$(MAKE) .depend
@$(ECHO) "Building $(TARGET_SPATCH)"
$(MAKE) $(TARGET_SPATCH)
@$(MAKE) preinstall
@$(ECHO) -e "\n\tcoccinelle can now be installed via 'make install'"
all-release: Makefile.config version.ml
@$(ECHO) "Building $(TARGET_SPATCH)"
$(MAKE) .depend
$(MAKE) $(TARGET_SPATCH)
$(MAKE) preinstall
# $(MAKE) docs
@$(ECHO) -e "\n\tcoccinelle can now be installed via 'make install'"
all.opt: Makefile.config
@$(MAKE) .depend
$(MAKE) opt-only
$(MAKE) preinstall
byte: Makefile.config version.ml
@$(MAKE) .depend
@$(MAKE) subdirs.all
@$(MAKE) $(EXEC)
@$(ECHO) "The compilation of $(EXEC) finished."
@$(ECHO) "$(EXEC) can be installed or used."
opt-compil: Makefile.config version.ml
$(MAKE) .depend
$(MAKE) subdirs.opt BUILD_OPT=yes
$(MAKE) $(EXEC).opt BUILD_OPT=yes
@$(ECHO) "The compilation of $(EXEC).opt finished."
@$(ECHO) "$(EXEC).opt can be installed or used."
top: $(EXEC).top
# the .cmi file of coccilib
# aliases for "byte" and "opt-compil"
opt opt-only: Makefile.config opt-compil
byte-only: Makefile.config byte
subdirs.all:
@+for D in $(MAKELIBS) $(MAKESUBDIRS); do $(MAKE) $$D.all || exit 1 ; done
subdirs.opt:
@+for D in $(MAKELIBS) $(MAKESUBDIRS); do $(MAKE) $$D.opt || exit 1 ; done
$(MAKELIBS:%=%.all) $(MAKESUBDIRS:%=%.all):
@$(MAKE) -C $(@:%.all=%) all
$(MAKELIBS:%=%.opt) $(MAKESUBDIRS:%=%.opt):
@$(MAKE) -C $(@:%.opt=%) all.opt
# This make target prepares the bundled software for building.
# Note that running 'make' in these subdirectories will
# automatically prepare the bundled software.
.PHONY:: prepare-bundles
prepare-bundles: $(MAKELIBS:%=%/.prepare)
$(MAKELIBS:%=%/.prepare):
$(ECHO) $@
@$(MAKE) -C $(@:%.prepare=%) .prepare
#dependencies:
# commons:
# globals:
# menhirLib:
# parsing_cocci: commons globals menhirLib
# parsing_c:parsing_cocci
# ctl:globals commonsg
# engine: parsing_cocci parsing_c ctl
# popl09:engine
# extra: parsing_cocci parsing_c ctl
# python:pyml parsing_cocci parsing_c
clean:: Makefile.config
@set -e; for i in $(CLEANSUBDIRS); do $(MAKE) -C $$i $@; done
@$(MAKE) -C demos/spp $@
$(LIBS): $(MAKELIBS:%=%.all) $(MAKESUBDIRS:%=%.all)
$(LIBS:.cma=.cmxa): $(MAKELIBS:%=%.opt) $(MAKESUBDIRS:%=%.opt)
$(LNKLIBS) : $(MAKELIBS:%=%.all) $(MAKESUBDIRS:%=%.all)
$(LNKOPTLIBS) : $(MAKELIBS:%=%.opt) $(MAKESUBDIRS:%=%.opt)
$(OBJS):$(LIBS)
$(OPTOBJS):$(LIBS:.cma=.cmxa)
$(EXEC): $(LNKLIBS) $(LIBS) $(OBJS)
$(OCAMLC_CMD) $(BYTECODE_EXTRA) $(FLAGSLIBS) -o $@ $(SYSLIBS) $^
$(EXEC).opt: $(OPTLNKLIBS) $(LIBS:.cma=.cmxa) $(OPTOBJS)
$(OCAMLOPT_CMD) $(OPTFLAGSLIBS) -o $@ $(SYSLIBS:.cma=.cmxa) $^
$(EXEC).top: $(LNKLIBS) $(LIBS) $(OBJS)
$(OCAMLMKTOP_CMD) -custom -o $@ $(SYSLIBS) $(FLAGSLIBS) $^
clean distclean::
rm -f $(TARGET) $(TARGET).opt $(TARGET).top
./configure: ./configure.ac
@echo Please run ./autogen to update configure
@false
# the dependencies on Makefile.config should give a hint to the programmer that
# configure should be run again
Makefile.config: Makefile.config.in configure.ac
@$(ECHO) "Makefile.config needs to be (re)build. Run ./autogen and ./configure $(CONFIGURE_FLAGS) to generate it."
@false
tools: $(LIBS) $(LNKLIBS)
$(MAKE) -C tools
distclean::
@if [ -d tools ] ; then $(MAKE) -C tools distclean ; fi
# it seems impossible to pass "-static" unless all dependent
# libraries are also available as static archives.
# set $(STATIC) to -static if you have such libraries.
static:
rm -f spatch.opt spatch
$(MAKE) $(STATIC) opt-only
cp spatch.opt spatch
# creates a portable version of spatch, which, however, may
# be dependent on non-portably dynamic libraries. You
# may need the stubs, see 'copy-stubs'.
purebytecode:
rm -f spatch.opt spatch
$(MAKE) BYTECODE_EXTRA="" byte-only
LC_CTYPE=C sed -i -e '1 s,^#!.*$$,#!/usr/bin/ocamlrun,g' spatch
# copies the stubs libraries (if any) to the root directory
copy-stubs:
@if test -f ./bundles/pyml/dllpyml_stubs.so; then \
cp -fv ./bundles/pyml/dllpyml_stubs.so .; fi
@if test -f ./bundles/pcre/dllpcre_stubs.so; then \
cp -fv ./bundles/pcre/dllpcre_stubs.so .; fi
##############################################################################
# Build version information
##############################################################################
version.ml:
@$(ECHO) "version.ml is missing. Run ./configure to generate it. Run ./autogen first if ./configure does not exist."
@false
##############################################################################
# Build documentation
##############################################################################
.PHONY:: docs
docs:
@$(MAKE) -C docs || ($(ECHO) "Warning: ignored the failed construction of the manual" 1>&2)
@$(MAKE) docs -C tools/spgen/documentation
@if test "x$(FEATURE_OCAML)" = x1; then \
if test -f ./parsing_c/ast_c.cmo -o -f ./parsing_c/ast_c.cmx; then \
$(MAKE) -C ocaml doc; \
else $(ECHO) "Note: to obtain coccilib documenation, it is required to build 'spatch' first so that ./parsing_c/ast_c.cm* gets build."; \
fi fi
@$(ECHO) "Finished building manuals"
clean:: Makefile.config
# $(MAKE) -C docs clean
$(MAKE) -C ocaml cleandoc
$(MAKE) clean -C tools/spgen/documentation
##############################################################################
# Pre-Install (customization of spatch frontend script)
##############################################################################
preinstall: docs/spatch.1 scripts/spatch scripts/spatch.opt scripts/spatch.byte
docs/spatch.1: Makefile.config
$(MAKE) -C docs spatch.1
# user will use spatch to run spatch.opt (native)
scripts/spatch: Makefile.config scripts/spatch.sh
cp scripts/spatch.sh scripts/spatch
chmod +x scripts/spatch
# user will use spatch to run spatch (bytecode)
scripts/spatch.byte: Makefile.config scripts/spatch.sh
cp scripts/spatch.sh scripts/spatch.byte
chmod +x scripts/spatch.byte
# user will use spatch.opt to run spatch.opt (native)
scripts/spatch.opt: Makefile.config scripts/spatch.sh
cp scripts/spatch.sh scripts/spatch.opt
chmod +x scripts/spatch.opt
distclean::
rm -f scripts/spatch scripts/spatch.byte scripts/spatch.opt
##############################################################################
# Install
##############################################################################
# don't remove DESTDIR, it can be set by package build system like ebuild
# for staged installation.
install-common: ocaml/coccilib.cmi
$(MKDIR_P) $(DESTDIR)$(BINDIR)
$(MKDIR_P) $(DESTDIR)$(LIBDIR)
$(MKDIR_P) $(DESTDIR)$(LIBDIR)/ocaml
$(INSTALL_DATA) standard.h $(DESTDIR)$(LIBDIR)
$(INSTALL_DATA) standard.iso $(DESTDIR)$(LIBDIR)
$(INSTALL_DATA) ocaml/*.cmi $(DESTDIR)$(LIBDIR)/ocaml/
install-man:
@$(ECHO) "Installing manuals in: ${DESTDIR}${MANDIR}"
$(MKDIR_P) $(DESTDIR)$(MANDIR)/man1
$(MKDIR_P) $(DESTDIR)$(MANDIR)/man3
$(INSTALL_DATA) docs/spatch.1 $(DESTDIR)$(MANDIR)/man1/
$(INSTALL_DATA) docs/pycocci.1 $(DESTDIR)$(MANDIR)/man1/
$(INSTALL_DATA) docs/spgen.1 $(DESTDIR)$(MANDIR)/man1/
$(INSTALL_DATA) docs/Coccilib.3cocci $(DESTDIR)$(MANDIR)/man3/
install-bash:
@$(ECHO) "Installing bash completion in: ${DESTDIR}${BASH_COMPLETION_DIR}"
$(MKDIR_P) $(DESTDIR)$(BASH_COMPLETION_DIR)
$(INSTALL_DATA) scripts/spatch.bash_completion \
$(DESTDIR)$(BASH_COMPLETION_DIR)/spatch
install-tools:
@$(ECHO) "Installing tools in: ${DESTDIR}${BINDIR}"
$(MKDIR_P) $(DESTDIR)$(BINDIR)
$(INSTALL_PROGRAM) tools/splitpatch \
$(DESTDIR)$(BINDIR)/splitpatch
$(INSTALL_PROGRAM) tools/cocci-send-email.perl \
$(DESTDIR)$(BINDIR)/cocci-send-email.perl
install-python:
@$(ECHO) "Installing python support in: ${DESTDIR}${LIBDIR}/python"
$(MKDIR_P) $(DESTDIR)$(LIBDIR)/python/coccilib/coccigui
$(INSTALL_DATA) python/coccilib/*.py \
$(DESTDIR)$(LIBDIR)/python/coccilib
$(INSTALL_DATA) python/coccilib/coccigui/*.py \
$(DESTDIR)$(LIBDIR)/python/coccilib/coccigui
$(INSTALL_DATA) python/coccilib/coccigui/pygui.glade \
$(DESTDIR)$(LIBDIR)/python/coccilib/coccigui
$(INSTALL_DATA) python/coccilib/coccigui/pygui.gladep \
$(DESTDIR)$(LIBDIR)/python/coccilib/coccigui
install-stubs:
$(MKDIR_P) $(DESTDIR)$(LIBDIR)
@if test -f ./bundles/pyml/dllpyml_stubs.so; then \
cp -fv ./bundles/pyml/dllpyml_stubs.so $(DESTDIR)$(LIBDIR); fi
@if test -f ./bundles/pcre/dllpcre_stubs.so; then \
cp -fv ./bundles/pcre/dllpcre_stubs.so $(DESTDIR)$(LIBDIR); fi
install: install-common install-man install-stubs $(PYTHON_INSTALL_TARGET)
rm -f $(DESTDIR)$(LIBDIR)/spatch
rm -f $(DESTDIR)$(LIBDIR)/spatch.opt
rm -f $(DESTDIR)$(BINDIR)/pycocci
@$(MAKE) install -C tools/spgen
$(INSTALL_PROGRAM) tools/pycocci $(DESTDIR)$(BINDIR)
@if test -x spatch -o -x spatch.opt; then \
$(MAKE) install-def;fi
@if test -x spatch ; then \
$(MAKE) install-byte; fi
@if test -x spatch.opt ; then \
$(MAKE) install-opt;fi
@if test ! -x spatch -a ! -x spatch.opt ; then \
$(ECHO) -e "\n\n\t==> Run 'make', 'make opt', or both first. <==\n\n";fi
@$(ECHO) -e "\n\tYou can also install spatch by copying the program spatch"
@$(ECHO) -e "\t(available in this directory) anywhere you want and"
@$(ECHO) -e "\tgive it the right options to find its configuration files.\n"
#
# Installation of spatch and spatch.opt and their wrappers
#
# user will use spatch to run one of the binaries
install-def:
$(INSTALL_PROGRAM) scripts/spatch $(DESTDIR)$(BINDIR)/spatch
# user will use spatch.byte to run spatch (bytecode)
install-byte:
$(INSTALL_PROGRAM) spatch $(DESTDIR)$(LIBDIR)
$(INSTALL_PROGRAM) scripts/spatch.byte $(DESTDIR)$(BINDIR)/spatch.byte
# user will use spatch.opt to run spatch.opt (native)
install-opt:
$(INSTALL_PROGRAM) spatch.opt $(DESTDIR)$(LIBDIR)
$(INSTALL_PROGRAM) scripts/spatch.opt $(DESTDIR)$(BINDIR)/spatch.opt
uninstall:
rm -f $(DESTDIR)$(BINDIR)/spatch
rm -f $(DESTDIR)$(BINDIR)/spatch.opt
rm -f $(DESTDIR)$(BINDIR)/spatch.byte
rm -f $(DESTDIR)$(LIBDIR)/dllpyml_stubs.so
rm -f $(DESTDIR)$(LIBDIR)/dllpcre_stubs.so
rm -f $(DESTDIR)$(LIBDIR)/spatch
rm -f $(DESTDIR)$(LIBDIR)/spatch.opt
rm -f $(DESTDIR)$(LIBDIR)/standard.h
rm -f $(DESTDIR)$(LIBDIR)/standard.iso
rm -f $(DESTDIR)$(LIBDIR)/ocaml/*.cmi
rm -f $(DESTDIR)$(LIBDIR)/python/coccilib/coccigui/*
rm -f $(DESTDIR)$(LIBDIR)/python/coccilib/*.py
@$(MAKE) uninstall -C tools/spgen/source
rmdir --ignore-fail-on-non-empty -p \
$(DESTDIR)$(LIBDIR)/python/coccilib/coccigui
rmdir --ignore-fail-on-non-empty $(DESTDIR)$(LIBDIR)/ocaml
rmdir $(DESTDIR)$(LIBDIR)
rm -f $(DESTDIR)$(MANDIR)/man1/spatch.1
rm -f $(DESTDIR)$(MANDIR)/man3/Coccilib.3cocci
rm -f $(DESTDIR)$(MANDIR)/man1/spgen.1
uninstall-bash:
rm -f $(DESTDIR)$(BASH_COMPLETION_DIR)/spatch
rmdir --ignore-fail-on-non-empty -p \
$(DESTDIR)$(BASH_COMPLETION_DIR)
uninstall-tools:
rm -f $(DESTDIR)$(BINDIR)/splitpatch
rm -f $(DESTDIR)$(BINDIR)/cocci-send-email.perl
version:
@$(ECHO) "spatch $(VERSION)"
@$(ECHO) "coccicheck $(CCVERSION)"
##############################################################################
# Deb package (for Ubuntu) and release rules
##############################################################################
include Makefile.release
##############################################################################
# Developer rules
##############################################################################
-include Makefile.dev
test: $(TARGET)
./$(TARGET) -testall
testparsing:
./$(TARGET) -D standard.h -parse_c -dir tests/
# the check target runs:
# * some feature tests (depending on what is enabled)
# * the test suite
check: scripts/spatch
@$(ECHO) "Testing if spatch works on hello world..."
@COCCINELLE_HOME="$$(pwd)" ./scripts/spatch --sp-file demos/hello/hello-smpl.cocci demos/hello/helloworld.c --very-quiet | grep -q '+ printf("world, hello!");'
@$(ECHO) "Testing if spatch works with regexes..."
@COCCINELLE_HOME="$$(pwd)" ./scripts/spatch --sp-file demos/hello/hello-regexp.cocci demos/hello/helloworld.c --very-quiet | grep -q '+ printf("world, hello!");'
@if test "x${FEATURE_OCAML}" = x1 -a -z "${NO_OCAMLFIND}"; then \
$(ECHO) "Testing if spatch works with ocaml scripts..."; \
COCCINELLE_HOME="$$(pwd)" ./scripts/spatch --sp-file demos/hello/hello-ocaml.cocci demos/hello/helloworld.c --very-quiet | grep -q 'Hello at: 2'; fi
@if test "x${FEATURE_PYTHON}" = x1; then \
$(ECHO) "Testing if spatch works with python scripts..."; \
COCCINELLE_HOME="$$(pwd)" ./scripts/spatch --sp-file demos/hello/hello-python.cocci demos/hello/helloworld.c --very-quiet | grep -q 'Hello at: 2'; fi
@$(ECHO) running the test suite
COCCINELLE_HOME="$$(pwd)" ./scripts/spatch --testall --no-update-score-file
pycocci-check:
COCCINELLE_HOME="$$(pwd)" ./scripts/pycocci-check.sh
# -inline 0 to see all the functions in the profile.
# Can also use the profile framework in commons/ and run your program
# with -profile.
forprofiling:
$(MAKE) OPTFLAGS="-p -inline 0 ${EXTRA_OCAML_FLAGS}" opt
clean distclean::
rm -f gmon.out ocamlprof.dump
tags:
otags -no-mli-tags -r .
##############################################################################
# Misc rules
##############################################################################
##############################################################################
# Generic ocaml rules
##############################################################################
.SUFFIXES: .ml .mli .cmo .cmi .cmx
.ml.cmo:
$(OCAMLC_CMD) -c $<
.mli.cmi:
$(OCAMLC_CMD) -c $<
.ml.cmx:
$(OCAMLOPT_CMD) -c $<
.ml.mldepend:
$(OCAMLC_CMD) -i $<
clean distclean::
rm -f .depend
rm -f *.cm[iox] *.o *.annot
rm -f *~ .*~ *.exe #*#
distclean::
set -e; for i in $(CLEANSUBDIRS); do $(MAKE) -C $$i $@; done
rm -f TAGS *.native *.byte *.d.native *.p.byte
if test -z "${KEEP_GENERATED}"; then \
rm -f tests/SCORE_actual.sexp tests/SCORE_best_of_both.sexp; fi
find . -name ".#*1.*" | xargs rm -f
rm -f $(EXEC) $(EXEC).opt $(EXEC).top
rm -f setup/Makefile
# using 'touch' to prevent infinite recursion with 'make depend'
.PHONY:: depend
.depend: Makefile.config version
@touch .depend
@$(MAKE) depend
depend: Makefile.config version
@$(ECHO) "Constructing '.depend'"
@rm -f .depend
set -e; for i in $(MAKELIBS) $(MAKESUBDIRS); do echo $$i; $(MAKE) -C $$i depend; done
$(OCAMLDEP_CMD) $(MLI_FILES) $(ML_FILES) > .depend
##############################################################################
# configure-related
##############################################################################
distclean::
@echo "Cleaning configured files"
if test -z "${KEEP_CONFIG}"; then rm -f Makefile.config; fi
rm -rf autom4te.cache
rm -f config.status
rm -f config.log
if test -z "${KEEP_GENERATED}"; then \
rm -f version.ml; fi
rm -f globals/config.ml
rm -f globals/regexp.ml python/pycocci.ml ocaml/prepare_ocamlcocci.ml
rm -f scripts/spatch.sh
rm -f aclocal.m4
for i in `find . -name '*.in'`; do rm -f `echo $$i | sed "s/\.in$$//"`; done
@echo "Run './configure' again prior to building coccinelle."
@echo "If ./configure does not exist, run ./autogen first."
# don't include depend for those actions that either don't need
# depend or that call 'make .depend' explicitly.
# TODO: find a nicer way to express this
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),distclean)
ifneq ($(MAKECMDGOALS),configure)
ifneq ($(MAKECMDGOALS),prerelease)
ifneq ($(MAKECMDGOALS),release)
ifneq ($(MAKECMDGOALS),package)
ifneq ($(MAKECMDGOALS),all-release)
ifneq ($(MAKECMDGOALS),all-dev)
ifneq ($(MAKECMDGOALS),all)
ifneq ($(MAKECMDGOALS),.depend)
ifneq ($(MAKECMDGOALS),depend)
-include .depend
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
include Makefile.common