-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
193 lines (155 loc) · 5.8 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
ifeq ($(CUSTOM_BUILD),)
ifeq ($(BUILD),debug)
BUILDFLAGS := -g3 -Og
else ifeq ($(BUILD),tsan)
BUILDFLAGS := -g3 -O1 -fsanitize=thread -fno-omit-frame-pointer
LDFLAGS := -fsanitize=thread
else ifeq ($(BUILD),asan)
BUILDFLAGS := -g3 -Og -fsanitize=address -fno-omit-frame-pointer
LDFLAGS := -fsanitize=address
else ifeq ($(BUILD),ubsan)
BUILDFLAGS := -g3 -O1 -fsanitize=undefined -fno-omit-frame-pointer
LDFLAGS := -fsanitize=undefined
else ifeq ($(BUILD),nonnative)
BUILDFLAGS := -Ofast -g3 -march=x86-64-v3
LTO := -flto
else ifeq ($(BUILD),o3gnative)
BUILDFLAGS := -O3 -g3 -march=native
LTO := -flto
else ifeq ($(BUILD),release)
BUILDFLAGS := -Ofast -march=native
LTO := -flto
else
BUILDFLAGS := -g3 -Ofast -march=native
LTO := -flto
endif
else
BUILDFLAGS := $(CUSTOM_BUILD)
LTO := $(CUSTOM_LTO)
endif
LDFLAGS += -lSQLiteCpp
ifeq ($(shell uname -s), Darwin)
LDFLAGS += -framework Cocoa -framework OpenGL -framework IOKit -framework GLUT
else
LDFLAGS += -lGL
endif
TRIPLET ?= x64-linux
DEPS := libzstd gtk4 gtkmm-4.0 glu libevent_openssl openssl libevent_pthreads freetype2 eigen3 vte-2.91-gtk4
OUTPUT := game3
COMPILER ?= g++
DEBUGGER ?= gdb
CPPFLAGS += -Wall -Wextra $(BUILDFLAGS) -std=c++23 -Iinclude -Isubprojects/chemskr/include -Ibuilddir -Ibuilddir/subprojects/chemskr -Idiscord $(LTO) $(PROFILING)
INCLUDES := $(shell pkg-config --cflags $(DEPS))
LIBS := $(shell pkg-config --libs $(DEPS))
GLIB_COMPILE_RESOURCES = $(shell pkg-config --variable=glib_compile_resources gio-2.0)
LDFLAGS := $(LDFLAGS) $(LIBS) -pthread $(LTO) $(PROFILING)
SOURCES := $(shell find -L src -name \*.cpp)
OBJECTS := $(SOURCES:.cpp=.o)
CLOC_OPTIONS := . --exclude-dir=voronoi,pvs-report,discord,subprojects,*build*,.codechecker,_build,po,vscode,stb,eigen,json,data,.github,.idea,vcpkg_installed,build,builddir,.flatpak-builder,libnoise --fullpath --not-match-f='^\.\/((src\/(gtk_)?resources\.cpp|include\/resources\.h|analysis\.txt|include\/lib\/.*|.*\.(json|txt|md|xml))|(chemskr\/src\/chemskr/(NuclideMasses|yylex|yyparse)\.cpp|chemskr\/(include|src)\/chemskr\/yyparse\.h))$$'
.PHONY: all clean flags test
all:
@ cd builddir && ninja
old_all: $(NOISE_OBJ) $(OUTPUT)
vcpkg_install:
vcpkg install
all_install: vcpkg all
vcpkg_zip: all_install zip
macos_setup:
- vcpkg install
PKG_CONFIG_PATH=vcpkg_installed/arm64-osx/lib/pkgconfig meson setup -Dbuildtype=debugoptimized -Ddiscord_rich_presence=false -Dvcpkg_triplet=arm64-osx builddir .
macos_reconf:
PKG_CONFIG_PATH=vcpkg_installed/arm64-osx/lib/pkgconfig meson setup -Dbuildtype=debugoptimized -Ddiscord_rich_presence=false -Dvcpkg_triplet=arm64-osx --reconfigure builddir .
macos_setup_intel:
- vcpkg install
PKG_CONFIG_PATH=vcpkg_installed/x64-osx/lib/pkgconfig meson setup -Ddiscord_rich_presence=false -Dvcpkg_triplet=x64-osx builddir .
macos_reconf_intel:
PKG_CONFIG_PATH=vcpkg_installed/x64-osx/lib/pkgconfig meson setup -Ddiscord_rich_presence=false -Dvcpkg_triplet=x64-osx --reconfigure builddir .
flat:
flatpak-builder --force-clean --arch=x86_64 --ccache --state-dir .flatpak-builder staging gay.heimskr.Game3.json
- flatpak build-finish --command game3 --share=ipc --socket=x11 --socket=wayland --socket=fallback-x11 --share=network --socket=session-bus --device=dri staging
flatpak build-bundle --arch=x86_64 /var/lib/flatpak/repo gay.heimskr.Game3.flatpak gay.heimskr.Game3 master
$(NOISE_OBJ):
cd libnoise && cmake . && make
flags:
@ echo "COMPILER: $(COMPILER)"
@ echo
@ echo "CPPFLAGS: $(CPPFLAGS)"
@ echo
@ echo "LDFLAGS: $(LDFLAGS)"
%.o: %.cpp
@ printf "\e[2m[\e[22;32mc++\e[39;2m]\e[22m $< \e[2m$(strip $(BUILDFLAGS) $(LTO))\e[22m\n"
@ $(COMPILER) $(CPPFLAGS) $(INCLUDES) -c $< -o $@
$(OUTPUT): $(OBJECTS) chemskr/libchemskr.a $(NOISE_OBJ)
@ printf "\e[2m[\e[22;36mld\e[39;2m]\e[22m $@ \e[2m$(LTO)\e[22m\n"
@ $(COMPILER) $^ -o $@ $(LDFLAGS)
pvs:
STAMP=$
mkdir -p pvs-report/
pvs-studio-analyzer trace -- meson compile -C builddir
pvs-studio-analyzer analyze \
-a "64;GA;OP;CS" \
-e subprojects \
-j "$(shell nproc)" \
-o pvs-analysis.log
plog-converter \
-p game3 \
-a "64;GA;OP;CS" \
-t fullhtml \
-o pvs-report/$$(date +'%Y-%m-%d_T%H%M%S') \
-d "V104,V1042" \
pvs-analysis.log\
repvs:
pvs-studio-analyzer analyze \
-a "64;GA;OP;CS" \
-e subprojects \
-j "$(shell nproc)" \
-o pvs-analysis.log
plog-converter \
-p game3 \
-a "64;GA;OP;CS" \
-t fullhtml \
-o pvs-report/$$(date +'%Y-%m-%d_T%H%M%S') \
-d "V104,V1042" \
pvs-analysis.log\
chemskr/libchemskr.a:
make -C chemskr libchemskr.a
test: $(OUTPUT)
./$<
servertest: $(OUTPUT)
./$< -s
flasktest: $(OUTPUT)
./$< 0 0.0 -0.2 > flask.png
tsanservertest: $(OUTPUT)
TSAN_OPTIONS="suppressions=tsan_suppressions.txt" ./$< -s
tsanclienttest: $(OUTPUT)
TSAN_OPTIONS="suppressions=tsan_suppressions.txt" ./$<
tsandebugtest: $(OUTPUT)
TSAN_OPTIONS="suppressions=tsan_suppressions.txt" $(DEBUGGER) ./$<
%.tidy: %.cpp
@ printf "\e[2m[\e[22;36mtidy\e[39;2m]\e[22m $<\n"
@ clang-tidy $< -- $(CPPFLAGS) $(INCLUDES)
reverse = $(if $(wordlist 2,2,$(1)),$(call reverse,$(wordlist 2,$(words $(1)),$(1))) $(firstword $(1)),$(1))
tidy: $(foreach source,$(call reverse,$(SOURCES)),$(source:.cpp=.tidy))
clean:
@ rm -f $(shell find -L src -name \*.o) $(OUTPUT) src/gtk_resources.cpp
count:
cloc $(CLOC_OPTIONS)
countbf:
cloc --by-file $(CLOC_OPTIONS)
analyze:
gprof ./game3 gmon.out > analysis.txt
DEPFILE := .dep
DEPTOKEN := "\# MAKEDEPENDS"
depend:
@ echo $(DEPTOKEN) > $(DEPFILE)
makedepend -f $(DEPFILE) -s $(DEPTOKEN) -Y -- $(COMPILER) $(CPPFLAGS) -- $(SOURCES) 2>/dev/null
@ rm $(DEPFILE).bak
sinclude $(DEPFILE)
zip: $(OUTPUT)
rm -f game3.zip
mkdir Game3
cp -r resources Game3/resources
cp -r data Game3/data
cp $(OUTPUT) Game3/$(OUTPUT)
zip -r game3.zip Game3
rm -r Game3