Makefile: check for cppcheck's --check-level option in cppcheck target
Don't run cppcheck to find out if the --check-level=exhaustive option
is available, unless we're actually going to run cppcheck later.
To avoid this, move this check under the cppcheck target, and
implement it in shell script instead of using Makefile directives,
because we can't easily implement conditionals in recipes.
Reported-by: Rahil Bhimjiani <me@rahil.website>
Link: https://bugs.gentoo.org/920795
Fixes: 8640d62af7
("cppcheck: Use "exhaustive" level checking when available")
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
15001b39ef
commit
925af4ef82
1 changed files with 6 additions and 6 deletions
12
Makefile
12
Makefile
|
@ -287,20 +287,20 @@ clang-tidy: $(SRCS) $(HEADERS)
|
||||||
-config='{CheckOptions: [{key: bugprone-suspicious-string-compare.WarnOnImplicitComparison, value: "false"}]}' \
|
-config='{CheckOptions: [{key: bugprone-suspicious-string-compare.WarnOnImplicitComparison, value: "false"}]}' \
|
||||||
--warnings-as-errors=* $(SRCS) -- $(filter-out -pie,$(FLAGS) $(CFLAGS) $(CPPFLAGS)) -DCLANG_TIDY_58992
|
--warnings-as-errors=* $(SRCS) -- $(filter-out -pie,$(FLAGS) $(CFLAGS) $(CPPFLAGS)) -DCLANG_TIDY_58992
|
||||||
|
|
||||||
CPPCHECK_EXHAUSTIVE :=
|
|
||||||
ifeq ($(shell cppcheck --check-level=exhaustive /dev/null > /dev/null 2>&1; echo $$?),0)
|
|
||||||
CPPCHECK_EXHAUSTIVE += --check-level=exhaustive
|
|
||||||
endif
|
|
||||||
|
|
||||||
SYSTEM_INCLUDES := /usr/include $(wildcard /usr/include/$(TARGET))
|
SYSTEM_INCLUDES := /usr/include $(wildcard /usr/include/$(TARGET))
|
||||||
ifeq ($(shell $(CC) -v 2>&1 | grep -c "gcc version"),1)
|
ifeq ($(shell $(CC) -v 2>&1 | grep -c "gcc version"),1)
|
||||||
VER := $(shell $(CC) -dumpversion)
|
VER := $(shell $(CC) -dumpversion)
|
||||||
SYSTEM_INCLUDES += /usr/lib/gcc/$(TARGET)/$(VER)/include
|
SYSTEM_INCLUDES += /usr/lib/gcc/$(TARGET)/$(VER)/include
|
||||||
endif
|
endif
|
||||||
cppcheck: $(SRCS) $(HEADERS)
|
cppcheck: $(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 --std=c11 --error-exitcode=1 --enable=all --force \
|
||||||
--inconclusive --library=posix --quiet \
|
--inconclusive --library=posix --quiet \
|
||||||
$(CPPCHECK_EXHAUSTIVE) \
|
$${CPPCHECK_EXHAUSTIVE} \
|
||||||
$(SYSTEM_INCLUDES:%=-I%) \
|
$(SYSTEM_INCLUDES:%=-I%) \
|
||||||
$(SYSTEM_INCLUDES:%=--config-exclude=%) \
|
$(SYSTEM_INCLUDES:%=--config-exclude=%) \
|
||||||
$(SYSTEM_INCLUDES:%=--suppress=*:%/*) \
|
$(SYSTEM_INCLUDES:%=--suppress=*:%/*) \
|
||||||
|
|
Loading…
Reference in a new issue