-
Notifications
You must be signed in to change notification settings - Fork 99
/
Makefile
333 lines (257 loc) · 10.9 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# VVdeC/Makefile
#
# How to build a single target:
# make <project>-r => build variant=release
# make <project>-d => build variant=debug
# make <project>-p => build variant=relwithdebinfo
#
# How to clean and build a single target:
# make <project>-cr => clean + build variant=release
# make <project>-cd => clean + build variant=debug
# make <project>-cp => clean + build variant=relwithdebinfo
#
TARGETS := vvdec vvdecapp
ifneq ($(g),)
ifeq ($(g),umake)
CMAKE_GENERATOR_CUSTOM := Unix Makefiles
else ifeq ($(g),ninja)
CMAKE_GENERATOR_CUSTOM := Ninja
else ifeq ($(g),xcode)
CMAKE_GENERATOR_CUSTOM := Xcode
else
CMAKE_GENERATOR_CUSTOM := $(g)
endif
CONFIG_OPTIONS += -G '$(CMAKE_GENERATOR_CUSTOM)'
endif
ifneq ($(verbose),)
CONFIG_OPTIONS += -DCMAKE_VERBOSE_MAKEFILE=$(verbose)
endif
ifneq ($(enable-bitstream-download),)
CONFIG_OPTIONS += -DVVDEC_ENABLE_BITSTREAM_DOWNLOAD=$(enable-bitstream-download)
endif
ifneq ($(enable-local-bitstream-download),)
CONFIG_OPTIONS += -DVVDEC_ENABLE_LOCAL_BITSTREAM_DOWNLOAD=$(enable-local-bitstream-download)
endif
ifneq ($(enable-build-type-postfix),)
CONFIG_OPTIONS += -DVVDEC_ENABLE_BUILD_TYPE_POSTFIX=$(enable-build-type-postfix)
endif
ifneq ($(install-prefix),)
CONFIG_OPTIONS += -DCMAKE_INSTALL_PREFIX=$(install-prefix)
endif
ifneq ($(install-vvdecapp),)
CONFIG_OPTIONS += -DVVDEC_INSTALL_VVDECAPP=$(install-vvdecapp)
endif
ifneq ($(opt-target-arch),)
CONFIG_OPTIONS += -DVVDEC_OPT_TARGET_ARCH=$(opt-target-arch)
endif
ifneq ($(enable-lto),)
CONFIG_OPTIONS += -DVVDEC_ENABLE_LINK_TIME_OPT=$(enable-lto)
endif
ifneq ($(enable-werror),)
CONFIG_OPTIONS += -DVVDEC_ENABLE_WERROR=$(enable-werror)
endif
ifneq ($(osx-arch),)
CONFIG_OPTIONS += -DCMAKE_OSX_ARCHITECTURES=$(osx-arch)
endif
ifneq ($(toolchainfile),)
CONFIG_OPTIONS += -DCMAKE_TOOLCHAIN_FILE=$(toolchainfile)
endif
ifneq ($(address-sanitizer),)
CONFIG_OPTIONS += -DVVDEC_USE_ADDRESS_SANITIZER=$(address-sanitizer)
endif
ifneq ($(thread-sanitizer),)
CONFIG_OPTIONS += -DVVDEC_USE_THREAD_SANITIZER=$(thread-sanitizer)
endif
ifneq ($(enable-tracing),)
CONFIG_OPTIONS += -DVVDEC_ENABLE_TRACING=$(enable-tracing)
endif
ifeq ($(j),)
# Query cmake for the number of cores
NUM_JOBS := $(shell cmake -P cmake/modules/vvdecNumCores.cmake)
NUM_JOBS := $(lastword $(NUM_JOBS))
else
NUM_JOBS := $(j)
endif
ifeq ($(OS),Windows_NT)
ifneq ($(msvc-arch),)
CONFIG_OPTIONS += -A $(msvc-arch)
else
CONFIG_OPTIONS += -A x64
endif
CMAKE_MCONFIG := 1
ifneq ($(NUM_JOBS),1)
BUILD_TOOL_OPTIONS := -- /maxcpucount:$(NUM_JOBS) /verbosity:minimal /nr:false
else
BUILD_TOOL_OPTIONS := -- /verbosity:minimal /nr:false
endif
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
ifneq ($(CMAKE_GENERATOR_CUSTOM),)
ifeq ($(CMAKE_GENERATOR_CUSTOM),Xcode)
CMAKE_MCONFIG := 1
endif
else
# No CMake generator specified as argument. Check for environment first.
ifeq ($(CMAKE_GENERATOR),)
CMAKE_MCONFIG := 1
# Default depends wether ninja is installed or not but this cannot be determined easily.
CONFIG_OPTIONS += -G Xcode
else ifeq ($(CMAKE_GENERATOR),Xcode)
CMAKE_MCONFIG := 1
endif
endif
endif
ifneq ($(NUM_JOBS),1)
BUILD_JOBS := -j $(NUM_JOBS)
endif
endif
ifeq ($(CMAKE_MCONFIG),)
# Using a CMake single-config generater like Unix Makefiles or Ninja
BUILD_DIR-release := build/release-static
BUILD_DIR-debug := build/debug-static
BUILD_DIR-relwithdebinfo := build/relwithdebinfo-static
BUILD_DIR-release-shared := build/release-shared
BUILD_DIR-debug-shared := build/debug-shared
BUILD_DIR-relwithdebinfo-shared := build/relwithdebinfo-shared
else
# Using a CMake multi-config generator like Visual Studio or Xcode
CONFIG_OPTIONS += -DCMAKE_CONFIGURATION_TYPES=Debug\;Release\;RelWithDebInfo
BUILD_DIR_STATIC := build/static
BUILD_DIR_SHARED := build/shared
BUILD_DIR-release := $(BUILD_DIR_STATIC)
BUILD_DIR-debug := $(BUILD_DIR_STATIC)
BUILD_DIR-relwithdebinfo := $(BUILD_DIR_STATIC)
BUILD_DIR-release-shared := $(BUILD_DIR_SHARED)
BUILD_DIR-debug-shared := $(BUILD_DIR_SHARED)
BUILD_DIR-relwithdebinfo-shared := $(BUILD_DIR_SHARED)
endif
BUILD_OPTIONS-release := --build $(BUILD_DIR-release)
BUILD_OPTIONS-debug := --build $(BUILD_DIR-debug)
BUILD_OPTIONS-relwithdebinfo := --build $(BUILD_DIR-relwithdebinfo)
BUILD_OPTIONS-release-shared := --build $(BUILD_DIR-release-shared)
BUILD_OPTIONS-debug-shared := --build $(BUILD_DIR-debug-shared)
BUILD_OPTIONS-relwithdebinfo-shared := --build $(BUILD_DIR-relwithdebinfo-shared)
ifneq ($(CMAKE_MCONFIG),)
BUILD_OPTIONS-release += --config Release
BUILD_OPTIONS-debug += --config Debug
BUILD_OPTIONS-relwithdebinfo += --config RelWithDebInfo
BUILD_OPTIONS-release-shared += --config Release
BUILD_OPTIONS-debug-shared += --config Debug
BUILD_OPTIONS-relwithdebinfo-shared += --config RelWithDebInfo
endif
DEFAULT_BUILD_TARGETS_STATIC := release debug relwithdebinfo
DEFAULT_BUILD_TARGETS_SHARED := $(foreach t,$(DEFAULT_BUILD_TARGETS_STATIC),$(t)-shared)
DEFAULT_BUILD_TARGETS := $(DEFAULT_BUILD_TARGETS_STATIC) $(DEFAULT_BUILD_TARGETS_SHARED)
release: $(BUILD_DIR-release)/CMakeCache.txt
cmake $(BUILD_OPTIONS-$@) $(BUILD_JOBS) $(BUILD_TOOL_OPTIONS)
debug: $(BUILD_DIR-debug)/CMakeCache.txt
cmake $(BUILD_OPTIONS-$@) $(BUILD_JOBS) $(BUILD_TOOL_OPTIONS)
relwithdebinfo: $(BUILD_DIR-relwithdebinfo)/CMakeCache.txt
cmake $(BUILD_OPTIONS-$@) $(BUILD_JOBS) $(BUILD_TOOL_OPTIONS)
release-shared: $(BUILD_DIR-release-shared)/CMakeCache.txt
cmake $(BUILD_OPTIONS-$@) $(BUILD_JOBS) $(BUILD_TOOL_OPTIONS)
debug-shared: $(BUILD_DIR-debug-shared)/CMakeCache.txt
cmake $(BUILD_OPTIONS-$@) $(BUILD_JOBS) $(BUILD_TOOL_OPTIONS)
relwithdebinfo-shared: $(BUILD_DIR-relwithdebinfo-shared)/CMakeCache.txt
cmake $(BUILD_OPTIONS-$@) $(BUILD_JOBS) $(BUILD_TOOL_OPTIONS)
$(foreach t,$(DEFAULT_BUILD_TARGETS),clean-$(t)):
cmake $(BUILD_OPTIONS-$(patsubst clean-%,%,$@)) $(BUILD_JOBS) --target clean $(BUILD_TOOL_OPTIONS)
install-release: release
cmake $(BUILD_OPTIONS-$(patsubst install-%,%,$@)) --target install
install-debug: debug
cmake $(BUILD_OPTIONS-$(patsubst install-%,%,$@)) --target install
install-relwithdebinfo: relwithdebinfo
cmake $(BUILD_OPTIONS-$(patsubst install-%,%,$@)) --target install
install-release-shared: release-shared
cmake $(BUILD_OPTIONS-$(patsubst install-%,%,$@)) --target install
install-debug-shared: debug-shared
cmake $(BUILD_OPTIONS-$(patsubst install-%,%,$@)) --target install
install-relwithdebinfo-shared: relwithdebinfo-shared
cmake $(BUILD_OPTIONS-$(patsubst install-%,%,$@)) --target install
ifeq ($(CMAKE_MCONFIG),)
$(BUILD_DIR-release)/CMakeCache.txt configure-release:
cmake -S . -B $(BUILD_DIR-release) $(CONFIG_OPTIONS) -DCMAKE_BUILD_TYPE=Release
$(BUILD_DIR-debug)/CMakeCache.txt configure-debug:
cmake -S . -B $(BUILD_DIR-debug) $(CONFIG_OPTIONS) -DCMAKE_BUILD_TYPE=Debug
$(BUILD_DIR-relwithdebinfo)/CMakeCache.txt configure-relwithdebinfo:
cmake -S . -B $(BUILD_DIR-relwithdebinfo) $(CONFIG_OPTIONS) -DCMAKE_BUILD_TYPE=RelWithDebInfo
$(BUILD_DIR-release-shared)/CMakeCache.txt configure-release-shared:
cmake -S . -B $(BUILD_DIR-release-shared) $(CONFIG_OPTIONS) -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=1
$(BUILD_DIR-debug-shared)/CMakeCache.txt configure-debug-shared:
cmake -S . -B $(BUILD_DIR-debug-shared) $(CONFIG_OPTIONS) -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=1
$(BUILD_DIR-relwithdebinfo-shared)/CMakeCache.txt configure-relwithdebinfo-shared:
cmake -S . -B $(BUILD_DIR-relwithdebinfo-shared) $(CONFIG_OPTIONS) -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=1
configure-static: $(foreach t,$(DEFAULT_BUILD_TARGETS_STATIC),configure-$(t))
configure-shared: $(foreach t,$(DEFAULT_BUILD_TARGETS_SHARED),configure-$(t))
else
$(BUILD_DIR_STATIC)/CMakeCache.txt configure-static $(foreach t,$(DEFAULT_BUILD_TARGETS_STATIC),configure-$(t)):
cmake -S . -B $(BUILD_DIR_STATIC) $(CONFIG_OPTIONS)
$(BUILD_DIR_SHARED)/CMakeCache.txt configure-shared $(foreach t,$(DEFAULT_BUILD_TARGETS_SHARED),configure-$(t)):
cmake -S . -B $(BUILD_DIR_SHARED) $(CONFIG_OPTIONS) -DBUILD_SHARED_LIBS=1
endif
static: $(DEFAULT_BUILD_TARGETS_STATIC)
shared: $(DEFAULT_BUILD_TARGETS_SHARED)
all: static shared
configure: configure-static configure-shared
install-static: $(foreach t,$(DEFAULT_BUILD_TARGETS_STATIC),install-$(t))
install-shared: $(foreach t,$(DEFAULT_BUILD_TARGETS_SHARED),install-$(t))
install-all: install-static install-shared
# default distribution target
install: install-release-shared
clean:
$(RM) -rf build bin lib
realclean: clean
$(RM) -rf install
distclean: realclean
$(RM) -rf ext
# Some alias targets to ease interactive use in command shells
configure-r: configure-release
configure-d: configure-debug
configure-rs: configure-release-shared
configure-ds: configure-debug-shared
configure-p: configure-relwithdebinfo
configure-ps: configure-relwithdebinfo-shared
clean-r: clean-release
clean-d: clean-debug
clean-rs: clean-release-shared
clean-ds: clean-debug-shared
clean-p: clean-relwithdebinfo
clean-ps: clean-relwithdebinfo-shared
install-r: install-release
install-d: install-debug
install-rs: install-release-shared
install-ds: install-debug-shared
install-p: install-relwithdebinfo
install-ps: install-relwithdebinfo-shared
# test target
test: release
cmake $(BUILD_OPTIONS-release) --target test-ok $(BUILD_TOOL_OPTIONS)
test-relwithdebinfo: relwithdebinfo
cmake $(BUILD_OPTIONS-relwithdebinfo) --target test-ok $(BUILD_TOOL_OPTIONS)
test-all: release
cmake $(BUILD_OPTIONS-release) --target test-all $(BUILD_TOOL_OPTIONS)
#
# project specific targets
#
# build the list of release, debug targets given the generic targets
TARGETS_RELEASE := $(foreach t,$(TARGETS),$(t)-r)
TARGETS_DEBUG := $(foreach t,$(TARGETS),$(t)-d)
TARGETS_RELWITHDEBINFO := $(foreach t,$(TARGETS),$(t)-p)
TARGETS_RELEASE_CLEAN_FIRST := $(foreach t,$(TARGETS),$(t)-cr)
TARGETS_DEBUG_CLEAN_FIRST := $(foreach t,$(TARGETS),$(t)-cd)
TARGETS_RELWITHDEBINFO_CLEAN_FIRST := $(foreach t,$(TARGETS),$(t)-cp)
$(TARGETS_RELEASE): $(BUILD_DIR-release)/CMakeCache.txt
cmake $(BUILD_OPTIONS-release) $(BUILD_JOBS) --target $(patsubst %-r,%,$@) $(BUILD_TOOL_OPTIONS)
$(TARGETS_RELEASE_CLEAN_FIRST): $(BUILD_DIR-release)/CMakeCache.txt
cmake $(BUILD_OPTIONS-release) $(BUILD_JOBS) --clean-first --target $(patsubst %-cr,%,$@) $(BUILD_TOOL_OPTIONS)
$(TARGETS_DEBUG): $(BUILD_DIR-debug)/CMakeCache.txt
cmake $(BUILD_OPTIONS-debug) $(BUILD_JOBS) --target $(patsubst %-d,%,$@) $(BUILD_TOOL_OPTIONS)
$(TARGETS_DEBUG_CLEAN_FIRST): $(BUILD_DIR-debug)/CMakeCache.txt
cmake $(BUILD_OPTIONS-debug) $(BUILD_JOBS) --clean-first --target $(patsubst %-cd,%,$@) $(BUILD_TOOL_OPTIONS)
$(TARGETS_RELWITHDEBINFO): $(BUILD_DIR-relwithdebinfo)/CMakeCache.txt
cmake $(BUILD_OPTIONS-relwithdebinfo) $(BUILD_JOBS) --target $(patsubst %-p,%,$@) $(BUILD_TOOL_OPTIONS)
$(TARGETS_RELWITHDEBINFO_CLEAN_FIRST): $(BUILD_DIR-relwithdebinfo)/CMakeCache.txt
cmake $(BUILD_OPTIONS-relwithdebinfo) $(BUILD_JOBS) --clean-first --target $(patsubst %-cp,%,$@) $(BUILD_TOOL_OPTIONS)
.PHONY: install clean realclean distclean
.NOTPARALLEL: