cppch = cppcheck
cppch_args = --language=c++ --std=c++20 --enable=all --verbose ./*.{cpp,h}
cpp_flags = -DCMAKE_CXX_FLAGS=-Wall -Werror -Wextra
c = cmake
c_args = -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=
n = ninja
n_args = -C
d_folder = cmake-build-debug
r_folder = cmake-build-release
t = clang-tidy
t_args = --config="" --format-style=google --checks="clang-diagnostic-*,clang-analyzer-*,google-*" --use-color=true -p $(d_folder) ./*.{cpp,h}
v = valgrind
.PHONY: check tidy build debug release valgrind test
debug:
if [ ! -d "$(d_folder)" ]; then mkdir -pv $(d_folder); fi
$(c) $(c_args)Debug -B $(d_folder) $(cpp_flags) && \
$(n) $(n_args) $(d_folder)
release:
$(c) $(c_args)Release -B $(r_folder) $(cpp_flags) && \
$(n) $(n_args) $(r_folder)
check:
$(cppch) $(cppch_args)
make tidy
tidy:
$(t) $(t_args)
valgrind: valgrind-debug
valgrind-debug:
$(v) ./$(d_folder)/fortuna
valgrind-release:
$(v) ./$(r_folder)/fortuna
build: debug
test: check build valgrind