aboutsummaryrefslogtreecommitdiff
path: root/Makefile.local
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2017-08-29 08:35:26 -0300
committerDavid Bremner <david@tethera.net>2017-08-29 22:05:37 -0300
commitaf64530d3f93dd1c379ad3ba93608ca5ad700598 (patch)
treea6906b07fcae4f09795d0552e64fe93a3163de52 /Makefile.local
parent8c7d979f5da30bfe19846527bac2f40c2cdc515a (diff)
build: add target to run cppcheck
The advantage of having a target as opposed to running cppcheck by hand - reuse list of source files - output errors in a format parsable, e.g. by emacs - returns exit code 1 on any error, for possibly use in other targets. For the moment, leave this as an optional target. If desired, it can be added to e.g. the release targets in the same way as the test target. Using two levels of directory for the stamps is arguably overengineering, but it doesn't really cost anything, and leaves open the possibility of putting other kinds of stamp files there. This only checks "new" source files (w.r.t. their last check). A future target (cppcheck-all ?) could blow away the stamp files first.
Diffstat (limited to 'Makefile.local')
-rw-r--r--Makefile.local18
1 files changed, 18 insertions, 0 deletions
diff --git a/Makefile.local b/Makefile.local
index 9e2111f5..9d9c52c2 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -199,6 +199,14 @@ quiet ?= $($(word 1, $(1)))
@mkdir -p $(patsubst %/.,%,.deps/$(@D))
$(call quiet,CC $(CPPFLAGS) $(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@ -MD -MP -MF .deps/$*.d
+CPPCHECK=cppcheck
+.stamps/cppcheck/%: %
+ @mkdir -p $(@D)
+ $(call quiet,CPPCHECK,$<) --template=gcc --error-exitcode=1 --quiet $<
+ @touch $@
+
+CLEAN := $(CLEAN) .stamps
+
.PHONY : clean
clean:
rm -rf $(CLEAN)
@@ -284,6 +292,16 @@ CLEAN := $(CLEAN) .deps
DISTCLEAN := $(DISTCLEAN) .first-build-message Makefile.config sh.config
+CPPCHECK_STAMPS := $(SRCS:%=.stamps/cppcheck/%)
+.PHONY: cppcheck
+ifeq ($(HAVE_CPPCHECK),1)
+cppcheck: ${CPPCHECK_STAMPS}
+else
+cppcheck:
+ @echo "No cppcheck found during configure; skipping static checking"
+endif
+
+
DEPS := $(SRCS:%.c=.deps/%.d)
DEPS := $(DEPS:%.cc=.deps/%.d)
-include $(DEPS)