This repository has been archived on 2022-02-10. You can view files and clone it, but cannot push or open issues or pull requests.
fortuna/Makefile

118 lines
3.3 KiB
Makefile
Raw Normal View History

2021-10-24 21:39:12 +02:00
cppch = cppcheck
cppch_args = --language=c++ --std=c++20 --enable=all --verbose --suppress=unmatchedSuppression --suppress=missingIncludeSystem ./*.{cpp,h}
2021-10-24 21:39:12 +02:00
c = cmake
2022-01-04 05:33:14 +01:00
c_args = -G Ninja -DCMAKE_BUILD_TYPE=
c_args_d = $(c_args)Debug
c_args_r = $(c_args)Release
2022-01-07 05:02:52 +01:00
cl = -DCMAKE_CXX_COMPILER=clang++
g = -DCMAKE_CXX_COMPILER=g++
2021-10-24 21:39:12 +02:00
n = ninja
n_args = -C
2022-01-21 19:14:55 +01:00
t_folder = /tmp/.fortuna_workdir/build
2021-10-24 21:39:12 +02:00
d_folder = cmake-build-debug
2022-01-07 05:02:52 +01:00
d_folder_cl = $(d_folder)_cl
2022-01-21 19:14:55 +01:00
dt_folder = $(t_folder)/$(d_folder)
2021-10-24 21:39:12 +02:00
r_folder = cmake-build-release
2022-01-21 19:14:55 +01:00
rt_folder = $(t_folder)/$(r_folder)
2021-12-02 18:34:07 +01:00
s_folder = cmake-build-san
2022-01-07 05:02:52 +01:00
s_folder_cl = $(s_folder)_cl
2022-01-21 19:14:55 +01:00
st_folder = $(t_folder)/$(s_folder)
tidy_folder = cmake-build-tidy
2022-01-21 19:14:55 +01:00
tidyt_folder = $(t_folder)/$(tidy_folder)
s_on = -DSAN=ON
s_off = -DSAN=OFF
t_on = -DTIDY=ON
t_off = -DTIDY=OFF
2021-10-24 21:39:12 +02:00
v = valgrind
v_on = -DVALGRIND=ON
v_off = -DVALGRIND=OFF
v_db = $(d_folder)_valgr
v_rl = $(r_folder)_valgr
2021-10-24 21:39:12 +02:00
2022-01-07 05:02:52 +01:00
.PHONY: check tidy build debug debug_cl release valgrind san san_cl test clean distclean
2021-10-24 21:39:12 +02:00
debug:
2022-01-21 19:14:55 +01:00
ifneq ("${CI}","true")
@if [ ! -L "$(d_folder)" ]; then \
mkdir -pv $(dt_folder) && ln -sfv $(dt_folder) $(d_folder);\
fi
else
@if [ ! -d "$(d_folder)" ]; then mkdir -pv $(d_folder); fi
endif
$(c) $(c_args_d) $(g) $(s_off) $(t_off) $(v_off) -B$$(readlink -f $(d_folder))
2021-10-24 21:39:12 +02:00
$(n) $(n_args) $(d_folder)
2022-01-07 05:02:52 +01:00
debug_cl:
if [ ! -d "$(d_folder_cl)" ]; then mkdir -pv $(d_folder_cl); fi
$(c) $(c_args_d) $(cl) $(s_off) $(t_off) $(v_off) -B$(d_folder_cl)
$(n) $(n_args) $(d_folder_cl)
2021-10-24 21:39:12 +02:00
release:
2022-01-21 19:14:55 +01:00
ifneq ("${CI}","true")
@if [ ! -L "$(r_folder)" ]; then \
mkdir -pv $(rt_folder) && ln -sfv $(rt_folder) $(r_folder);\
fi
else
@if [ ! -d "$(r_folder)" ]; then mkdir -pv $(r_folder); fi
endif
$(c) $(c_args_r) $(g) $(s_off) $(t_off) $(v_off) -B$$(readlink -f $(r_folder))
2021-10-24 21:39:12 +02:00
$(n) $(n_args) $(r_folder)
check:
$(cppch) $(cppch_args)
2021-10-30 20:20:30 +02:00
make tidy
2021-12-02 18:34:07 +01:00
san:
2022-01-21 19:14:55 +01:00
ifneq ("${CI}","true")
@if [ ! -L "$(s_folder)" ]; then \
mkdir -pv $(st_folder) && ln -sfv $(st_folder) $(s_folder);\
fi
else
@if [ ! -d "$(s_folder)" ]; then mkdir -pv $(s_folder); fi
endif
$(c) $(c_args_d) $(g) $(s_on) $(t_off) $(v_off) -B$$(readlink -f $(s_folder))
$(n) $(n_args) $(s_folder)
2021-12-02 18:34:07 +01:00
2022-01-07 05:02:52 +01:00
san_cl:
if [ ! -d "$(s_folder_cl)" ]; then mkdir -pv $(s_folder_cl); fi
$(c) $(c_args_d) $(cl) $(s_on) $(t_off) $(v_off) -B$(s_folder_cl)
$(n) $(n_args) $(s_folder_cl)
2021-12-02 18:34:07 +01:00
2021-10-30 20:20:30 +02:00
tidy:
2022-01-21 19:14:55 +01:00
ifneq ("${CI}","true")
if [ ! -L "$(tidy_folder)" ]; then \
mkdir -pv $(tidyt_folder) && \
ln -sfv $(tidyt_folder) $(tidy_folder);\
fi
else
@if [ ! -d "$(tidy_folder)" ]; then mkdir -pv $(tidy_folder); fi
endif
$(c) $(c_args_d) $(g) $(s_off) $(t_on) $(v_off) -B$$(readlink -f $(tidy_folder))
$(n) $(n_args) $(tidy_folder)
2021-10-24 21:39:12 +02:00
valgrind: valgrind-debug
valgrind-debug:
if [ ! -d "$(v_db)" ]; then mkdir -pv "$(v_db)"; fi
2022-01-07 05:02:52 +01:00
$(c) $(c_args_d) $(g) $(s_off) $(t_off) $(v_on) -B"$(v_db)"
$(n) $(n_args) "$(v_db)"
$(v) --leak-check=full ./$(v_db)/fortuna
2021-10-24 21:39:12 +02:00
valgrind-release:
if [ ! -d "$(v_rl)" ]; then mkdir -pv "$(v_rl)"; fi
2022-01-07 05:02:52 +01:00
$(c) $(c_args_r) $(g) $(s_off) $(t_off) $(v_on) -B"$(v_rl)"
$(n) $(n_args) "$(v_rl)"
$(v) ./$(v_rl)/fortuna
2021-10-24 21:39:12 +02:00
build: debug
test: check build
2021-10-24 21:39:12 +02:00
2021-11-02 03:14:56 +01:00
clean:
@find . -maxdepth 5 -follow -type f -regextype posix-egrep -regex ".*\.(o|dwo|out|bin|cmake|txt)" -not -name CMakeLists.txt -not -path "./lib/*" -not -path "./.git/*" -delete
distclean:
@find . -iwholename '*cmake*' -not -name CMakeLists.txt -not -path "./lib/*" -delete
2021-11-02 03:14:56 +01:00