Add targets check1 (cppcheck) and check2 (clang-tidy)

This commit is contained in:
benn 2025-05-22 17:21:45 +02:00
parent 1f4311529e
commit 7532011245

View file

@ -56,21 +56,30 @@ endif
# OS dependent flags
#
OS := $(shell uname -s)
ifeq ($(OS),Linux)
# installed by system and in PATH
CPPCHECK := cppcheck
CHECKFLAGS := --platform=unix64
DBG_REL +=
ifeq ($(MAKECMDGOALS),check1)
ifeq ($(OS),Linux)
# installed by system and in PATH
CPPCHECK := cppcheck
CHECKFLAGS :=
endif
ifeq ($(OS),SunOS)
# local installation
CPPCHECK := $(HOME)/devl/cppcheck/bin/cppcheck
endif
# Uncomment one of the following to select an output format
#CHECKFLAGS = --template="{file},{line},{severity},{id},{message}"
#CHECKFLAGS = --platform=unix64 --quiet --enable=all --error-exitcode=1 --check-level=exhaustive -I./include
CHECKFLAGS = --enable=all --error-exitcode=1 --suppress=missingIncludeSystem
endif
# OpenIndiana and flavours
ifeq ($(OS),SunOS)
# local installation
CPPCHECK := $(HOME)/devl/cppcheck/bin/cppcheck
CHECKFLAGS := --platform=unix64
DBG_REL +=
ifeq ($(MAKECMDGOALS),check2)
CPPCHECK := clang-tidy
CHECKFLAGS := --checks=*
endif
SRC_DIR := src
OBJ_DIR := obj
SRC := $(wildcard $(SRC_DIR)/*.cpp)
@ -134,13 +143,11 @@ APP_LIBS=
LIBS = $(NETBEANSBUILD) $(APP_LIBS)
# Uncomment one of the following to select an output format
#CHECKFLAGS = --template="{file},{line},{severity},{id},{message}"
CHECKFLAGS += --quiet --enable=all --error-exitcode=1 --check-level=exhaustive -I./include
#CHECKFLAGS = --enable=all --error-exitcode=1
debug release: DIRS $(APP)
check: cppcheck.out
.PHONY: check1 check2
check1 check2: check
$(APP): $(OBJS)
@ -152,10 +159,11 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
DIRS:
mkdir -p obj bin
cppcheck.out: $(SRC)
check: $(SRC)
$(info output to cppcheck.out)
$(info Check using: : $(CPPCHECK))
$(CPPCHECK) $(CHECKFLAGS) $^ > $@ 2>&1
$(CPPCHECK) $(CHECKFLAGS) $^
.PHONY: clean
clean:
@ -163,3 +171,4 @@ clean:
@rm -f $(APP) $(OBJ_DIR)/* ./bin/$(APP) cppcheck.out
@if [ -d "./bin" ]; then rmdir ./bin ; fi
@if [ -d "./obj" ]; then rmdir ./obj ; fi