aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2026-05-12 15:52:45 +1000
committerStefano Brivio <sbrivio@redhat.com>2026-05-16 15:45:23 +0200
commit1cd627648f439b4964e428a2cedf680fac5ca54b (patch)
treeee8777008b0891b5ffa7a02006404871a5588b6f
parent4de7c3826d810e2e3f7f404dc8037ab445d6f2f0 (diff)
downloadpasst-1cd627648f439b4964e428a2cedf680fac5ca54b.tar
passt-1cd627648f439b4964e428a2cedf680fac5ca54b.tar.gz
passt-1cd627648f439b4964e428a2cedf680fac5ca54b.tar.bz2
passt-1cd627648f439b4964e428a2cedf680fac5ca54b.tar.lz
passt-1cd627648f439b4964e428a2cedf680fac5ca54b.tar.xz
passt-1cd627648f439b4964e428a2cedf680fac5ca54b.tar.zst
passt-1cd627648f439b4964e428a2cedf680fac5ca54b.zip
Makefile: Use make variables for static checker configuration
Our cppcheck and clang-tidy rules don't really follow normal Makefile conventions. Usually any commands other than the very basics have their binary specified in a variable so it can be overridden on the command line if they're in an unusual location. Implement that for $(CPPCHECK) and $(CLANG_TIDY) Likewise flags to tools usually have their own Make variable. Do the same with $(CLANG_TIDY_FLAGS) and $(CPPCHECK_FLAGS). Note that these only have the options specifically for the static checker, not compiler flags which we are also supplying to the static checker - those are derived from FLAGS / CFLAGS / CPPFLAGS as before. As part of that we change the probing for --check-level=exhaustive from being run as part of the cppcheck target, to being run when we build the CPPCHECK_FLAGS variable. That doesn't make any real difference now, but will make things nicer if we need multiple cppcheck targets in future (e.g. for passt-repair). Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--Makefile32
1 files changed, 19 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 5e91da1..48c5fb6 100644
--- a/Makefile
+++ b/Makefile
@@ -181,21 +181,27 @@ docs: README.md
done < README.md; \
) > README.plain.md
+CLANG_TIDY = clang-tidy
+CLANG_TIDY_FLAGS = -DCLANG_TIDY_58992
+
clang-tidy: $(PASST_SRCS)
- clang-tidy $^ -- $(filter-out -pie,$(FLAGS) $(CFLAGS) $(CPPFLAGS)) \
- -DCLANG_TIDY_58992
+ $(CLANG_TIDY) $^ -- $(filter-out -pie,$(FLAGS) $(CFLAGS) $(CPPFLAGS)) \
+ $(CLANG_TIDY_FLAGS)
-cppcheck: $(PASST_SRCS) $(HEADERS)
- if cppcheck --check-level=exhaustive /dev/null > /dev/null 2>&1; then \
- CPPCHECK_EXHAUSTIVE="--check-level=exhaustive"; \
- else \
- CPPCHECK_EXHAUSTIVE=; \
- fi; \
- cppcheck --std=c11 --error-exitcode=1 --enable=all --force \
+CPPCHECK = cppcheck
+CPPCHECK_FLAGS = --std=c11 --error-exitcode=1 --enable=all --force \
--inconclusive --library=posix --quiet \
- $${CPPCHECK_EXHAUSTIVE} \
--inline-suppr \
- --suppress=missingIncludeSystem \
+ $(shell if $(CPPCHECK) --quiet --check-level=exhaustive /dev/null; then \
+ echo "--check-level=exhaustive"; \
+ else \
+ echo ""; \
+ fi) \
+ --suppress=missingIncludeSystem \
--suppress=unusedStructMember \
- $(filter -D%,$(FLAGS) $(CFLAGS) $(CPPFLAGS)) -D CPPCHECK_6936 \
- $^
+ -D CPPCHECK_6936
+
+cppcheck: $(PASST_SRCS) $(HEADERS)
+ $(CPPCHECK) $(CPPCHECK_FLAGS) \
+ $(filter -D%,$(FLAGS) $(CFLAGS) $(CPPFLAGS)) $^ \
+ $^