2021-10-24 21:39:12 +02:00
|
|
|
cppch = cppcheck
|
2021-11-20 22:13:30 +01:00
|
|
|
cppch_args = --language=c++ --std=c++20 --enable=all --verbose --suppress=unmatchedSuppression --suppress=missingIncludeSystem ./*.{cpp,h}
|
2021-11-13 00:13:19 +01:00
|
|
|
cpp_flags = CMAKE_CXX_FLAGS=
|
2021-10-24 21:39:12 +02:00
|
|
|
c = cmake
|
2021-10-30 20:20:30 +02:00
|
|
|
c_args = -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=
|
2021-10-24 21:39:12 +02:00
|
|
|
n = ninja
|
|
|
|
n_args = -C
|
|
|
|
d_folder = cmake-build-debug
|
|
|
|
r_folder = cmake-build-release
|
2021-12-02 18:34:07 +01:00
|
|
|
s_folder = cmake-build-san
|
|
|
|
s_tru = SANITIZE_PLS=true
|
2021-10-24 21:39:12 +02:00
|
|
|
v = valgrind
|
2021-11-01 09:10:32 +01:00
|
|
|
v_env = VALGRIND=
|
|
|
|
v_db = $(d_folder)_valgr
|
|
|
|
v_rl = $(r_folder)_valgr
|
2021-10-24 21:39:12 +02:00
|
|
|
|
2021-12-05 15:27:47 +01:00
|
|
|
.PHONY: check tidy build debug release valgrind san test clean distclean
|
2021-10-24 21:39:12 +02:00
|
|
|
|
|
|
|
debug:
|
|
|
|
if [ ! -d "$(d_folder)" ]; then mkdir -pv $(d_folder); fi
|
2021-11-11 02:18:01 +01:00
|
|
|
$(v_env)false $(c) $(c_args)Debug -B $(d_folder) -D$(cpp_flags) && \
|
2021-10-24 21:39:12 +02:00
|
|
|
$(n) $(n_args) $(d_folder)
|
2021-11-08 09:41:41 +01:00
|
|
|
@echo fortuna \(debug\) has been built inside $(d_folder)
|
2021-10-24 21:39:12 +02:00
|
|
|
|
|
|
|
release:
|
2021-11-02 03:12:22 +01:00
|
|
|
if [ ! -d "$(r_folder)" ]; then mkdir -pv $(r_folder); fi
|
2021-11-11 02:18:01 +01:00
|
|
|
$(v_env)false $(c) $(c_args)Release -B $(r_folder) -D$(cpp_flags) && \
|
2021-10-24 21:39:12 +02:00
|
|
|
$(n) $(n_args) $(r_folder)
|
2021-11-08 09:41:41 +01:00
|
|
|
@echo fortuna \(release\) has been built inside $(r_folder)
|
2021-10-24 21:39:12 +02:00
|
|
|
|
|
|
|
check:
|
|
|
|
$(cppch) $(cppch_args)
|
2021-10-30 20:20:30 +02:00
|
|
|
make tidy
|
|
|
|
|
2021-12-02 18:34:07 +01:00
|
|
|
san:
|
|
|
|
if [ ! -d "$(s_folder)" ]; then mkdir -pv $(s_folder); fi
|
|
|
|
$(v_env)false $(s_tru) $(c) $(c_args)Debug -B $(s_folder) -D$(cpp_flags) \
|
|
|
|
&& $(n) $(n_args) $(s_folder)
|
|
|
|
|
|
|
|
|
2021-10-30 20:20:30 +02:00
|
|
|
tidy:
|
2021-12-05 05:07:02 +01:00
|
|
|
env TIDY=1 make debug
|
2021-10-24 21:39:12 +02:00
|
|
|
|
|
|
|
valgrind: valgrind-debug
|
|
|
|
|
|
|
|
valgrind-debug:
|
2021-11-01 09:10:32 +01:00
|
|
|
if [ ! -d "$(v_db)" ]; then mkdir -pv "$(v_db)"; fi
|
2021-11-11 02:18:01 +01:00
|
|
|
$(v_env)true $(c) $(c_args)Debug -B "$(v_db)" -D$(cpp_flags) && \
|
2021-11-01 09:10:32 +01:00
|
|
|
$(n) $(n_args) "$(v_db)"
|
2021-11-20 22:09:47 +01:00
|
|
|
$(v) --leak-check=full ./$(v_db)/fortuna
|
2021-11-08 09:41:41 +01:00
|
|
|
@echo fortuna \(debug\) has been built and checked using valgrind
|
2021-10-24 21:39:12 +02:00
|
|
|
|
|
|
|
valgrind-release:
|
2021-11-01 09:10:32 +01:00
|
|
|
if [ ! -d "$(v_rl)" ]; then mkdir -pv "$(v_rl)"; fi
|
2021-11-11 02:18:01 +01:00
|
|
|
$(v_env)true $(c) $(c_args)Release -B "$(v_rl)" -D$(cpp_flags) && \
|
2021-11-01 09:10:32 +01:00
|
|
|
$(n) $(n_args) "$(v_rl)"
|
|
|
|
$(v) ./$(v_rl)/fortuna
|
2021-11-08 09:41:41 +01:00
|
|
|
@echo fortuna \(release\) has been built and checked using valgrind
|
2021-10-24 21:39:12 +02:00
|
|
|
|
|
|
|
build: debug
|
|
|
|
|
2021-10-30 20:55:53 +02:00
|
|
|
test: check build
|
2021-10-24 21:39:12 +02:00
|
|
|
|
2021-11-02 03:14:56 +01:00
|
|
|
clean:
|
2021-12-05 15:27:47 +01:00
|
|
|
@find . -regextype posix-egrep -regex ".*\.(o|dwo|out|bin|cmake)" -delete
|
|
|
|
|
|
|
|
distclean:
|
|
|
|
@find . -iwholename '*cmake*' -not -name CMakeLists.txt -delete
|
2021-11-02 03:14:56 +01:00
|
|
|
|