-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile-options
500 lines (426 loc) · 11.5 KB
/
Makefile-options
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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
########## smooth options makefile ##########
VERSION = 0.9
REVISION = 0
# Find source folder and set vpath
SRCDIR = $(abspath $(dir $(firstword $(MAKEFILE_LIST))))
vpath %.c "$(SRCDIR)"
vpath %.cc "$(SRCDIR)"
vpath %.cpp "$(SRCDIR)"
vpath %.m "$(SRCDIR)"
vpath %.mm "$(SRCDIR)"
vpath %.js "$(SRCDIR)"
vpath %.py "$(SRCDIR)"
vpath %.rc "$(SRCDIR)"
# Define makein and cleanin macros
ifeq ("$(SRCDIR)","$(CURDIR)")
makein = cd $(1) && $(MAKE) $(2) && cd ..
cleanin = cd $(1) && $(MAKE) clean && cd ..
else
makein = mkdir -p $(1) && cd $(1) && $(MAKE) -f "$(SRCDIR)"/$(1)/Makefile $(2) && cd ..
cleanin = mkdir -p $(1) && cd $(1) && $(MAKE) -f "$(SRCDIR)"/$(1)/Makefile clean && cd .. && (rmdir $(1) || true)
endif
# Find architecture and system
UNAME = $(shell uname)
MACHINE = $(shell $(CC) -dumpmachine)
ifneq ($(findstring arm,$(MACHINE)),)
ifneq ($(BUILD_ARM),False)
BUILD_ARM = True
endif
else ifneq ($(findstring aarch64,$(MACHINE)),)
ifneq ($(BUILD_ARM64),False)
BUILD_ARM64 = True
endif
else ifneq ($(findstring mips,$(MACHINE)),)
ifneq ($(BUILD_MIPS),False)
BUILD_MIPS = True
endif
else ifneq ($(findstring powerpc,$(MACHINE)),)
ifneq ($(BUILD_PPC),False)
BUILD_PPC = True
endif
else ifneq ($(findstring powerpc64,$(MACHINE)),)
ifneq ($(BUILD_PPC64),False)
BUILD_PPC64 = True
endif
else ifneq ($(findstring x86_64,$(MACHINE)),)
ifneq ($(BUILD_ARM64),True)
ifneq ($(BUILD_X86),True)
ifneq ($(BUILD_X86_64),False)
BUILD_X86_64 = True
endif
endif
endif
else ifneq ($(findstring amd64,$(MACHINE)),)
ifneq ($(BUILD_ARM64),True)
ifneq ($(BUILD_X86),True)
ifneq ($(BUILD_X86_64),False)
BUILD_X86_64 = True
endif
endif
endif
else
ifneq ($(BUILD_ARM64),True)
ifneq ($(BUILD_X86),False)
ifneq ($(BUILD_X86_64),True)
BUILD_X86 = True
endif
endif
endif
endif
# Disable threads based timers
BUILD_THREADSTIMER = False
# Do not build V8 JavaScript library by default
BUILD_V8 = False
# Treat MSYS and MinGW the same
ifneq ($(findstring MSYS,$(UNAME)),)
UNAME = MINGW
endif
ifneq ($(findstring MINGW,$(UNAME)),)
# Set executable and shared object extensions
EXECUTABLE = .exe
SHARED = .dll
# Build using Win32 backends
BUILD_WIN32 = True
# Disable GDI+ backend by default
BUILD_GDIPLUS = False
else
# Set executable and shared object extensions
EXECUTABLE =
SHARED = .so
BUILD_UNIX = True
# Build using XLib backends
BUILD_XLIB = True
# Build using Cairo graphics backend
BUILD_CAIRO = True
# Build using POSIX threads
BUILD_POSIXTHREADS = True
# Build using POSIX timers
BUILD_POSIXTIMER = True
ifeq ($(UNAME),Linux)
BUILD_LINUX = True
else ifeq ($(UNAME),FreeBSD)
BUILD_FREEBSD = True
else ifeq ($(UNAME),OpenBSD)
BUILD_OPENBSD = True
# Enable threads based timers
BUILD_POSIXTIMER = False
BUILD_THREADSTIMER = True
else ifeq ($(UNAME),NetBSD)
BUILD_NETBSD = True
else ifeq ($(UNAME),SunOS)
BUILD_SOLARIS = True
else ifeq ($(UNAME),Haiku)
BUILD_HAIKU = True
# Disable POSIX timer backend
BUILD_POSIXTIMER = False
# Disable XLib and Cairo backends
BUILD_XLIB = False
BUILD_CAIRO = False
else ifeq ($(UNAME),GNU)
BUILD_GNU = True
# Enable threads based timers
BUILD_POSIXTIMER = False
BUILD_THREADSTIMER = True
else ifeq ($(UNAME),Darwin)
# Set shared object extension
SHARED = .dylib
BUILD_OSX = True
# Disable XLib and Cairo backends
BUILD_XLIB = False
BUILD_CAIRO = False
# Disable POSIX timers
BUILD_POSIXTIMER = False
endif
endif
# Set default commands
ifndef OBJC
OBJC = $(CC)
endif
ifndef OBJCXX
OBJCXX = $(CXX)
endif
ifeq ($(LD),ld)
LD = $(CXX)
endif
LDCONFIG = /sbin/ldconfig
INSTALL = install
ifeq ($(BUILD_SOLARIS),True)
INSTALL = ginstall
endif
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL) -m 644
# Set output folders
BINDIR = bin
LIBDIR = lib
ifeq ($(BUILD_WIN32),True)
ifeq ($(BUILD_X86_64),True)
BINDIR = bin64
LIBDIR = lib64
endif
endif
# Set install folders
ifndef prefix
prefix = /usr/local
ifeq ($(BUILD_HAIKU),True)
prefix = /system/non-packaged
endif
endif
bindir = $(prefix)/bin
libdir = $(prefix)/lib
includedir = $(prefix)/include
datadir = $(prefix)/share
ifeq ($(BUILD_HAIKU),True)
includedir = $(prefix)/develop/headers
datadir = $(prefix)/data
endif
# Decide which libraries to use
ifeq ($(findstring bundledlibbz2,$(config)),bundledlibbz2)
USE_BUNDLED_LIBBZ2 = True
else ifeq ($(findstring systemlibbz2,$(config)),systemlibbz2)
USE_BUNDLED_LIBBZ2 = False
else
ifeq ($(BUILD_WIN32),True)
USE_BUNDLED_LIBBZ2 = True
endif
endif
ifeq ($(findstring bundledlibcpuid,$(config)),bundledlibcpuid)
USE_BUNDLED_LIBCPUID = True
else ifeq ($(findstring systemlibcpuid,$(config)),systemlibcpuid)
USE_BUNDLED_LIBCPUID = False
else
USE_BUNDLED_LIBCPUID = True
endif
ifeq ($(findstring bundledlibcurl,$(config)),bundledlibcurl)
USE_BUNDLED_LIBCURL = True
else ifeq ($(findstring systemlibcurl,$(config)),systemlibcurl)
USE_BUNDLED_LIBCURL = False
else
ifeq ($(BUILD_WIN32),True)
USE_BUNDLED_LIBCURL = True
endif
endif
ifeq ($(findstring bundledlibfribidi,$(config)),bundledlibfribidi)
USE_BUNDLED_LIBFRIBIDI = True
else ifeq ($(findstring systemlibfribidi,$(config)),systemlibfribidi)
USE_BUNDLED_LIBFRIBIDI = False
else
ifeq ($(BUILD_OSX),True)
USE_BUNDLED_LIBFRIBIDI = True
else ifeq ($(BUILD_WIN32),True)
USE_BUNDLED_LIBFRIBIDI = True
endif
endif
ifeq ($(findstring bundledlibiconv,$(config)),bundledlibiconv)
USE_BUNDLED_LIBICONV = True
else ifeq ($(findstring systemlibiconv,$(config)),systemlibiconv)
USE_BUNDLED_LIBICONV = False
else
ifeq ($(BUILD_WIN32),True)
USE_BUNDLED_LIBICONV = True
endif
endif
ifeq ($(findstring bundledlibjpeg,$(config)),bundledlibjpeg)
USE_BUNDLED_LIBJPEG = True
else ifeq ($(findstring systemlibjpeg,$(config)),systemlibjpeg)
USE_BUNDLED_LIBJPEG = False
else
ifeq ($(BUILD_OSX),True)
USE_BUNDLED_LIBJPEG = True
else ifeq ($(BUILD_SOLARIS),True)
USE_BUNDLED_LIBJPEG = True
else ifeq ($(BUILD_WIN32),True)
USE_BUNDLED_LIBJPEG = True
endif
endif
ifeq ($(findstring bundledlibpng,$(config)),bundledlibpng)
USE_BUNDLED_LIBPNG = True
else ifeq ($(findstring systemlibpng,$(config)),systemlibpng)
USE_BUNDLED_LIBPNG = False
else
ifeq ($(BUILD_OSX),True)
USE_BUNDLED_LIBPNG = True
else ifeq ($(BUILD_WIN32),True)
USE_BUNDLED_LIBPNG = True
endif
endif
ifeq ($(findstring bundledlibwebp,$(config)),bundledlibwebp)
USE_BUNDLED_LIBWEBP = True
else ifeq ($(findstring systemlibwebp,$(config)),systemlibwebp)
USE_BUNDLED_LIBWEBP = False
else
USE_BUNDLED_LIBWEBP = True
endif
ifeq ($(findstring bundledlibxml2,$(config)),bundledlibxml2)
USE_BUNDLED_LIBXML2 = True
else ifeq ($(findstring systemlibxml2,$(config)),systemlibxml2)
USE_BUNDLED_LIBXML2 = False
else
ifeq ($(BUILD_WIN32),True)
USE_BUNDLED_LIBXML2 = True
endif
endif
ifeq ($(findstring bundledzlib,$(config)),bundledzlib)
USE_BUNDLED_ZLIB = True
else ifeq ($(findstring systemzlib,$(config)),systemzlib)
USE_BUNDLED_ZLIB = False
else
ifeq ($(BUILD_OSX),True)
USE_BUNDLED_ZLIB = True
else ifeq ($(BUILD_WIN32),True)
USE_BUNDLED_ZLIB = True
endif
endif
# Set release specific options
ifeq ($(findstring release,$(config)),release)
ifeq ($(BUILD_FREEBSD),True)
override CC = clang
override CXX = clang++
override OBJC = clang
override OBJCXX = clang++
override LD = clang++
else ifeq ($(BUILD_OSX),True)
override CC = gcc
override CXX = g++
override OBJC = gcc
override OBJCXX = g++
override LD = g++
endif
override CFLAGS = -pipe -g0 -Wall
override CXXFLAGS =
override OBJCFLAGS =
override OBJCXXFLAGS =
override LDFLAGS = -pipe
ifneq ($(BUILD_SOLARIS),True)
override CFLAGS += -Os
endif
ifneq ($(RTTI),True)
ifneq ($(BUILD_HAIKU),True)
override CXXFLAGS += -fno-rtti
override OBJCXXFLAGS += -fno-rtti
endif
endif
ifneq ($(EXCEPTION),True)
override CXXFLAGS += -fno-exceptions
override OBJCXXFLAGS += -fno-exceptions
endif
ifeq ($(BUILD_OSX),True)
# Find macOS and Xcode version
XCODEVERSION = $(shell xcodebuild -version | head -n1)
MACOSVERSION = $(MACOSX_DEPLOYMENT_TARGET)
ifeq ($(MACOSVERSION),)
MACOSVERSION = $(shell sw_vers | awk '$$1 == "ProductVersion:" { print $$2 }')
endif
XCODE_LE3 = $(shell bash -c "v='$(XCODEVERSION)'; v=\$${v\#\#* }; if [ \$${v%%.*} -le 3 ]; then echo True; fi")
XCODE_LE9 = $(shell bash -c "v='$(XCODEVERSION)'; v=\$${v\#\#* }; if [ \$${v%%.*} -le 9 ]; then echo True; fi")
XCODE_EQ12 = $(shell bash -c "v='$(XCODEVERSION)'; v=\$${v\#\#* }; if [ \$${v%%.*} -eq 12 ]; then echo True; fi")
XCODE_GE13 = $(shell bash -c "v='$(XCODEVERSION)'; v=\$${v\#\#* }; if [ \$${v%%.*} -ge 13 ]; then echo True; fi")
XCODE_N_GE2 = $(shell bash -c "v='$(XCODEVERSION)'; v=\$${v\#*.}; if [ \$${v%%.*} -ge 2 ]; then echo True; fi")
MACOS_GE11 = $(shell bash -c "v='$(MACOSVERSION)'; if [ \$${v%%.*} -ge 11 ]; then echo True; fi")
# Build universal binaries
ifneq ($(BUILD_X86_64),False)
BUILD_X86_64 = True
endif
ifeq ($(XCODE_LE9),True)
ifneq ($(BUILD_X86),False)
BUILD_X86 = True
endif
ifeq ($(XCODE_LE3),True)
ifneq ($(BUILD_PPC),False)
BUILD_PPC = True
endif
endif
else ifeq ($(XCODE_EQ12),True)
ifeq ($(XCODE_N_GE2),True)
ifeq ($(MACOS_GE11),True)
ifneq ($(BUILD_ARM64),False)
BUILD_ARM64 = True
endif
endif
endif
else ifeq ($(XCODE_GE13),True)
ifeq ($(MACOS_GE11),True)
ifneq ($(BUILD_ARM64),False)
BUILD_ARM64 = True
endif
endif
endif
# Set build flags
override LDFLAGS += -Wl,-x
ifeq ($(BUILD_X86),True)
override CFLAGS += -arch i386 -Xarch_i386 -march=prescott
override LDFLAGS += -arch i386
endif
ifeq ($(BUILD_X86_64),True)
ifeq ($(MACOS_GE11),True)
override CFLAGS += -arch x86_64 -Xarch_x86_64 -march=haswell
else
override CFLAGS += -arch x86_64 -Xarch_x86_64 -march=core2
endif
override LDFLAGS += -arch x86_64
endif
ifeq ($(BUILD_PPC),True)
override CFLAGS += -arch ppc -Xarch_ppc -mcpu=G4
override LDFLAGS += -arch ppc
endif
ifeq ($(BUILD_PPC64),True)
override CFLAGS += -arch ppc64 -Xarch_ppc64 -mcpu=G5
override LDFLAGS += -arch ppc64
endif
ifeq ($(BUILD_ARM64),True)
override CFLAGS += -arch arm64
override LDFLAGS += -arch arm64
endif
else
override LDFLAGS += -s
ifeq ($(BUILD_X86),True)
override CFLAGS += -m32
override LDFLAGS += -m32
else ifeq ($(BUILD_X86_64),True)
override CFLAGS += -m64
override LDFLAGS += -m64
endif
endif
override CXXFLAGS += $(CFLAGS)
override OBJCFLAGS += $(CFLAGS)
override OBJCXXFLAGS += $(CFLAGS)
ifneq ($(BUILD_WIN32),True)
ifneq ($(BUILD_OSX),True)
LDFLAGS_TOOLS += -Wl,-rpath,.
endif
endif
endif
# Set debug specific options
ifeq ($(findstring debug,$(config)),debug)
override CFLAGS = -pipe -g -Wall -DDEBUG
override CXXFLAGS =
override OBJCFLAGS =
override OBJCXXFLAGS =
override LDFLAGS = -pipe
ifneq ($(RTTI),True)
ifneq ($(BUILD_HAIKU),True)
override CXXFLAGS += -fno-rtti
override OBJCXXFLAGS += -fno-rtti
endif
endif
ifneq ($(EXCEPTION),True)
override CXXFLAGS += -fno-exceptions
override OBJCXXFLAGS += -fno-exceptions
endif
override CXXFLAGS += $(CFLAGS)
override OBJCFLAGS += $(CFLAGS)
override OBJCXXFLAGS += $(CFLAGS)
ifneq ($(BUILD_WIN32),True)
ifneq ($(BUILD_OSX),True)
override LDFLAGS_TOOLS += -Wl,-rpath,.
endif
endif
endif
# Flags needed for Windows ARM64 toolchain
ifeq ($(BUILD_WIN32),True)
ifeq ($(BUILD_ARM64),True)
override CFLAGS += -target aarch64-w64-mingw32
override LDFLAGS += -target aarch64-w64-mingw32
endif
endif
# Clear config variable
config =