Makefile: add coccicheck target
Coccinelle is a program for static code analysis.
For details on Coccinelle see
http://coccinelle.lip6.fr/
Add scripts/coccicheck copied from Linux kernel v4.14.
The coccicheck script executes the tests *.cocci in
directory scripts/coccinelle by calling spatch.
In Makefile add a coccicheck target. You can use it with
make coccicheck MODE=<mode>
where mode in patch, report, context, org.
Add a copy of Linux v4.14 file Documentation/dev-tools/coccinelle.rst
as doc/README.coccinelle.
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
diff --git a/Makefile b/Makefile
index b5f81e3..fea1954 100644
--- a/Makefile
+++ b/Makefile
@@ -1572,6 +1572,7 @@
@echo ''
@echo 'Static analysers'
@echo ' checkstack - Generate a list of stack hogs'
+ @echo ' coccicheck - Execute static code analysis with Coccinelle'
@echo ''
@echo 'Documentation targets:'
@$(MAKE) -f $(srctree)/doc/DocBook/Makefile dochelp
@@ -1664,6 +1665,14 @@
$(build)=$(build-dir) $(@:.ko=.o)
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
+# Consistency checks
+# ---------------------------------------------------------------------------
+
+PHONY += coccicheck
+
+coccicheck:
+ $(Q)$(CONFIG_SHELL) $(srctree)/scripts/$@
+
# FIXME Should go into a make.lib or something
# ===========================================================================