{"thread":{"id":"44093","subject":"[PATCH] add coccicheck make target","startedAt":"2016-09-15T18:31:38Z","lastAt":"2016-09-15T18:31:38Z","messageCount":1,"participants":["René Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"301993","messageId":"e47359bc-1bf0-e1bd-b076-6f95c3f15abd@web.de","threadId":"44093","inReplyTo":null,"subject":"[PATCH] add coccicheck make target","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2016-09-15T18:30:56Z","receivedAt":"2016-09-15T18:31:38Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Provide a simple way to run Coccinelle against all source files, in the\nform of a Makefile target.  Running \"make coccicheck\" applies each\n.cocci file in contrib/coccinelle/ on all source files.  It generates\na .patch file for each .cocci file, containing the actual changes for\neffecting the transformations described by the semantic patches.\n\nNon-empty .patch files are reported.  They can be applied to the work\ntree using \"patch -p0\", but should be checked to e.g. make sure they\ndon't screw up formatting or create circular references.\n\nCoccinelle's diagnostic output (stderr) is piped into .log files.\n\nLinux has a much more elaborate make target of the same name; let's\nstart nice and easy.\n\nSigned-off-by: Rene Scharfe <l.s.r@web.de>\n---\n Makefile | 14 ++++++++++++++\n 1 file changed, 14 insertions(+)\n\ndiff --git a/Makefile b/Makefile\nindex 7f18492..74b2788 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -461,6 +461,7 @@ CURL_CONFIG = curl-config\n PTHREAD_LIBS = -lpthread\n PTHREAD_CFLAGS =\n GCOV = gcov\n+SPATCH = spatch\n \n export TCL_PATH TCLTK_PATH\n \n@@ -2307,6 +2308,18 @@ check: common-cmds.h\n \t\texit 1; \\\n \tfi\n \n+C_SOURCES = $(patsubst %.o,%.c,$(C_OBJ))\n+%.cocci.patch: %.cocci $(C_SOURCES)\n+\t@echo '    ' SPATCH $<; \\\n+\tfor f in $(C_SOURCES); do \\\n+\t\t$(SPATCH) --sp-file $< $$f; \\\n+\tdone >$@ 2>$@.log; \\\n+\tif test -s $@; \\\n+\tthen \\\n+\t\techo '    ' SPATCH result: $@; \\\n+\tfi\n+coccicheck: $(patsubst %.cocci,%.cocci.patch,$(wildcard contrib/coccinelle/*.cocci))\n+\n ### Installation rules\n \n ifneq ($(filter /%,$(firstword $(template_dir))),)\n@@ -2498,6 +2511,7 @@ clean: profile-clean coverage-clean\n \t$(RM) -r $(GIT_TARNAME) .doc-tmp-dir\n \t$(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz\n \t$(RM) $(htmldocs).tar.gz $(manpages).tar.gz\n+\t$(RM) contrib/coccinelle/*.cocci.patch*\n \t$(MAKE) -C Documentation/ clean\n ifndef NO_PERL\n \t$(MAKE) -C gitweb clean\n-- \n2.10.0\n\n"}]}