Skip to content

Commit 63f0a75

Browse files
rscharfegitster
authored andcommitted
add coccicheck make target
Provide a simple way to run Coccinelle against all source files, in the form of a Makefile target. Running "make coccicheck" applies each .cocci file in contrib/coccinelle/ on all source files. It generates a .patch file for each .cocci file, containing the actual changes for effecting the transformations described by the semantic patches. Non-empty .patch files are reported. They can be applied to the work tree using "patch -p0", but should be checked to e.g. make sure they don't screw up formatting or create circular references. Coccinelle's diagnostic output (stderr) is piped into .log files. Linux has a much more elaborate make target of the same name; let's start nice and easy. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 76d1567 commit 63f0a75

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ CURL_CONFIG = curl-config
456456
PTHREAD_LIBS = -lpthread
457457
PTHREAD_CFLAGS =
458458
GCOV = gcov
459+
SPATCH = spatch
459460

460461
export TCL_PATH TCLTK_PATH
461462

@@ -2296,6 +2297,18 @@ check: common-cmds.h
22962297
exit 1; \
22972298
fi
22982299

2300+
C_SOURCES = $(patsubst %.o,%.c,$(C_OBJ))
2301+
%.cocci.patch: %.cocci $(C_SOURCES)
2302+
@echo ' ' SPATCH $<; \
2303+
for f in $(C_SOURCES); do \
2304+
$(SPATCH) --sp-file $< $$f; \
2305+
done >$@ 2>$@.log; \
2306+
if test -s $@; \
2307+
then \
2308+
echo ' ' SPATCH result: $@; \
2309+
fi
2310+
coccicheck: $(patsubst %.cocci,%.cocci.patch,$(wildcard contrib/coccinelle/*.cocci))
2311+
22992312
### Installation rules
23002313

23012314
ifneq ($(filter /%,$(firstword $(template_dir))),)
@@ -2487,6 +2500,7 @@ clean: profile-clean coverage-clean
24872500
$(RM) -r $(GIT_TARNAME) .doc-tmp-dir
24882501
$(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
24892502
$(RM) $(htmldocs).tar.gz $(manpages).tar.gz
2503+
$(RM) contrib/coccinelle/*.cocci.patch*
24902504
$(MAKE) -C Documentation/ clean
24912505
ifndef NO_PERL
24922506
$(MAKE) -C gitweb clean

0 commit comments

Comments
 (0)