Debian Codegraph @

Makefile-options

raw
1 ########## BoCA options makefile ##########
2
3 SMOOTHVER = 0.9
4
5 # Find source folder and set vpath
6 SRCDIR = $(abspath $(dir $(firstword $(MAKEFILE_LIST))))
7
8 vpath %.c "$(SRCDIR)"
9 vpath %.cc "$(SRCDIR)"
10 vpath %.cpp "$(SRCDIR)"
11 vpath %.m "$(SRCDIR)"
12 vpath %.mm "$(SRCDIR)"
13
14 # Define makein and cleanin macros
15 ifeq ("$(SRCDIR)","$(CURDIR)")
16 makein = cd $(1) && $(MAKE) $(2) && cd ..
17 cleanin = cd $(1) && $(MAKE) clean && cd ..
18 else
19 makein = mkdir -p $(1) && cd $(1) && $(MAKE) -f "$(SRCDIR)"/$(1)/Makefile $(2) && cd ..
20 cleanin = mkdir -p $(1) && cd $(1) && $(MAKE) -f "$(SRCDIR)"/$(1)/Makefile clean && cd .. && (rmdir $(1) || true)
21 endif
22
23 # Find architecture and system
24 UNAME = $(shell uname)
25 MACHINE = $(shell $(CC) -dumpmachine)
26
27 ifneq ($(findstring arm,$(MACHINE)),)
28 ifneq ($(BUILD_ARM),False)
29 BUILD_ARM = True
30 endif
31 else ifneq ($(findstring aarch64,$(MACHINE)),)
32 ifneq ($(BUILD_ARM64),False)
33 BUILD_ARM64 = True
34 endif
35 else ifneq ($(findstring mips,$(MACHINE)),)
36 ifneq ($(BUILD_MIPS),False)
37 BUILD_MIPS = True
38 endif
39 else ifneq ($(findstring powerpc64,$(MACHINE)),)
40 ifneq ($(BUILD_PPC64),False)
41 BUILD_PPC64 = True
42 endif
43 else ifneq ($(findstring powerpc,$(MACHINE)),)
44 ifneq ($(BUILD_PPC),False)
45 BUILD_PPC = True
46 endif
47 else ifneq ($(findstring riscv64,$(MACHINE)),)
48 ifneq ($(BUILD_RISCV64),False)
49 BUILD_RISCV64 = True
50 endif
51 else ifneq ($(findstring x86_64,$(MACHINE)),)
52 ifneq ($(BUILD_ARM64),True)
53 ifneq ($(BUILD_X86),True)
54 ifneq ($(BUILD_X86_64),False)
55 BUILD_X86_64 = True
56 endif
57 endif
58 endif
59 else ifneq ($(findstring amd64,$(MACHINE)),)
60 ifneq ($(BUILD_ARM64),True)
61 ifneq ($(BUILD_X86),True)
62 ifneq ($(BUILD_X86_64),False)
63 BUILD_X86_64 = True
64 endif
65 endif
66 endif
67 else ifneq ($(findstring i586,$(MACHINE))$(findstring i686,$(MACHINE)),)
68 ifneq ($(BUILD_ARM64),True)
69 ifneq ($(BUILD_X86),False)
70 ifneq ($(BUILD_X86_64),True)
71 BUILD_X86 = True
72 endif
73 endif
74 endif
75 endif
76
77 # Treat MSYS and MinGW the same
78 ifneq ($(findstring MSYS,$(UNAME)),)
79 UNAME = MINGW
80 endif
81
82 ifneq ($(findstring MINGW,$(UNAME)),)
83 # Set executable and shared object extensions
84 EXECUTABLE = .exe
85 SHARED = .dll
86
87 # Build on Win32
88 BUILD_WIN32 = True
89 else
90 # Set executable and shared object extensions
91 EXECUTABLE =
92 SHARED = .so
93
94 BUILD_UNIX = True
95
96 ifeq ($(UNAME),Linux)
97 BUILD_LINUX = True
98 else ifeq ($(UNAME),FreeBSD)
99 BUILD_FREEBSD = True
100 else ifeq ($(UNAME),OpenBSD)
101 BUILD_OPENBSD = True
102 else ifeq ($(UNAME),NetBSD)
103 BUILD_NETBSD = True
104 else ifeq ($(UNAME),SunOS)
105 BUILD_SOLARIS = True
106 else ifeq ($(UNAME),Haiku)
107 BUILD_HAIKU = True
108 else ifeq ($(UNAME),GNU)
109 BUILD_GNU = True
110 else ifeq ($(UNAME),Darwin)
111 # Set shared object extension
112 SHARED = .dylib
113
114 BUILD_OSX = True
115 endif
116 endif
117
118 # Set default commands
119 ifndef OBJC
120 OBJC = $(CC)
121 endif
122
123 ifndef OBJCXX
124 OBJCXX = $(CXX)
125 endif
126
127 ifeq ($(LD),ld)
128 LD = $(CXX)
129 endif
130
131 LDCONFIG = /sbin/ldconfig
132
133 INSTALL = install
134
135 ifeq ($(BUILD_SOLARIS),True)
136 INSTALL = ginstall
137 endif
138
139 INSTALL_PROGRAM = $(INSTALL)
140 INSTALL_DATA = $(INSTALL) -m 644
141
142 # Set output folders
143 BINDIR = bin
144 LIBDIR = lib
145
146 ifeq ($(BUILD_WIN32),True)
147 ifeq ($(BUILD_X86_64),True)
148 BINDIR = bin64
149 LIBDIR = lib64
150 endif
151 endif
152
153 # Set install folders
154 ifndef prefix
155 prefix = /usr/local
156
157 ifeq ($(BUILD_HAIKU),True)
158 prefix = /system/non-packaged
159 endif
160 endif
161
162 bindir = $(prefix)/bin
163 libdir = $(prefix)/lib
164 includedir = $(prefix)/include
165 datadir = $(prefix)/share
166
167 ifeq ($(BUILD_HAIKU),True)
168 includedir = $(prefix)/develop/headers
169 datadir = $(prefix)/data
170 endif
171
172 # Decide which libraries to use
173 ifeq ($(findstring bundledlibexpat,$(config)),bundledlibexpat)
174 USE_BUNDLED_LIBEXPAT = True
175 else ifeq ($(findstring systemlibexpat,$(config)),systemlibexpat)
176 USE_BUNDLED_LIBEXPAT = False
177 else
178 ifeq ($(BUILD_WIN32),True)
179 USE_BUNDLED_LIBEXPAT = True
180 endif
181 endif
182
183 ifeq ($(findstring bundledliburiparser,$(config)),bundledliburiparser)
184 USE_BUNDLED_LIBURIPARSER = True
185 else ifeq ($(findstring systemliburiparser,$(config)),systemliburiparser)
186 USE_BUNDLED_LIBURIPARSER = False
187 else
188 ifeq ($(BUILD_OSX),True)
189 USE_BUNDLED_LIBURIPARSER = True
190 else ifeq ($(BUILD_SOLARIS),True)
191 USE_BUNDLED_LIBURIPARSER = True
192 else ifeq ($(BUILD_WIN32),True)
193 USE_BUNDLED_LIBURIPARSER = True
194 endif
195 endif
196
197 ifeq ($(findstring bundledlibxspf,$(config)),bundledlibxspf)
198 USE_BUNDLED_LIBXSPF = True
199 else ifeq ($(findstring systemlibxspf,$(config)),systemlibxspf)
200 USE_BUNDLED_LIBXSPF = False
201 else
202 USE_BUNDLED_LIBXSPF = True
203 endif
204
205 ifeq ($(findstring bundledzlib,$(config)),bundledzlib)
206 USE_BUNDLED_ZLIB = True
207 else ifeq ($(findstring systemzlib,$(config)),systemzlib)
208 USE_BUNDLED_ZLIB = False
209 else
210 ifeq ($(BUILD_OSX),True)
211 USE_BUNDLED_ZLIB = True
212 else ifeq ($(BUILD_WIN32),True)
213 USE_BUNDLED_ZLIB = True
214 endif
215 endif
216
217 # Decide whether to build using Wine
218 ifneq ($(BUILD_OSX),True)
219 ifneq ($(BUILD_WIN32),True)
220 ifeq ($(shell type winegcc 1> /dev/null 2> /dev/null; echo $$?),0)
221 USE_WINE = True
222 endif
223 endif
224 endif
225
226 # Set release specific options
227 ifeq ($(findstring release,$(config)),release)
228 ifeq ($(BUILD_FREEBSD),True)
229 override CC = clang
230 override CXX = clang++
231 override OBJC = clang
232 override OBJCXX = clang++
233
234 override LD = clang++
235 else ifeq ($(BUILD_OSX),True)
236 override CC = gcc
237 override CXX = g++
238 override OBJC = gcc
239 override OBJCXX = g++
240
241 override LD = g++
242 endif
243
244 override CFLAGS = -pipe -g0 -Wall -Os
245 override CXXFLAGS =
246 override OBJCFLAGS =
247 override OBJCXXFLAGS =
248 override LDFLAGS = -pipe
249
250 ifneq ($(RTTI),True)
251 ifneq ($(BUILD_HAIKU),True)
252 override CXXFLAGS += -fno-rtti
253 override OBJCXXFLAGS += -fno-rtti
254 endif
255 endif
256
257 ifneq ($(EXCEPTION),True)
258 override CXXFLAGS += -fno-exceptions
259 override OBJCXXFLAGS += -fno-exceptions
260 endif
261
262 ifeq ($(BUILD_OSX),True)
263 # Find macOS and Xcode version
264 XCODEVERSION = $(shell xcodebuild -version | head -n1)
265 MACOSVERSION = $(MACOSX_DEPLOYMENT_TARGET)
266
267 ifeq ($(MACOSVERSION),)
268 MACOSVERSION = $(shell sw_vers | awk '$$1 == "ProductVersion:" { print $$2 }')
269 endif
270
271 XCODE_LE3 = $(shell bash -c "v='$(XCODEVERSION)'; v=\$${v\#\#* }; if [ \$${v%%.*} -le 3 ]; then echo True; fi")
272 XCODE_LE9 = $(shell bash -c "v='$(XCODEVERSION)'; v=\$${v\#\#* }; if [ \$${v%%.*} -le 9 ]; then echo True; fi")
273 XCODE_EQ12 = $(shell bash -c "v='$(XCODEVERSION)'; v=\$${v\#\#* }; if [ \$${v%%.*} -eq 12 ]; then echo True; fi")
274 XCODE_GE13 = $(shell bash -c "v='$(XCODEVERSION)'; v=\$${v\#\#* }; if [ \$${v%%.*} -ge 13 ]; then echo True; fi")
275 XCODE_N_GE2 = $(shell bash -c "v='$(XCODEVERSION)'; v=\$${v\#*.}; if [ \$${v%%.*} -ge 2 ]; then echo True; fi")
276
277 MACOS_GE11 = $(shell bash -c "v='$(MACOSVERSION)'; if [ \$${v%%.*} -ge 11 ]; then echo True; fi")
278
279 # Build universal binaries
280 ifneq ($(BUILD_X86_64),False)
281 BUILD_X86_64 = True
282 endif
283 ifeq ($(XCODE_LE9),True)
284 ifneq ($(BUILD_X86),False)
285 BUILD_X86 = True
286 endif
287
288 ifeq ($(XCODE_LE3),True)
289 ifneq ($(BUILD_PPC),False)
290 BUILD_PPC = True
291 endif
292 endif
293 else ifeq ($(XCODE_EQ12),True)
294 ifeq ($(XCODE_N_GE2),True)
295 ifeq ($(MACOS_GE11),True)
296 ifneq ($(BUILD_ARM64),False)
297 BUILD_ARM64 = True
298 endif
299 endif
300 endif
301 else ifeq ($(XCODE_GE13),True)
302 ifeq ($(MACOS_GE11),True)
303 ifneq ($(BUILD_ARM64),False)
304 BUILD_ARM64 = True
305 endif
306 endif
307 endif
308
309 # Set build flags
310 override LDFLAGS += -Wl,-x
311
312 ifeq ($(BUILD_X86),True)
313 override CFLAGS += -arch i386 -Xarch_i386 -march=prescott
314 override LDFLAGS += -arch i386
315 endif
316 ifeq ($(BUILD_X86_64),True)
317 ifeq ($(MACOS_GE11),True)
318 override CFLAGS += -arch x86_64 -Xarch_x86_64 -march=haswell
319 else
320 override CFLAGS += -arch x86_64 -Xarch_x86_64 -march=core2
321 endif
322
323 override LDFLAGS += -arch x86_64
324 endif
325 ifeq ($(BUILD_PPC),True)
326 override CFLAGS += -arch ppc -Xarch_ppc -mcpu=G4
327 override LDFLAGS += -arch ppc
328 endif
329 ifeq ($(BUILD_PPC64),True)
330 override CFLAGS += -arch ppc64 -Xarch_ppc64 -mcpu=G5
331 override LDFLAGS += -arch ppc64
332 endif
333 ifeq ($(BUILD_ARM64),True)
334 override CFLAGS += -arch arm64
335 override LDFLAGS += -arch arm64
336 endif
337 else
338 override LDFLAGS += -s
339
340 ifeq ($(BUILD_X86),True)
341 override CFLAGS += -m32
342 override LDFLAGS += -m32
343 else ifeq ($(BUILD_X86_64),True)
344 override CFLAGS += -m64
345 override LDFLAGS += -m64
346 endif
347 endif
348
349 override CXXFLAGS += $(CFLAGS)
350 override OBJCFLAGS += $(CFLAGS)
351 override OBJCXXFLAGS += $(CFLAGS)
352
353 ifneq ($(BUILD_WIN32),True)
354 ifneq ($(BUILD_OSX),True)
355 override LDFLAGS += -Wl,-rpath,.
356 endif
357 endif
358 endif
359
360 # Set debug specific options
361 ifeq ($(findstring debug,$(config)),debug)
362 override CFLAGS = -pipe -g -Wall -DDEBUG
363 override CXXFLAGS =
364 override OBJCFLAGS =
365 override OBJCXXFLAGS =
366 override LDFLAGS = -pipe
367
368 ifneq ($(RTTI),True)
369 ifneq ($(BUILD_HAIKU),True)
370 override CXXFLAGS += -fno-rtti
371 override OBJCXXFLAGS += -fno-rtti
372 endif
373 endif
374
375 ifneq ($(EXCEPTION),True)
376 override CXXFLAGS += -fno-exceptions
377 override OBJCXXFLAGS += -fno-exceptions
378 endif
379
380 override CXXFLAGS += $(CFLAGS)
381 override OBJCFLAGS += $(CFLAGS)
382 override OBJCXXFLAGS += $(CFLAGS)
383
384 ifneq ($(BUILD_WIN32),True)
385 ifneq ($(BUILD_OSX),True)
386 override LDFLAGS += -Wl,-rpath,.
387 endif
388 endif
389 endif
390
391 # Flags needed for Windows ARM64 toolchain
392 ifeq ($(BUILD_WIN32),True)
393 ifeq ($(BUILD_ARM64),True)
394 override CFLAGS += -target aarch64-w64-mingw32
395 override LDFLAGS += -target aarch64-w64-mingw32
396 endif
397 endif
398
399 # Clear config variable
400 config =