Subversion Repositories eduke32

Rev

Rev 4817 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4817 Rev 4824
1
# OS package maintainers: Please try invoking make with PACKAGE_REPOSITORY=1 to see if that meets your needs before patching out our optimizations entirely.
1
# OS package maintainers: Please try invoking make with PACKAGE_REPOSITORY=1 to see if that meets your needs before patching out our optimizations entirely.
2
PACKAGE_REPOSITORY ?= 0
2
PACKAGE_REPOSITORY ?= 0
3
3
4
# Use colored output. Disable for build system debugging.
4
# Use colored output. Disable for build system debugging.
5
PRETTY_OUTPUT ?= 1
5
PRETTY_OUTPUT ?= 1
6
6
7
# Tools
7
# Tools
8
CROSS=
8
CROSS=
9
ifneq ($(CROSS),)
9
ifneq ($(CROSS),)
10
    undefine CC
10
    undefine CC
11
    undefine CXX
11
    undefine CXX
12
    undefine AR
12
    undefine AR
13
    undefine RC
13
    undefine RC
14
    undefine RANLIB
14
    undefine RANLIB
15
    undefine STRIP
15
    undefine STRIP
16
endif
16
endif
17
17
18
CC=$(CROSS)gcc
18
CC=$(CROSS)gcc
19
CXX=$(CROSS)g++
19
CXX=$(CROSS)g++
20
AR=$(CROSS)ar
20
AR=$(CROSS)ar
21
RC=$(CROSS)windres
21
RC=$(CROSS)windres
22
RANLIB=$(CROSS)ranlib
22
RANLIB=$(CROSS)ranlib
23
STRIP=$(CROSS)strip
23
STRIP=$(CROSS)strip
24
AS=nasm
24
AS=nasm
25
PKG_CONFIG=pkg-config
25
PKG_CONFIG=pkg-config
26
26
27
DONT_PRINT = > /dev/null 2>&1
27
DONT_PRINT = > /dev/null 2>&1
28
DONT_FAIL = ; exit 0
28
DONT_FAIL = ; exit 0
29
29
30
# Override defaults that absolutely will not work.
30
# Override defaults that absolutely will not work.
31
ifeq ($(CC),cc)
31
ifeq ($(CC),cc)
32
    override CC=gcc
32
    override CC=gcc
33
endif
33
endif
34
ifeq ($(AS),as)
34
ifeq ($(AS),as)
35
    override AS=nasm
35
    override AS=nasm
36
endif
36
endif
37
37
38
COMPILER_OBJC=$(CC)
38
COMPILER_OBJC=$(CC)
39
L_CC=$(CC)
39
L_CC=$(CC)
40
L_CXX=$(CXX)
40
L_CXX=$(CXX)
41
41
42
CCFULLPATH=$(CC)
42
CCFULLPATH=$(CC)
43
43
44
ifeq ($(PLATFORM),WII)
44
ifeq ($(PLATFORM),WII)
45
    ifeq ($(strip $(DEVKITPPC)),)
45
    ifeq ($(strip $(DEVKITPPC)),)
46
        $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
46
        $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
47
    endif
47
    endif
48
48
49
    include $(DEVKITPPC)/wii_rules
49
    include $(DEVKITPPC)/wii_rules
50
50
51
    CCFULLPATH=$(DEVKITPPC)/bin/$(CC)
51
    CCFULLPATH=$(DEVKITPPC)/bin/$(CC)
52
52
53
    CROSS=powerpc-eabi-
53
    CROSS=powerpc-eabi-
54
    RANLIB=powerpc-eabi-ranlib
54
    RANLIB=powerpc-eabi-ranlib
55
    STRIP=powerpc-eabi-strip
55
    STRIP=powerpc-eabi-strip
56
endif
56
    ELF2DOL=elf2dol
-
 
57
    DOLSUFFIX=.dol
-
 
58
endif
57
59
58
CLANG?=0
60
CLANG?=0
59
61
60
CLANG_POTENTIAL_VERSION := $(shell $(CCFULLPATH) --version)
62
CLANG_POTENTIAL_VERSION := $(shell $(CCFULLPATH) --version)
61
63
62
ifeq ($(findstring clang,$(CC)),clang)
64
ifeq ($(findstring clang,$(CC)),clang)
63
    override CLANG=1
65
    override CLANG=1
64
endif
66
endif
65
# detect clang symlinked as gcc, as in OS X
67
# detect clang symlinked as gcc, as in OS X
66
ifeq ($(findstring clang,$(CLANG_POTENTIAL_VERSION)),clang)
68
ifeq ($(findstring clang,$(CLANG_POTENTIAL_VERSION)),clang)
67
    override CLANG=1
69
    override CLANG=1
68
endif
70
endif
69
71
70
ifneq (0,$(CLANG))
72
ifneq (0,$(CLANG))
71
    override CC=clang -x c
73
    override CC=clang -x c
72
    override CXX=clang -x c++
74
    override CXX=clang -x c++
73
    override COMPILER_OBJC=clang -x objective-c
75
    override COMPILER_OBJC=clang -x objective-c
74
    override L_CC=clang
76
    override L_CC=clang
75
    override L_CXX=clang
77
    override L_CXX=clang
76
endif
78
endif
77
79
78
# GCC version, for conditional selection of flags.
80
# GCC version, for conditional selection of flags.
79
ifndef GCC_MAJOR
81
ifndef GCC_MAJOR
80
    GCC_MAJOR    := $(shell $(CCFULLPATH) -dumpversion 2>&1 | cut -d'.' -f1)
82
    GCC_MAJOR    := $(shell $(CCFULLPATH) -dumpversion 2>&1 | cut -d'.' -f1)
81
endif
83
endif
82
ifeq ($(GCC_MAJOR),)
84
ifeq ($(GCC_MAJOR),)
83
    GCC_MAJOR    := 4
85
    GCC_MAJOR    := 4
84
endif
86
endif
85
ifndef GCC_MINOR
87
ifndef GCC_MINOR
86
    GCC_MINOR    := $(shell $(CCFULLPATH) -dumpversion 2>&1 | cut -d'.' -f2)
88
    GCC_MINOR    := $(shell $(CCFULLPATH) -dumpversion 2>&1 | cut -d'.' -f2)
87
endif
89
endif
88
ifeq ($(GCC_MINOR),)
90
ifeq ($(GCC_MINOR),)
89
    GCC_MINOR    := 8
91
    GCC_MINOR    := 8
90
endif
92
endif
91
93
92
# Detect machine architecture
94
# Detect machine architecture
93
ifndef SYSARCH
95
ifndef SYSARCH
94
    SYSARCH:=$(strip $(shell uname -m))
96
    SYSARCH:=$(strip $(shell uname -m))
95
endif
97
endif
96
SYSBITS=32
98
SYSBITS=32
97
99
98
# Detect the platform if it wasn't explicitly given to us from
100
# Detect the platform if it wasn't explicitly given to us from
99
# the outside world. This allows cross-compilation by overriding
101
# the outside world. This allows cross-compilation by overriding
100
# CC and giving us PLATFORM specifically.
102
# CC and giving us PLATFORM specifically.
101
#
103
#
102
ifndef HOST
104
ifndef HOST
103
    uname:=$(strip $(shell uname -s))
105
    uname:=$(strip $(shell uname -s))
104
    HOST=UNKNOWN
106
    HOST=UNKNOWN
105
    ifeq ($(findstring Linux,$(uname)),Linux)
107
    ifeq ($(findstring Linux,$(uname)),Linux)
106
        HOST=LINUX
108
        HOST=LINUX
107
    endif
109
    endif
108
    ifeq ($(findstring BSD,$(uname)),BSD)
110
    ifeq ($(findstring BSD,$(uname)),BSD)
109
        HOST=BSD
111
        HOST=BSD
110
    endif
112
    endif
111
    ifeq ($(findstring MINGW,$(uname)),MINGW)
113
    ifeq ($(findstring MINGW,$(uname)),MINGW)
112
        HOST=WINDOWS
114
        HOST=WINDOWS
113
    endif
115
    endif
114
    ifeq ($(findstring Darwin,$(uname)),Darwin)
116
    ifeq ($(findstring Darwin,$(uname)),Darwin)
115
        HOST=DARWIN
117
        HOST=DARWIN
116
    endif
118
    endif
117
    ifeq ($(findstring BeOS,$(uname)),BeOS)
119
    ifeq ($(findstring BeOS,$(uname)),BeOS)
118
        HOST=BEOS
120
        HOST=BEOS
119
    endif
121
    endif
120
    ifeq ($(findstring skyos,$(uname)),skyos)
122
    ifeq ($(findstring skyos,$(uname)),skyos)
121
        HOST=SKYOS
123
        HOST=SKYOS
122
    endif
124
    endif
123
    ifeq ($(findstring QNX,$(uname)),QNX)
125
    ifeq ($(findstring QNX,$(uname)),QNX)
124
        HOST=QNX
126
        HOST=QNX
125
    endif
127
    endif
126
    ifeq ($(findstring SunOS,$(uname)),SunOS)
128
    ifeq ($(findstring SunOS,$(uname)),SunOS)
127
        HOST=SUNOS
129
        HOST=SUNOS
128
    endif
130
    endif
129
    ifeq ($(findstring syllable,$(uname)),syllable)
131
    ifeq ($(findstring syllable,$(uname)),syllable)
130
        HOST=SYLLABLE
132
        HOST=SYLLABLE
131
    endif
133
    endif
132
endif
134
endif
133
ifndef PLATFORM
135
ifndef PLATFORM
134
    PLATFORM=$(HOST)
136
    PLATFORM=$(HOST)
135
endif
137
endif
136
138
137
ifndef SUBPLATFORM
139
ifndef SUBPLATFORM
138
    SUBPLATFORM=
140
    SUBPLATFORM=
139
    ifeq ($(PLATFORM),LINUX)
141
    ifeq ($(PLATFORM),LINUX)
140
        SUBPLATFORM=LINUX
142
        SUBPLATFORM=LINUX
141
    endif
143
    endif
142
    ifeq ($(PLATFORM),DINGOO)
144
    ifeq ($(PLATFORM),DINGOO)
143
        SUBPLATFORM=LINUX
145
        SUBPLATFORM=LINUX
144
        CROSS=mipsel-linux-
146
        CROSS=mipsel-linux-
145
    endif
147
    endif
146
    ifeq ($(PLATFORM),GCW)
148
    ifeq ($(PLATFORM),GCW)
147
        SUBPLATFORM=LINUX
149
        SUBPLATFORM=LINUX
148
        CROSS=mipsel-linux-
150
        CROSS=mipsel-linux-
149
    endif
151
    endif
150
    ifeq ($(PLATFORM),CAANOO)
152
    ifeq ($(PLATFORM),CAANOO)
151
        SUBPLATFORM=LINUX
153
        SUBPLATFORM=LINUX
152
    endif
154
    endif
153
endif
155
endif
154
156
155
# Binary suffix override:
157
# Binary suffix override:
156
EXESUFFIX_OVERRIDE ?=
158
EXESUFFIX_OVERRIDE ?=
157
159
158
# Are we running from synthesis?
160
# Are we running from synthesis?
159
SYNTHESIS ?= 0
161
SYNTHESIS ?= 0
160
162
161
# Mac OS X Frameworks location
163
# Mac OS X Frameworks location
162
# Like above, use absolute paths.
164
# Like above, use absolute paths.
163
APPLE_FRAMEWORKS ?=/Library/Frameworks
165
APPLE_FRAMEWORKS ?=/Library/Frameworks
164
# Without the resource files packaged in the .app bundle, the startupwindow produces errors, so give it an off switch.
166
# Without the resource files packaged in the .app bundle, the startupwindow produces errors, so give it an off switch.
165
OSX_STARTUPWINDOW ?= 1
167
OSX_STARTUPWINDOW ?= 1
166
168
167
# Engine options
169
# Engine options
168
#  USE_OPENGL     - enables basic OpenGL Polymost renderer
170
#  USE_OPENGL     - enables basic OpenGL Polymost renderer
169
#  POLYMER        - enables fancy Polymer renderer
171
#  POLYMER        - enables fancy Polymer renderer
170
#  NOASM          - disables the use of inline assembly pragmas
172
#  NOASM          - disables the use of inline assembly pragmas
171
#  LINKED_GTK     - enables compile-time linkage to GTK
173
#  LINKED_GTK     - enables compile-time linkage to GTK
172
#
174
#
173
POLYMER = 1
175
POLYMER = 1
174
USE_OPENGL = 1
176
USE_OPENGL = 1
175
NOASM = 0
177
NOASM = 0
176
LINKED_GTK = 0
178
LINKED_GTK = 0
177
BUILD32_ON_64 ?= 0
179
BUILD32_ON_64 ?= 0
178
USE_LIBPNG ?= 1
180
USE_LIBPNG ?= 1
179
USE_LIBVPX ?= 1
181
USE_LIBVPX ?= 1
180
HAVE_VORBIS ?= 1
182
HAVE_VORBIS ?= 1
181
HAVE_FLAC ?= 1
183
HAVE_FLAC ?= 1
182
NETCODE ?= 1
184
NETCODE ?= 1
183
185
184
LUNATIC ?= 0
186
LUNATIC ?= 0
185
USE_LUAJIT_2_1 ?= 0
187
USE_LUAJIT_2_1 ?= 0
186
188
187
# EXPERIMENTAL, unfinished x86_64 assembly routines. DO NOT ENABLE.
189
# EXPERIMENTAL, unfinished x86_64 assembly routines. DO NOT ENABLE.
188
USE_ASM64 ?= 0
190
USE_ASM64 ?= 0
189
191
190
ifeq (0,$(USE_OPENGL))
192
ifeq (0,$(USE_OPENGL))
191
    POLYMER = 0
193
    POLYMER = 0
192
    USE_LIBVPX = 0
194
    USE_LIBVPX = 0
193
endif
195
endif
194
196
195
# Debugging/Build options
197
# Debugging/Build options
196
#  CPLUSPLUS - 1 = enable C++ building
198
#  CPLUSPLUS - 1 = enable C++ building
197
#  RELEASE - 1 = no debugging
199
#  RELEASE - 1 = no debugging
198
#  DEBUGANYWAY:
200
#  DEBUGANYWAY:
199
#    1 = Include debug symbols even when generating release code.
201
#    1 = Include debug symbols even when generating release code.
200
#    2 = Also enable sanitizers with Clang. On the C side, make 'sprite' etc. be real arrays.
202
#    2 = Also enable sanitizers with Clang. On the C side, make 'sprite' etc. be real arrays.
201
#  DISABLEINLINING - 1 = compile inline functions as extern __fastcall instead of static inline
203
#  DISABLEINLINING - 1 = compile inline functions as extern __fastcall instead of static inline
202
#  KRANDDEBUG - 1 = include logging of krand() calls for debugging the demo system
204
#  KRANDDEBUG - 1 = include logging of krand() calls for debugging the demo system
203
#  MEMMAP - 1 = produce .memmap file when linking
205
#  MEMMAP - 1 = produce .memmap file when linking
204
#  EFENCE  - 1 = compile with Electric Fence for malloc() debugging
206
#  EFENCE  - 1 = compile with Electric Fence for malloc() debugging
205
#  OPTLEVEL	- 0..3 = GCC optimization strategy
207
#  OPTLEVEL	- 0..3 = GCC optimization strategy
206
#  LTO - 1 = enable link-time optimization, for GCC 4.5 and up
208
#  LTO - 1 = enable link-time optimization, for GCC 4.5 and up
207
#
209
#
208
CPLUSPLUS?=1
210
CPLUSPLUS?=1
209
RELEASE?=1
211
RELEASE?=1
210
DEBUGANYWAY?=0
212
DEBUGANYWAY?=0
211
KRANDDEBUG?=0
213
KRANDDEBUG?=0
212
MEMMAP?=0
214
MEMMAP?=0
213
DISABLEINLINING?=0
215
DISABLEINLINING?=0
214
EFENCE?=0
216
EFENCE?=0
215
DMALLOC?=0
217
DMALLOC?=0
216
PROFILER?=0
218
PROFILER?=0
217
MUDFLAP?=0
219
MUDFLAP?=0
218
220
219
# Make allocache() a wrapper around malloc()? Useful for debugging
221
# Make allocache() a wrapper around malloc()? Useful for debugging
220
# allocache()-allocated memory accesses with e.g. Valgrind.
222
# allocache()-allocated memory accesses with e.g. Valgrind.
221
# For debugging with Valgrind + GDB, see
223
# For debugging with Valgrind + GDB, see
222
# http://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.gdbserver
224
# http://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.gdbserver
223
ALLOCACHE_AS_MALLOC?=0
225
ALLOCACHE_AS_MALLOC?=0
224
226
225
# Select the default optimization level for release and debug builds.
227
# Select the default optimization level for release and debug builds.
226
ifeq ($(RELEASE),0)
228
ifeq ($(RELEASE),0)
227
    OPTLEVEL?=0
229
    OPTLEVEL?=0
228
else
230
else
229
    OPTLEVEL?=2
231
    OPTLEVEL?=2
230
endif
232
endif
231
233
232
ifeq ($(RELEASE),0)
234
ifeq ($(RELEASE),0)
233
    override STRIP=
235
    override STRIP=
234
endif
236
endif
235
ifneq ($(DEBUGANYWAY),0)
237
ifneq ($(DEBUGANYWAY),0)
236
    override STRIP=
238
    override STRIP=
237
endif
239
endif
238
240
239
ifneq ($(LUNATIC),0)
241
ifneq ($(LUNATIC),0)
240
    # FIXME: Lunatic builds with LTO don't start up properly as the required
242
    # FIXME: Lunatic builds with LTO don't start up properly as the required
241
    # symbol names are apparently not exported.
243
    # symbol names are apparently not exported.
242
    override LTO=0
244
    override LTO=0
243
endif
245
endif
244
246
245
ifndef LTO
247
ifndef LTO
246
    LTO=1
248
    LTO=1
247
    ifneq (0,$(CLANG))
249
    ifneq (0,$(CLANG))
248
        ifeq ($(PLATFORM), WINDOWS)
250
        ifeq ($(PLATFORM), WINDOWS)
249
            LTO=0
251
            LTO=0
250
        endif
252
        endif
251
    endif
253
    endif
252
endif
254
endif
253
255
254
COMMONFLAGS=$(ARCH)
256
COMMONFLAGS=$(ARCH)
255
COMPILERFLAGS=
257
COMPILERFLAGS=
256
258
257
ifeq ($(PACKAGE_REPOSITORY),0)
259
ifeq ($(PACKAGE_REPOSITORY),0)
258
    COMMONFLAGS += $(OPTIMIZATIONS)
260
    COMMONFLAGS += $(OPTIMIZATIONS)
259
endif
261
endif
260
262
261
OPTIMIZATIONS=-O$(OPTLEVEL) $(OPTOPT)
263
OPTIMIZATIONS=-O$(OPTLEVEL) $(OPTOPT)
262
264
263
DEBUGFLAG=-g
265
DEBUGFLAG=-g
264
ifeq (0,$(CLANG))
266
ifeq (0,$(CLANG))
265
    ifneq ($(PLATFORM),WII)
267
    ifneq ($(PLATFORM),WII)
266
        DEBUGFLAG=-ggdb -fno-omit-frame-pointer
268
        DEBUGFLAG=-ggdb -fno-omit-frame-pointer
267
    endif
269
    endif
268
endif
270
endif
269
ifneq ($(RELEASE)$(DEBUGANYWAY),10)
271
ifneq ($(RELEASE)$(DEBUGANYWAY),10)
270
    # debug build or DEBUGANYWAY=1 --> -g flag
272
    # debug build or DEBUGANYWAY=1 --> -g flag
271
    OPTIMIZATIONS += $(DEBUGFLAG)
273
    OPTIMIZATIONS += $(DEBUGFLAG)
272
endif
274
endif
273
275
274
CONLYFLAGS=-std=gnu99 -Wimplicit -Werror-implicit-function-declaration
276
CONLYFLAGS=-std=gnu99 -Wimplicit -Werror-implicit-function-declaration
275
CPPONLYFLAGS= -fno-exceptions -fno-rtti -Wno-write-strings
277
CPPONLYFLAGS= -fno-exceptions -fno-rtti -Wno-write-strings
276
ASFORMAT=elf$(SYSBITS)
278
ASFORMAT=elf$(SYSBITS)
277
ASFLAGS=-s -f $(ASFORMAT) #-g
279
ASFLAGS=-s -f $(ASFORMAT) #-g
278
LINKERFLAGS=
280
LINKERFLAGS=
279
LIBS=-lm
281
LIBS=-lm
280
LIBDIRS=
282
LIBDIRS=
281
283
282
ifeq (1,$(strip $(shell expr $(GCC_MAJOR) \>= 4)))
284
ifeq (1,$(strip $(shell expr $(GCC_MAJOR) \>= 4)))
283
    F_NO_STACK_PROTECTOR := -fno-stack-protector
285
    F_NO_STACK_PROTECTOR := -fno-stack-protector
284
    # there are some link-time issues with stack protectors, so make it possible to override
286
    # there are some link-time issues with stack protectors, so make it possible to override
285
    F_STACK_PROTECTOR_ALL ?= -fstack-protector-all
287
    F_STACK_PROTECTOR_ALL ?= -fstack-protector-all
286
    ifeq (0,$(CLANG))
288
    ifeq (0,$(CLANG))
287
        F_JUMP_TABLES := -fjump-tables
289
        F_JUMP_TABLES := -fjump-tables
288
    endif
290
    endif
289
    M_TUNE_GENERIC := -mtune=generic
291
    M_TUNE_GENERIC := -mtune=generic
290
    M_STACKREALIGN := -mstackrealign
292
    M_STACKREALIGN := -mstackrealign
291
    W_STRICT_OVERFLOW := -Wno-strict-overflow
293
    W_STRICT_OVERFLOW := -Wno-strict-overflow
292
endif
294
endif
293
295
294
ifeq ($(HOST),WINDOWS)
296
ifeq ($(HOST),WINDOWS)
295
    DONT_PRINT = > NUL 2>&1
297
    DONT_PRINT = > NUL 2>&1
296
endif
298
endif
297
299
298
ifeq ($(PLATFORM),WINDOWS)
300
ifeq ($(PLATFORM),WINDOWS)
299
    ifndef COMPILERTARGET
301
    ifndef COMPILERTARGET
300
        COMPILERTARGET:=$(strip $(shell $(CC) -dumpmachine))
302
        COMPILERTARGET:=$(strip $(shell $(CC) -dumpmachine))
301
    endif
303
    endif
302
304
303
    ifeq ($(findstring x86_64,$(COMPILERTARGET)),x86_64)
305
    ifeq ($(findstring x86_64,$(COMPILERTARGET)),x86_64)
304
        SYSARCH:=x86_64
306
        SYSARCH:=x86_64
305
        SYSBITS=64
307
        SYSBITS=64
306
    endif
308
    endif
307
309
308
    WINLIB?=/$(SYSBITS)
310
    WINLIB?=/$(SYSBITS)
309
else
311
else
310
ifneq (1,$(BUILD32_ON_64))
312
ifneq (1,$(BUILD32_ON_64))
311
    ifeq ($(findstring x86_64,$(ARCH)),x86_64)
313
    ifeq ($(findstring x86_64,$(ARCH)),x86_64)
312
        SYSBITS=64
314
        SYSBITS=64
313
    endif
315
    endif
314
    ifeq ($(ARCH),)
316
    ifeq ($(ARCH),)
315
        ifeq ($(findstring x86_64,$(SYSARCH)),x86_64)
317
        ifeq ($(findstring x86_64,$(SYSARCH)),x86_64)
316
            SYSBITS=64
318
            SYSBITS=64
317
        endif
319
        endif
318
    endif
320
    endif
319
endif
321
endif
320
endif
322
endif
321
323
322
ifeq ($(PLATFORM),DARWIN)
324
ifeq ($(PLATFORM),DARWIN)
323
    ifndef DARWINVERSION
325
    ifndef DARWINVERSION
324
        DARWINVERSION:=$(strip $(shell uname -r | cut -d . -f 1))
326
        DARWINVERSION:=$(strip $(shell uname -r | cut -d . -f 1))
325
    endif
327
    endif
326
328
327
	DARWIN9 ?= 0
329
	DARWIN9 ?= 0
328
	DARWIN10 ?= 0
330
	DARWIN10 ?= 0
329
    ifeq (1,$(strip $(shell expr $(DARWINVERSION) \< 10)))
331
    ifeq (1,$(strip $(shell expr $(DARWINVERSION) \< 10)))
330
        override DARWIN9 := 1
332
        override DARWIN9 := 1
331
    endif
333
    endif
332
    ifeq (1,$(strip $(shell expr $(DARWINVERSION) \< 11)))
334
    ifeq (1,$(strip $(shell expr $(DARWINVERSION) \< 11)))
333
        override DARWIN10 := 1
335
        override DARWIN10 := 1
334
    endif
336
    endif
335
337
336
#    COMMONFLAGS    += -fno-leading-underscore
338
#    COMMONFLAGS    += -fno-leading-underscore
337
339
338
    ifeq (1,$(DARWIN9))
340
    ifeq (1,$(DARWIN9))
339
        F_JUMP_TABLES :=
341
        F_JUMP_TABLES :=
340
        W_STRICT_OVERFLOW :=
342
        W_STRICT_OVERFLOW :=
341
    endif
343
    endif
342
344
343
    ifeq (1,$(BUILD32_ON_64))
345
    ifeq (1,$(BUILD32_ON_64))
344
        COMMONFLAGS += $(F_NO_STACK_PROTECTOR)
346
        COMMONFLAGS += $(F_NO_STACK_PROTECTOR)
345
    else
347
    else
346
        ifeq ($(findstring ppc,$(ARCH)),ppc)
348
        ifeq ($(findstring ppc,$(ARCH)),ppc)
347
            COMMONFLAGS += $(F_NO_STACK_PROTECTOR)
349
            COMMONFLAGS += $(F_NO_STACK_PROTECTOR)
348
        endif
350
        endif
349
    endif
351
    endif
350
    ifneq (0,$(OSX_STARTUPWINDOW))
352
    ifneq (0,$(OSX_STARTUPWINDOW))
351
        COMPILERFLAGS+= -DOSX_STARTUPWINDOW
353
        COMPILERFLAGS+= -DOSX_STARTUPWINDOW
352
    endif
354
    endif
353
endif
355
endif
354
356
355
357
356
ifneq (0,$(RELEASE))
358
ifneq (0,$(RELEASE))
357
    # Debugging disabled
359
    # Debugging disabled
358
    COMMONFLAGS += $(F_NO_STACK_PROTECTOR)
360
    COMMONFLAGS += $(F_NO_STACK_PROTECTOR)
359
else
361
else
360
    # Debugging enabled
362
    # Debugging enabled
361
    ifneq (0,$(KRANDDEBUG))
363
    ifneq (0,$(KRANDDEBUG))
362
        COMMONFLAGS += -fno-inline -fno-inline-functions -fno-inline-functions-called-once
364
        COMMONFLAGS += -fno-inline -fno-inline-functions -fno-inline-functions-called-once
363
    endif
365
    endif
364
    ifeq (1,$(SDL_TARGET))
366
    ifeq (1,$(SDL_TARGET))
365
        COMPILERFLAGS += -DNOSDLPARACHUTE
367
        COMPILERFLAGS += -DNOSDLPARACHUTE
366
    endif
368
    endif
367
endif
369
endif
368
370
369
ifndef OPTOPT
371
ifndef OPTOPT
370
    ifeq ($(PLATFORM), WII)
372
    ifeq ($(PLATFORM), WII)
371
        OPTOPT=
373
        OPTOPT=
372
    else
374
    else
373
        OPTOPTARCH=$(ARCH)
375
        OPTOPTARCH=$(ARCH)
374
        ifeq (,$(OPTOPTARCH))
376
        ifeq (,$(OPTOPTARCH))
375
            OPTOPTARCH=$(SYSARCH)
377
            OPTOPTARCH=$(SYSARCH)
376
        endif
378
        endif
377
379
378
        ifeq (i686,$(findstring i686, $(OPTOPTARCH)))
380
        ifeq (i686,$(findstring i686, $(OPTOPTARCH)))
379
            OPTOPT=-march=pentium3 $(M_TUNE_GENERIC) -mmmx
381
            OPTOPT=-march=pentium3 $(M_TUNE_GENERIC) -mmmx
380
            # -msse2 -mfpmath=sse,387 -malign-double $(M_STACKREALIGN)
382
            # -msse2 -mfpmath=sse,387 -malign-double $(M_STACKREALIGN)
381
        else
383
        else
382
            OPTOPT=
384
            OPTOPT=
383
        endif
385
        endif
384
    endif
386
    endif
385
endif
387
endif
386
388
387
ifneq (0,$(KRANDDEBUG))
389
ifneq (0,$(KRANDDEBUG))
388
    RELEASE=0
390
    RELEASE=0
389
endif
391
endif
390
ifneq (0,$(PROFILER))
392
ifneq (0,$(PROFILER))
391
    # XXX: Why?
393
    # XXX: Why?
392
    DEBUGANYWAY=1
394
    DEBUGANYWAY=1
393
endif
395
endif
394
396
395
397
396
398
397
399
398
ifeq (1,$(strip $(shell expr $(GCC_MAJOR) \>= 4)))
400
ifeq (1,$(strip $(shell expr $(GCC_MAJOR) \>= 4)))
399
    ifeq (1,$(strip $(shell expr $(GCC_MINOR) \>= 1)))
401
    ifeq (1,$(strip $(shell expr $(GCC_MINOR) \>= 1)))
400
        COMPILERFLAGS+= -Wno-attributes
402
        COMPILERFLAGS+= -Wno-attributes
401
    endif
403
    endif
402
endif
404
endif
403
405
404
ifeq ($(PLATFORM),WII)
406
ifeq ($(PLATFORM),WII)
405
    override USE_LIBVPX = 0
407
    override USE_LIBVPX = 0
406
    override NETCODE = 0
408
    override NETCODE = 0
407
    override HAVE_FLAC = 0
409
    override HAVE_FLAC = 0
408
endif
410
endif
409
ifeq ($(PLATFORM),GCW)
411
ifeq ($(PLATFORM),GCW)
410
    override USE_LIBVPX = 0
412
    override USE_LIBVPX = 0
411
endif
413
endif
412
ifeq ($(PLATFORM),DINGOO)
414
ifeq ($(PLATFORM),DINGOO)
413
    override USE_LIBVPX = 0
415
    override USE_LIBVPX = 0
414
endif
416
endif
415
417
416
ifneq (0,$(USE_LIBVPX))
418
ifneq (0,$(USE_LIBVPX))
417
    # On Windows, we link statically to libvpx
419
    # On Windows, we link statically to libvpx
418
    LIBS+= -lvpx
420
    LIBS+= -lvpx
419
endif
421
endif
420
422
421
423
422
ifneq ($(ALLOCACHE_AS_MALLOC),0)
424
ifneq ($(ALLOCACHE_AS_MALLOC),0)
423
    COMPILERFLAGS += -DDEBUG_ALLOCACHE_AS_MALLOC
425
    COMPILERFLAGS += -DDEBUG_ALLOCACHE_AS_MALLOC
424
endif
426
endif
425
427
426
# See http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation
428
# See http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation
427
# for a list of possible UBSan options.
429
# for a list of possible UBSan options.
428
# Clang 3.2 does only supports -fsanitize=address for the AddressSanitizer
430
# Clang 3.2 does only supports -fsanitize=address for the AddressSanitizer
429
CLANG_DEBUG_FLAGS := -fsanitize=address -fsanitize=bounds,enum,float-cast-overflow,object-size
431
CLANG_DEBUG_FLAGS := -fsanitize=address -fsanitize=bounds,enum,float-cast-overflow,object-size
430
#CLANG_DEBUG_FLAGS := $(CLANG_DEBUG_FLAGS),signed-integer-overflow
432
#CLANG_DEBUG_FLAGS := $(CLANG_DEBUG_FLAGS),signed-integer-overflow
431
#CLANG_DEBUG_FLAGS := $(CLANG_DEBUG_FLAGS),unsigned-integer-overflow
433
#CLANG_DEBUG_FLAGS := $(CLANG_DEBUG_FLAGS),unsigned-integer-overflow
432
#CLANG_DEBUG_FLAGS := $(CLANG_DEBUG_FLAGS) -fsanitize-undefined-trap-on-error
434
#CLANG_DEBUG_FLAGS := $(CLANG_DEBUG_FLAGS) -fsanitize-undefined-trap-on-error
433
435
434
ifneq (0,$(RELEASE))
436
ifneq (0,$(RELEASE))
435
    ## Debugging disabled
437
    ## Debugging disabled
436
438
437
    ifeq (0,$(CLANG))
439
    ifeq (0,$(CLANG))
438
        COMMONFLAGS += -funswitch-loops
440
        COMMONFLAGS += -funswitch-loops
439
        ifeq (1,$(strip $(shell expr $(GCC_MAJOR) \< 4)))
441
        ifeq (1,$(strip $(shell expr $(GCC_MAJOR) \< 4)))
440
            override LTO=0
442
            override LTO=0
441
        endif
443
        endif
442
        ifeq (1,$(strip $(shell expr $(GCC_MAJOR) = 4)))
444
        ifeq (1,$(strip $(shell expr $(GCC_MAJOR) = 4)))
443
            ifeq ($(PLATFORM),WII)
445
            ifeq ($(PLATFORM),WII)
444
                ifeq (1,$(strip $(shell expr $(GCC_MINOR) \< 8)))
446
                ifeq (1,$(strip $(shell expr $(GCC_MINOR) \< 8)))
445
                    override LTO=0
447
                    override LTO=0
446
                endif
448
                endif
447
            else
449
            else
448
                ifeq (1,$(strip $(shell expr $(GCC_MINOR) \< 6)))
450
                ifeq (1,$(strip $(shell expr $(GCC_MINOR) \< 6)))
449
                    override LTO=0
451
                    override LTO=0
450
                endif
452
                endif
451
            endif
453
            endif
452
        endif
454
        endif
453
    endif
455
    endif
454
456
455
    ifeq (0,$(DEBUGANYWAY))
457
    ifeq (0,$(DEBUGANYWAY))
456
        COMMONFLAGS += -fomit-frame-pointer
458
        COMMONFLAGS += -fomit-frame-pointer
457
        COMPILERFLAGS += -DNDEBUG
459
        COMPILERFLAGS += -DNDEBUG
458
    else
460
    else
459
        # Our $(DEBUGANYWAY) -> DEBUGGINGAIDS #define
461
        # Our $(DEBUGANYWAY) -> DEBUGGINGAIDS #define
460
        COMPILERFLAGS += -DDEBUGGINGAIDS=$(DEBUGANYWAY)
462
        COMPILERFLAGS += -DDEBUGGINGAIDS=$(DEBUGANYWAY)
461
        ifneq (0,$(CLANG))
463
        ifneq (0,$(CLANG))
462
            ifeq (2,$(DEBUGANYWAY))
464
            ifeq (2,$(DEBUGANYWAY))
463
                COMMONFLAGS += $(CLANG_DEBUG_FLAGS)
465
                COMMONFLAGS += $(CLANG_DEBUG_FLAGS)
464
            endif
466
            endif
465
        endif
467
        endif
466
    endif
468
    endif
467
469
468
    ifneq (0,$(LTO))
470
    ifneq (0,$(LTO))
469
        COMPILERFLAGS += -DUSING_LTO
471
        COMPILERFLAGS += -DUSING_LTO
470
        COMMONFLAGS += -flto
472
        COMMONFLAGS += -flto
471
    endif
473
    endif
472
else
474
else
473
    ## Debugging enabled
475
    ## Debugging enabled
474
476
475
    # Our $(DEBUGANYWAY) -> DEBUGGINGAIDS #define
477
    # Our $(DEBUGANYWAY) -> DEBUGGINGAIDS #define
476
    COMPILERFLAGS += -DDEBUGGINGAIDS=$(DEBUGANYWAY)
478
    COMPILERFLAGS += -DDEBUGGINGAIDS=$(DEBUGANYWAY)
477
    ifneq (0,$(CLANG))
479
    ifneq (0,$(CLANG))
478
        ifeq (2,$(DEBUGANYWAY))
480
        ifeq (2,$(DEBUGANYWAY))
479
            COMMONFLAGS += $(CLANG_DEBUG_FLAGS)
481
            COMMONFLAGS += $(CLANG_DEBUG_FLAGS)
480
        endif
482
        endif
481
    endif
483
    endif
482
484
483
    ifeq ($(SUBPLATFORM),LINUX)
485
    ifeq ($(SUBPLATFORM),LINUX)
484
        LIBS+=-rdynamic
486
        LIBS+=-rdynamic
485
    endif
487
    endif
486
488
487
    ifneq (0,$(MUDFLAP))
489
    ifneq (0,$(MUDFLAP))
488
        LIBS+= -lmudflapth
490
        LIBS+= -lmudflapth
489
        COMMONFLAGS += -fmudflapth
491
        COMMONFLAGS += -fmudflapth
490
    endif
492
    endif
491
    ifneq (0,$(PROFILER))
493
    ifneq (0,$(PROFILER))
492
        ifneq ($(PLATFORM),DARWIN)
494
        ifneq ($(PLATFORM),DARWIN)
493
            LIBS+= -lprofiler
495
            LIBS+= -lprofiler
494
        endif
496
        endif
495
        COMMONFLAGS += -pg
497
        COMMONFLAGS += -pg
496
    endif
498
    endif
497
    ifneq (0,$(KRANDDEBUG))
499
    ifneq (0,$(KRANDDEBUG))
498
        COMPILERFLAGS += -DKRANDDEBUG=1
500
        COMPILERFLAGS += -DKRANDDEBUG=1
499
    endif
501
    endif
500
endif
502
endif
501
503
502
W_NO_UNUSED_RESULT :=
504
W_NO_UNUSED_RESULT :=
503
ifeq (0,$(CLANG))
505
ifeq (0,$(CLANG))
504
#    W_NO_UNUSED_RESULT := $(shell echo '' | $(CC) -E -Wno-unused-result - 2>/dev/null && echo -Wno-unused-result)
506
#    W_NO_UNUSED_RESULT := $(shell echo '' | $(CC) -E -Wno-unused-result - 2>/dev/null && echo -Wno-unused-result)
505
#    W_NO_UNUSED_RESULT := $(findstring -Wno-unused-result,$(W_NO_UNUSED_RESULT))
507
#    W_NO_UNUSED_RESULT := $(findstring -Wno-unused-result,$(W_NO_UNUSED_RESULT))
506
    ifeq (1,$(strip $(shell expr $(GCC_MAJOR) \>= 4)))
508
    ifeq (1,$(strip $(shell expr $(GCC_MAJOR) \>= 4)))
507
        ifeq (1,$(strip $(shell expr $(GCC_MINOR) \>= 4)))
509
        ifeq (1,$(strip $(shell expr $(GCC_MINOR) \>= 4)))
508
            W_NO_UNUSED_RESULT := -Wno-unused-result
510
            W_NO_UNUSED_RESULT := -Wno-unused-result
509
        endif
511
        endif
510
    endif
512
    endif
511
endif
513
endif
512
514
513
CWARNS := -W -Wall \
515
CWARNS := -W -Wall \
514
    -Wpointer-arith \
516
    -Wpointer-arith \
515
    -Wextra \
517
    -Wextra \
516
    -Wno-char-subscripts \
518
    -Wno-char-subscripts \
517
    #-Wstrict-prototypes \
519
    #-Wstrict-prototypes \
518
    #-Waggregate-return \
520
    #-Waggregate-return \
519
    #-Wwrite-strings \
521
    #-Wwrite-strings \
520
    #-Wcast-qual -Wcast-align \
522
    #-Wcast-qual -Wcast-align \
521
    #-Waddress -Wlogical-op
523
    #-Waddress -Wlogical-op
522
524
523
ifneq (0,$(CLANG))
525
ifneq (0,$(CLANG))
524
    CWARNS+= -Wno-unused-value -Wno-parentheses
526
    CWARNS+= -Wno-unused-value -Wno-parentheses
525
endif
527
endif
526
528
527
COMMONFLAGS+= -funsigned-char -fno-strict-aliasing $(F_JUMP_TABLES)
529
COMMONFLAGS+= -funsigned-char -fno-strict-aliasing $(F_JUMP_TABLES)
528
530
529
COMPILERFLAGS+= $(CWARNS) $(W_NO_UNUSED_RESULT) -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
531
COMPILERFLAGS+= $(CWARNS) $(W_NO_UNUSED_RESULT) -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
530
532
531
ifeq (0,$(NETCODE))
533
ifeq (0,$(NETCODE))
532
    COMPILERFLAGS+= -DNETCODE_DISABLE
534
    COMPILERFLAGS+= -DNETCODE_DISABLE
533
endif
535
endif
534
536
535
537
536
#### Lunatic development
538
#### Lunatic development
537
# LuaJIT standalone interpreter executable:
539
# LuaJIT standalone interpreter executable:
538
LUAJIT:=luajit
540
LUAJIT:=luajit
539
# Options to "luajit -b" for synthesis. Since it runs on Linux, we need to tell
541
# Options to "luajit -b" for synthesis. Since it runs on Linux, we need to tell
540
# the native LuaJIT to emit PE object files.
542
# the native LuaJIT to emit PE object files.
541
ifeq ($(PLATFORM),WINDOWS)
543
ifeq ($(PLATFORM),WINDOWS)
542
    LUAJIT_BCOPTS := -o windows
544
    LUAJIT_BCOPTS := -o windows
543
    ifeq (32,$(SYSBITS))
545
    ifeq (32,$(SYSBITS))
544
        LUAJIT_BCOPTS += -a x86
546
        LUAJIT_BCOPTS += -a x86
545
    endif
547
    endif
546
    ifeq (64,$(SYSBITS))
548
    ifeq (64,$(SYSBITS))
547
        LUAJIT_BCOPTS += -a x64
549
        LUAJIT_BCOPTS += -a x64
548
    endif
550
    endif
549
endif
551
endif
550
552
551
ifneq ($(LUNATIC),0)
553
ifneq ($(LUNATIC),0)
552
    # FIXME: Lunatic doesn't build with inlining because of wacky include
554
    # FIXME: Lunatic doesn't build with inlining because of wacky include
553
    # chains!
555
    # chains!
554
    override DISABLEINLINING=1
556
    override DISABLEINLINING=1
555
557
556
    ifneq ($(CPLUSPLUS),0)
558
    ifneq ($(CPLUSPLUS),0)
557
        # FIXME: Lunatic C++ doesn't build because otherwise it doesn't find
559
        # FIXME: Lunatic C++ doesn't build because otherwise it doesn't find
558
        # INT32_MIN and the like.
560
        # INT32_MIN and the like.
559
        COMPILERFLAGS+= -D__STDC_LIMIT_MACROS
561
        COMPILERFLAGS+= -D__STDC_LIMIT_MACROS
560
    endif
562
    endif
561
563
562
    COMPILERFLAGS+= -Isource/lunatic -DLUNATIC
564
    COMPILERFLAGS+= -Isource/lunatic -DLUNATIC
563
    ifneq ($(USE_LUAJIT_2_1),0)
565
    ifneq ($(USE_LUAJIT_2_1),0)
564
        COMPILERFLAGS+= -DUSE_LUAJIT_2_1
566
        COMPILERFLAGS+= -DUSE_LUAJIT_2_1
565
    endif
567
    endif
566
568
567
    # Determine size of defs.ilua bytecode once.
569
    # Determine size of defs.ilua bytecode once.
568
    ifndef DEFS_BC_SIZE
570
    ifndef DEFS_BC_SIZE
569
        DEFS_BC_SIZE := $(shell $(LUAJIT) -bg -t h source/lunatic/defs.ilua -)
571
        DEFS_BC_SIZE := $(shell $(LUAJIT) -bg -t h source/lunatic/defs.ilua -)
570
        DEFS_BC_SIZE := $(word 3, $(DEFS_BC_SIZE))
572
        DEFS_BC_SIZE := $(word 3, $(DEFS_BC_SIZE))
571
        # Pass it to the sub-makes, too.
573
        # Pass it to the sub-makes, too.
572
        export DEFS_BC_SIZE
574
        export DEFS_BC_SIZE
573
    endif
575
    endif
574
    # Determine size of defs_m32.ilua bytecode once.
576
    # Determine size of defs_m32.ilua bytecode once.
575
    ifndef DEFS_M32_BC_SIZE
577
    ifndef DEFS_M32_BC_SIZE
576
        DEFS_M32_BC_SIZE := $(shell $(LUAJIT) -bg -t h source/lunatic/defs_m32.ilua -)
578
        DEFS_M32_BC_SIZE := $(shell $(LUAJIT) -bg -t h source/lunatic/defs_m32.ilua -)
577
        DEFS_M32_BC_SIZE := $(word 3, $(DEFS_M32_BC_SIZE))
579
        DEFS_M32_BC_SIZE := $(word 3, $(DEFS_M32_BC_SIZE))
578
        export DEFS_M32_BC_SIZE
580
        export DEFS_M32_BC_SIZE
579
    endif
581
    endif
580
    COMPILERFLAGS+= -DLUNATIC_DEFS_BC_SIZE=$(DEFS_BC_SIZE) -DLUNATIC_DEFS_M32_BC_SIZE=$(DEFS_M32_BC_SIZE)
582
    COMPILERFLAGS+= -DLUNATIC_DEFS_BC_SIZE=$(DEFS_BC_SIZE) -DLUNATIC_DEFS_M32_BC_SIZE=$(DEFS_M32_BC_SIZE)
581
583
582
    ifeq ($(PLATFORM),WINDOWS)
584
    ifeq ($(PLATFORM),WINDOWS)
583
        LIBS+= -lluajit
585
        LIBS+= -lluajit
584
    else
586
    else
585
        LIBS+= -lluajit-5.1
587
        LIBS+= -lluajit-5.1
586
    endif
588
    endif
587
endif
589
endif
588
590
589
####
591
####
590
592
591
ifneq (0,$(DISABLEINLINING))
593
ifneq (0,$(DISABLEINLINING))
592
    COMPILERFLAGS+= -DDISABLE_INLINING
594
    COMPILERFLAGS+= -DDISABLE_INLINING
593
endif
595
endif
594
596
595
# This should come from the environment:
597
# This should come from the environment:
596
ifdef EDUKE32_MY_DEVELOPER_ID
598
ifdef EDUKE32_MY_DEVELOPER_ID
597
    COMPILERFLAGS+= -DMY_DEVELOPER_ID=$(EDUKE32_MY_DEVELOPER_ID)
599
    COMPILERFLAGS+= -DMY_DEVELOPER_ID=$(EDUKE32_MY_DEVELOPER_ID)
598
endif
600
endif
599
601
600
ifneq (0,$(USE_LIBPNG))
602
ifneq (0,$(USE_LIBPNG))
601
    COMPILERFLAGS+= -DUSE_LIBPNG
603
    COMPILERFLAGS+= -DUSE_LIBPNG
602
endif
604
endif
603
ifneq (0,$(USE_LIBVPX))
605
ifneq (0,$(USE_LIBVPX))
604
    COMPILERFLAGS+= -DUSE_LIBVPX
606
    COMPILERFLAGS+= -DUSE_LIBVPX
605
endif
607
endif
606
608
607
ifneq (0,$(HAVE_VORBIS))
609
ifneq (0,$(HAVE_VORBIS))
608
    COMPILERFLAGS+= -DHAVE_VORBIS
610
    COMPILERFLAGS+= -DHAVE_VORBIS
609
endif
611
endif
610
ifneq (0,$(HAVE_FLAC))
612
ifneq (0,$(HAVE_FLAC))
611
    COMPILERFLAGS+= -DHAVE_FLAC
613
    COMPILERFLAGS+= -DHAVE_FLAC
612
endif
614
endif
613
ifneq (0,$(EFENCE))
615
ifneq (0,$(EFENCE))
614
    LIBS+= -lefence
616
    LIBS+= -lefence
615
    COMPILERFLAGS+= -DEFENCE
617
    COMPILERFLAGS+= -DEFENCE
616
endif
618
endif
617
ifneq (0,$(DMALLOC))
619
ifneq (0,$(DMALLOC))
618
    LIBS+= -ldmalloc
620
    LIBS+= -ldmalloc
619
    COMPILERFLAGS+= -DDMALLOC
621
    COMPILERFLAGS+= -DDMALLOC
620
endif
622
endif
621
623
622
# may be overridden
624
# may be overridden
623
EXESUFFIX=
625
EXESUFFIX=
624
DLLSUFFIX=.so
626
DLLSUFFIX=.so
625
627
626
628
627
SDL_TARGET ?= 2
629
SDL_TARGET ?= 2
628
SDL_FRAMEWORK ?= 0
630
SDL_FRAMEWORK ?= 0
629
631
630
ifeq (1,$(strip $(shell expr $(GCC_MAJOR) \>= 4)))
632
ifeq (1,$(strip $(shell expr $(GCC_MAJOR) \>= 4)))
631
    L_SSP := -lssp
633
    L_SSP := -lssp
632
endif
634
endif
633
635
634
# NOTE: If your setup doesn't have libstdc++, you can try using libsupc++.
636
# NOTE: If your setup doesn't have libstdc++, you can try using libsupc++.
635
# Search for STDCPPLIB below and change it to -lsupc++.
637
# Search for STDCPPLIB below and change it to -lsupc++.
636
638
637
SDL_INCLUDES=-I$(SDLROOT)/include -I$(SDLROOT)/include/SDL
639
SDL_INCLUDES=-I$(SDLROOT)/include -I$(SDLROOT)/include/SDL
638
SDL_LIB=-l$(SDLNAME)
640
SDL_LIB=-l$(SDLNAME)
639
SDL_MIXER_LIB=-l$(SDLNAME)_mixer
641
SDL_MIXER_LIB=-l$(SDLNAME)_mixer
640
642
641
ifeq ($(SUBPLATFORM),LINUX)
643
ifeq ($(SUBPLATFORM),LINUX)
642
    RENDERTYPE=SDL
644
    RENDERTYPE=SDL
643
    MIXERTYPE=SDL
645
    MIXERTYPE=SDL
644
    COMPILERFLAGS+= -DHAVE_INTTYPES
646
    COMPILERFLAGS+= -DHAVE_INTTYPES
645
    GTKCOMPAT32=0
647
    GTKCOMPAT32=0
646
    SDL_FRAMEWORK=0
648
    SDL_FRAMEWORK=0
647
649
648
    # On Linux, we don't need to specify libstdc++ manually, the linker will
650
    # On Linux, we don't need to specify libstdc++ manually, the linker will
649
    # presumably take care for us.
651
    # presumably take care for us.
650
    STDCPPLIB:=
652
    STDCPPLIB:=
651
653
652
    ifeq ($(PLATFORM),GCW)
654
    ifeq ($(PLATFORM),GCW)
653
        override USE_OPENGL=0
655
        override USE_OPENGL=0
654
        override NOASM=1
656
        override NOASM=1
655
    endif
657
    endif
656
    ifeq ($(PLATFORM),DINGOO)
658
    ifeq ($(PLATFORM),DINGOO)
657
        override USE_OPENGL=0
659
        override USE_OPENGL=0
658
        override NOASM=1
660
        override NOASM=1
659
    endif
661
    endif
660
662
661
    ifeq ($(findstring x86_64,$(SYSARCH)),x86_64)
663
    ifeq ($(findstring x86_64,$(SYSARCH)),x86_64)
662
        ifeq (1,$(BUILD32_ON_64))
664
        ifeq (1,$(BUILD32_ON_64))
663
            # On my 64bit Gentoo these are the 32bit emulation libs
665
            # On my 64bit Gentoo these are the 32bit emulation libs
664
            LIBS+= -m32
666
            LIBS+= -m32
665
            LIBDIRS+= -L/emul/linux/x86/usr/lib
667
            LIBDIRS+= -L/emul/linux/x86/usr/lib
666
            COMMONFLAGS+= -m32
668
            COMMONFLAGS+= -m32
667
            # Override WITHOUT_GTK=0
669
            # Override WITHOUT_GTK=0
668
            GTKCOMPAT32=1
670
            GTKCOMPAT32=1
669
        else
671
        else
670
            override NOASM=1
672
            override NOASM=1
671
        endif
673
        endif
672
    endif
674
    endif
673
675
674
    LIBS+= -lrt
676
    LIBS+= -lrt
675
    ifeq (0,$(CLANG))
677
    ifeq (0,$(CLANG))
676
        COMMONFLAGS	+= -fno-pic
678
        COMMONFLAGS	+= -fno-pic
677
    endif
679
    endif
678
endif
680
endif
679
ifeq ($(PLATFORM),DARWIN)
681
ifeq ($(PLATFORM),DARWIN)
680
    COMPILERFLAGS+= -DUNDERSCORES
682
    COMPILERFLAGS+= -DUNDERSCORES
681
    ASFORMAT=macho$(SYSBITS)
683
    ASFORMAT=macho$(SYSBITS)
682
    ASFLAGS+= -DUNDERSCORES
684
    ASFLAGS+= -DUNDERSCORES
683
    # ASM on OS X crashes in mmxoverlay()
685
    # ASM on OS X crashes in mmxoverlay()
684
    override NOASM=1
686
    override NOASM=1
685
687
686
    # LIBDIRS+= -Lplatform/Apple/lib
688
    # LIBDIRS+= -Lplatform/Apple/lib
687
    # COMPILERFLAGS+= -Iplatform/Apple/include
689
    # COMPILERFLAGS+= -Iplatform/Apple/include
688
690
689
    ifneq ($(shell port --version &>/dev/null; echo $$?),127)
691
    ifneq ($(shell port --version &>/dev/null; echo $$?),127)
690
        LIBDIRS+= -L/opt/local/lib
692
        LIBDIRS+= -L/opt/local/lib
691
        COMPILERFLAGS+= -I/opt/local/include
693
        COMPILERFLAGS+= -I/opt/local/include
692
    endif
694
    endif
693
    ifneq ($(shell brew --version &>/dev/null; echo $$?),127)
695
    ifneq ($(shell brew --version &>/dev/null; echo $$?),127)
694
        LIBDIRS+= -L/usr/local/lib
696
        LIBDIRS+= -L/usr/local/lib
695
        COMPILERFLAGS+= -I/usr/local/include
697
        COMPILERFLAGS+= -I/usr/local/include
696
    endif
698
    endif
697
    ifneq ($(shell fink --version &>/dev/null; echo $$?),127)
699
    ifneq ($(shell fink --version &>/dev/null; echo $$?),127)
698
        LIBDIRS+= -L/sw/lib
700
        LIBDIRS+= -L/sw/lib
699
        COMPILERFLAGS+= -I/sw/include
701
        COMPILERFLAGS+= -I/sw/include
700
    endif
702
    endif
701
703
702
    RENDERTYPE    = SDL
704
    RENDERTYPE    = SDL
703
    MIXERTYPE     = SDL
705
    MIXERTYPE     = SDL
704
    STDCPPLIB:=-lstdc++
706
    STDCPPLIB:=-lstdc++
705
    COMPILERFLAGS    += -DHAVE_INTTYPES
707
    COMPILERFLAGS    += -DHAVE_INTTYPES
706
    DLLSUFFIX=.dylib
708
    DLLSUFFIX=.dylib
707
    GTKCOMPAT32    = 0
709
    GTKCOMPAT32    = 0
708
    WITHOUT_GTK   ?= 1
710
    WITHOUT_GTK   ?= 1
709
711
710
    ifeq (1,$(SDL_FRAMEWORK))
712
    ifeq (1,$(SDL_FRAMEWORK))
711
        SDL_INCLUDES=-I$(APPLE_FRAMEWORKS)/SDL.framework/Headers -I$(APPLE_FRAMEWORKS)/SDL_mixer.framework/Headers
713
        SDL_INCLUDES=-I$(APPLE_FRAMEWORKS)/SDL.framework/Headers -I$(APPLE_FRAMEWORKS)/SDL_mixer.framework/Headers
712
        SDL_LIB=-l$(SDLNAME)main -Wl,-framework,SDL -Wl,-rpath -Wl,"@loader_path/../Frameworks"
714
        SDL_LIB=-l$(SDLNAME)main -Wl,-framework,SDL -Wl,-rpath -Wl,"@loader_path/../Frameworks"
713
        SDL_MIXER_LIB=-Wl,-framework,SDL_mixer
715
        SDL_MIXER_LIB=-Wl,-framework,SDL_mixer
714
    endif
716
    endif
715
717
716
    ifeq (1,$(DARWIN9))
718
    ifeq (1,$(DARWIN9))
717
        COMPILERFLAGS += -DDARWIN9
719
        COMPILERFLAGS += -DDARWIN9
718
    endif
720
    endif
719
721
720
    ifeq (1,$(BUILD32_ON_64))
722
    ifeq (1,$(BUILD32_ON_64))
721
        ARCH=-arch i386
723
        ARCH=-arch i386
722
    endif
724
    endif
723
725
724
    ifneq ($(findstring x86_64,$(ARCH)),x86_64)
726
    ifneq ($(findstring x86_64,$(ARCH)),x86_64)
725
        ifeq (,$(ARCH))
727
        ifeq (,$(ARCH))
726
            ifneq ($(findstring x86_64,$(SYSARCH)),x86_64)
728
            ifneq ($(findstring x86_64,$(SYSARCH)),x86_64)
727
                LINKERFLAGS += -read_only_relocs suppress
729
                LINKERFLAGS += -read_only_relocs suppress
728
            endif
730
            endif
729
        else
731
        else
730
            LINKERFLAGS += -read_only_relocs suppress
732
            LINKERFLAGS += -read_only_relocs suppress
731
        endif
733
        endif
732
    endif
734
    endif
733
735
734
    ifeq (0,$(CLANG))
736
    ifeq (0,$(CLANG))
735
        COMMONFLAGS	+= -fno-pic
737
        COMMONFLAGS	+= -fno-pic
736
    endif
738
    endif
737
endif
739
endif
738
ifeq ($(PLATFORM),WINDOWS)
740
ifeq ($(PLATFORM),WINDOWS)
739
    COMPILERFLAGS+= -DUNDERSCORES -DHAVE_INTTYPES -Iplatform/Windows/include
741
    COMPILERFLAGS+= -DUNDERSCORES -DHAVE_INTTYPES -Iplatform/Windows/include
740
    LINKERFLAGS+= -static-libgcc
742
    LINKERFLAGS+= -static-libgcc
741
    ASFORMAT=win$(SYSBITS)
743
    ASFORMAT=win$(SYSBITS)
742
    ASFLAGS+= -DUNDERSCORES
744
    ASFLAGS+= -DUNDERSCORES
743
745
744
    # Windows types can be SDL or WIN
746
    # Windows types can be SDL or WIN
745
    RENDERTYPE?=SDL
747
    RENDERTYPE?=SDL
746
    MIXERTYPE?=WIN
748
    MIXERTYPE?=WIN
747
    ifneq ($(RENDERTYPE),SDL)
749
    ifneq ($(RENDERTYPE),SDL)
748
        ifeq ($(MIXERTYPE),SDL)
750
        ifeq ($(MIXERTYPE),SDL)
749
            MIXERTYPE:=WIN
751
            MIXERTYPE:=WIN
750
        endif
752
        endif
751
    endif
753
    endif
752
754
753
    SDL_INCLUDES=
755
    SDL_INCLUDES=
754
    ifeq ($(SDL_TARGET),1)
756
    ifeq ($(SDL_TARGET),1)
755
        SDL_MIXER_LIB=platform/Windows/lib$(WINLIB)/SDL_mixer.lib
757
        SDL_MIXER_LIB=platform/Windows/lib$(WINLIB)/SDL_mixer.lib
756
    endif
758
    endif
757
759
758
    WITHOUT_GTK?=1
760
    WITHOUT_GTK?=1
759
    SDLCONFIG=
761
    SDLCONFIG=
760
    SDL_FRAMEWORK=1
762
    SDL_FRAMEWORK=1
761
    EXESUFFIX=.exe
763
    EXESUFFIX=.exe
762
    DLLSUFFIX=.dll
764
    DLLSUFFIX=.dll
763
    LIBDIRS+= -Lplatform/Windows/lib$(WINLIB)
765
    LIBDIRS+= -Lplatform/Windows/lib$(WINLIB)
764
    LIBS+= -Wl,--enable-auto-import -lmingwex -lgdi32 -lcomctl32 -lwinmm $(L_SSP) -lwsock32 -lws2_32 -lshlwapi
766
    LIBS+= -Wl,--enable-auto-import -lmingwex -lgdi32 -lcomctl32 -lwinmm $(L_SSP) -lwsock32 -lws2_32 -lshlwapi
765
    ifeq (0,$(CLANG))
767
    ifeq (0,$(CLANG))
766
        LIBS+= -mwindows
768
        LIBS+= -mwindows
767
    endif
769
    endif
768
    #-lshfolder
770
    #-lshfolder
769
    STDCPPLIB:=-lstdc++
771
    STDCPPLIB:=-lstdc++
770
    ifeq ($(findstring x86_64,$(SYSARCH)),x86_64)
772
    ifeq ($(findstring x86_64,$(SYSARCH)),x86_64)
771
        ifneq (1,$(BUILD32_ON_64))
773
        ifneq (1,$(BUILD32_ON_64))
772
            override NOASM=1
774
            override NOASM=1
773
        endif
775
        endif
774
    endif
776
    endif
775
777
776
    COMMONFLAGS += -fno-pic
778
    COMMONFLAGS += -fno-pic
777
endif
779
endif
778
ifeq ($(PLATFORM),BSD)
780
ifeq ($(PLATFORM),BSD)
779
    COMPILERFLAGS+= -I/usr/X11R6/include
781
    COMPILERFLAGS+= -I/usr/X11R6/include
780
782
781
    RENDERTYPE=SDL
783
    RENDERTYPE=SDL
782
    MIXERTYPE=SDL
784
    MIXERTYPE=SDL
783
    COMPILERFLAGS+= -DHAVE_INTTYPES
785
    COMPILERFLAGS+= -DHAVE_INTTYPES
784
    ifneq ($(findstring i386,$(SYSARCH)),i386)
786
    ifneq ($(findstring i386,$(SYSARCH)),i386)
785
        override NOASM=1
787
        override NOASM=1
786
    endif
788
    endif
787
    STDCPPLIB:=-lstdc++
789
    STDCPPLIB:=-lstdc++
788
endif
790
endif
789
ifeq ($(PLATFORM),BEOS)
791
ifeq ($(PLATFORM),BEOS)
790
    override NOASM=1
792
    override NOASM=1
791
793
792
    RENDERTYPE=SDL
794
    RENDERTYPE=SDL
793
    MIXERTYPE=SDL
795
    MIXERTYPE=SDL
794
    STDCPPLIB:=-lstdc++
796
    STDCPPLIB:=-lstdc++
795
endif
797
endif
796
ifeq ($(PLATFORM),SKYOS)
798
ifeq ($(PLATFORM),SKYOS)
797
    RENDERTYPE=SDL
799
    RENDERTYPE=SDL
798
    MIXERTYPE=SDL
800
    MIXERTYPE=SDL
799
    EXESUFFIX=.app
801
    EXESUFFIX=.app
800
    override NOASM=1
802
    override NOASM=1
801
    COMPILERFLAGS+= -DUNDERSCORES -I/boot/programs/sdk/include/sdl
803
    COMPILERFLAGS+= -DUNDERSCORES -I/boot/programs/sdk/include/sdl
802
    SDLCONFIG=
804
    SDLCONFIG=
803
    LIBS+= -lSDL -lnet
805
    LIBS+= -lSDL -lnet
804
endif
806
endif
805
ifeq ($(PLATFORM),WII)
807
ifeq ($(PLATFORM),WII)
806
    RENDERTYPE=SDL
808
    RENDERTYPE=SDL
807
    MIXERTYPE=SDL
809
    MIXERTYPE=SDL
808
    SDL_INCLUDES=
810
    SDL_INCLUDES=
809
    EXESUFFIX=.elf
811
    EXESUFFIX=.elf
810
    override USE_OPENGL=0
812
    override USE_OPENGL=0
811
    override POLYMER=0
813
    override POLYMER=0
812
    override NOASM=1
814
    override NOASM=1
813
    override WITHOUT_GTK=1
815
    override WITHOUT_GTK=1
814
    # -msdata=eabi
816
    # -msdata=eabi
815
    COMMONFLAGS+= -g -mtune=750 -meabi -mhard-float
817
    COMMONFLAGS+= -g -mtune=750 -meabi -mhard-float
816
    COMPILERFLAGS+= -DGEKKO -DHAVE_INTTYPES -D__POWERPC__ -I$(LIBOGC_INC) -I$(PORTLIBS)/include -Iplatform/Wii/include
818
    COMPILERFLAGS+= -DGEKKO -DHAVE_INTTYPES -D__POWERPC__ -I$(LIBOGC_INC) -I$(PORTLIBS)/include -Iplatform/Wii/include
817
    SDLCONFIG=
819
    SDLCONFIG=
818
    SDL_TARGET=1
820
    SDL_TARGET=1
819
    SDL_FRAMEWORK=1
821
    SDL_FRAMEWORK=1
820
    LIBDIRS += -L$(LIBOGC_LIB) -L$(PORTLIBS)/lib -Lplatform/Wii/lib
822
    LIBDIRS += -L$(LIBOGC_LIB) -L$(PORTLIBS)/lib -Lplatform/Wii/lib
821
endif
823
endif
822
ifeq ($(PLATFORM),QNX)
824
ifeq ($(PLATFORM),QNX)
823
    RENDERTYPE=SDL
825
    RENDERTYPE=SDL
824
    MIXERTYPE=SDL
826
    MIXERTYPE=SDL
825
    override USE_OPENGL=0
827
    override USE_OPENGL=0
826
    override NOASM=1
828
    override NOASM=1
827
    STDCPPLIB:=-lstdc++
829
    STDCPPLIB:=-lstdc++
828
    LIBS+= -lsocket
830
    LIBS+= -lsocket
829
endif
831
endif
830
ifeq ($(PLATFORM),SUNOS)
832
ifeq ($(PLATFORM),SUNOS)
831
    RENDERTYPE=SDL
833
    RENDERTYPE=SDL
832
    MIXERTYPE=SDL
834
    MIXERTYPE=SDL
833
    override USE_OPENGL=0
835
    override USE_OPENGL=0
834
    override NOASM=1
836
    override NOASM=1
835
    STDCPPLIB:=-lstdc++
837
    STDCPPLIB:=-lstdc++
836
    LIBS+= -lsocket -lnsl
838
    LIBS+= -lsocket -lnsl
837
endif
839
endif
838
ifeq ($(PLATFORM),SYLLABLE)
840
ifeq ($(PLATFORM),SYLLABLE)
839
    RENDERTYPE=SDL
841
    RENDERTYPE=SDL
840
    MIXERTYPE=SDL
842
    MIXERTYPE=SDL
841
    override USE_OPENGL=0
843
    override USE_OPENGL=0
842
    override NOASM=1
844
    override NOASM=1
843
endif
845
endif
844
ifeq ($(PLATFORM),GCW)
846
ifeq ($(PLATFORM),GCW)
845
    COMPILERFLAGS += -D__OPENDINGUX__
847
    COMPILERFLAGS += -D__OPENDINGUX__
846
endif
848
endif
847
ifeq ($(PLATFORM),DINGOO)
849
ifeq ($(PLATFORM),DINGOO)
848
    COMPILERFLAGS += -D__OPENDINGUX__
850
    COMPILERFLAGS += -D__OPENDINGUX__
849
endif
851
endif
850
852
851
ifneq ($(EXESUFFIX_OVERRIDE),)
853
ifneq ($(EXESUFFIX_OVERRIDE),)
852
    EXESUFFIX=$(EXESUFFIX_OVERRIDE)
854
    EXESUFFIX=$(EXESUFFIX_OVERRIDE)
853
endif
855
endif
854
856
855
ifneq (0,$(CLANG))
857
ifneq (0,$(CLANG))
856
    ifneq (,$(STDCPPLIB))
858
    ifneq (,$(STDCPPLIB))
857
        STDCPPLIB:=-Xlinker $(STDCPPLIB)
859
        STDCPPLIB:=-Xlinker $(STDCPPLIB)
858
    endif
860
    endif
859
endif
861
endif
860
862
861
ifeq ($(SDL_TARGET),2)
863
ifeq ($(SDL_TARGET),2)
862
    SDLCONFIG ?= sdl2-config
864
    SDLCONFIG ?= sdl2-config
863
    SDLNAME ?= SDL2
865
    SDLNAME ?= SDL2
864
endif
866
endif
865
ifeq ($(SDL_TARGET),1)
867
ifeq ($(SDL_TARGET),1)
866
    SDLCONFIG ?= sdl-config
868
    SDLCONFIG ?= sdl-config
867
    SDLNAME ?= SDL
869
    SDLNAME ?= SDL
868
endif
870
endif
869
871
870
ifneq ($(SDLCONFIG),)
872
ifneq ($(SDLCONFIG),)
871
    SDLVERSION:=$(strip $(shell $(SDLCONFIG) --version))
873
    SDLVERSION:=$(strip $(shell $(SDLCONFIG) --version))
872
    ifneq ($(SDLVERSION),)
874
    ifneq ($(SDLVERSION),)
873
        SDLROOT:=$(strip $(shell $(SDLCONFIG) --prefix))
875
        SDLROOT:=$(strip $(shell $(SDLCONFIG) --prefix))
874
    endif
876
    endif
875
endif
877
endif
876
878
877
SDL_STATIC?=1
879
SDL_STATIC?=1
878
880
879
ifeq ($(RENDERTYPE),SDL)
881
ifeq ($(RENDERTYPE),SDL)
880
    COMPILERFLAGS += -DSDL_TARGET=$(SDL_TARGET)
882
    COMPILERFLAGS += -DSDL_TARGET=$(SDL_TARGET)
881
883
882
    ifeq ($(SDL_FRAMEWORK),1)
884
    ifeq ($(SDL_FRAMEWORK),1)
883
        COMPILERFLAGS += -DSDL_FRAMEWORK
885
        COMPILERFLAGS += -DSDL_FRAMEWORK
884
    endif
886
    endif
885
887
886
    ifneq ($(PLATFORM),WINDOWS)
888
    ifneq ($(PLATFORM),WINDOWS)
887
        ifeq ($(SDL_FRAMEWORK),1)
889
        ifeq ($(SDL_FRAMEWORK),1)
888
            ifeq ($(PLATFORM),DARWIN)
890
            ifeq ($(PLATFORM),DARWIN)
889
                LIBS        += -Wl,-framework,SDL
891
                LIBS        += -Wl,-framework,SDL
890
                COMPILERFLAGS+= -I$(APPLE_FRAMEWORKS)/SDL.framework/Headers \
892
                COMPILERFLAGS+= -I$(APPLE_FRAMEWORKS)/SDL.framework/Headers \
891
                                -I$(APPLE_FRAMEWORKS)/SDL_mixer.framework/Headers
893
                                -I$(APPLE_FRAMEWORKS)/SDL_mixer.framework/Headers
892
            endif
894
            endif
893
        else
895
        else
894
            ifneq ($(SDLCONFIG),)
896
            ifneq ($(SDLCONFIG),)
895
                SDLCONFIG_COMMONFLAGS:=$(subst -Dmain=SDL_main,,$(strip $(shell $(SDLCONFIG) --cflags)))
897
                SDLCONFIG_COMMONFLAGS:=$(subst -Dmain=SDL_main,,$(strip $(shell $(SDLCONFIG) --cflags)))
896
                SDLCONFIG_LIBS:=$(strip $(shell $(SDLCONFIG) --libs))
898
                SDLCONFIG_LIBS:=$(strip $(shell $(SDLCONFIG) --libs))
897
899
898
                LIBS+= $(SDLCONFIG_LIBS)
900
                LIBS+= $(SDLCONFIG_LIBS)
899
                COMMONFLAGS+= $(SDLCONFIG_COMMONFLAGS)
901
                COMMONFLAGS+= $(SDLCONFIG_COMMONFLAGS)
900
            endif
902
            endif
901
        endif
903
        endif
902
    else
904
    else
903
        COMPILERFLAGS += -D_GNU_SOURCE=1
905
        COMPILERFLAGS += -D_GNU_SOURCE=1
904
        ifneq ($(SDL_STATIC),0)
906
        ifneq ($(SDL_STATIC),0)
905
            ifneq ($(SDL_TARGET),1) # Since SDL2 is under the zlib license, link statically if possible.
907
            ifneq ($(SDL_TARGET),1) # Since SDL2 is under the zlib license, link statically if possible.
906
                LIBS+= -static
908
                LIBS+= -static
907
            endif
909
            endif
908
        endif
910
        endif
909
        LIBS+= -l$(SDLNAME)main -l$(SDLNAME) -lmingw32 -lgdi32 -limm32 -lole32 -loleaut32 -lwinmm -lversion
911
        LIBS+= -l$(SDLNAME)main -l$(SDLNAME) -lmingw32 -lgdi32 -limm32 -lole32 -loleaut32 -lwinmm -lversion
910
    endif
912
    endif
911
913
912
    ifeq (1,$(WITHOUT_GTK))
914
    ifeq (1,$(WITHOUT_GTK))
913
        HAVE_GTK2=0
915
        HAVE_GTK2=0
914
    else
916
    else
915
        ifneq (No,$(shell $(PKG_CONFIG) --exists gtk+-2.0 || echo No))
917
        ifneq (No,$(shell $(PKG_CONFIG) --exists gtk+-2.0 || echo No))
916
            HAVE_GTK2=1
918
            HAVE_GTK2=1
917
            # On my 64bit Gentoo box I have Cairo enabled which means the libs list includes
919
            # On my 64bit Gentoo box I have Cairo enabled which means the libs list includes
918
            # -lpangocairo-1.0 and -lcairo, however the 32bit compatibility libraries don't
920
            # -lpangocairo-1.0 and -lcairo, however the 32bit compatibility libraries don't
919
            # include cairo, so we need to filter out those -l switches in order to link
921
            # include cairo, so we need to filter out those -l switches in order to link
920
            ifneq ($(LINKED_GTK),0)
922
            ifneq ($(LINKED_GTK),0)
921
                ifeq ($(GTKCOMPAT32),1)
923
                ifeq ($(GTKCOMPAT32),1)
922
                    LIBS+= $(shell $(PKG_CONFIG) --libs gtk+-2.0 | sed 's/\s-l\(pango\)\{0,1\}cairo\S*\s/ /g')
924
                    LIBS+= $(shell $(PKG_CONFIG) --libs gtk+-2.0 | sed 's/\s-l\(pango\)\{0,1\}cairo\S*\s/ /g')
923
                else
925
                else
924
                    LIBS+= $(shell $(PKG_CONFIG) --libs gtk+-2.0)
926
                    LIBS+= $(shell $(PKG_CONFIG) --libs gtk+-2.0)
925
                endif
927
                endif
926
            endif
928
            endif
927
            COMPILERFLAGS += -DHAVE_GTK2 $(shell $(PKG_CONFIG) --cflags gtk+-2.0)
929
            COMPILERFLAGS += -DHAVE_GTK2 $(shell $(PKG_CONFIG) --cflags gtk+-2.0)
928
        else
930
        else
929
            HAVE_GTK2=0
931
            HAVE_GTK2=0
930
        endif
932
        endif
931
    endif
933
    endif
932
934
933
    COMPILERFLAGS += $(SDL_INCLUDES)
935
    COMPILERFLAGS += $(SDL_INCLUDES)
934
    ifneq ($(MIXERTYPE),WIN)
936
    ifneq ($(MIXERTYPE),WIN)
935
        LIBS += $(SDL_MIXER_LIB)
937
        LIBS += $(SDL_MIXER_LIB)
936
    endif
938
    endif
937
    LIBS += $(SDL_LIB)
939
    LIBS += $(SDL_LIB)
938
endif
940
endif
939
ifeq ($(RENDERTYPE),WIN)
941
ifeq ($(RENDERTYPE),WIN)
940
    LIBS+= -ldxguid
942
    LIBS+= -ldxguid
941
endif
943
endif
942
944
943
# SDL depends on these
945
# SDL depends on these
944
ifeq ($(PLATFORM),WINDOWS)
946
ifeq ($(PLATFORM),WINDOWS)
945
    ifeq ($(RENDERTYPE),SDL)
947
    ifeq ($(RENDERTYPE),SDL)
946
    SDL_LIB:=-l$(SDLNAME)main $(SDL_LIB)
948
    SDL_LIB:=-l$(SDLNAME)main $(SDL_LIB)
947
        ifeq ($(MIXERTYPE),WIN)
949
        ifeq ($(MIXERTYPE),WIN)
948
            LIBS+= -ldxguid_sdl
950
            LIBS+= -ldxguid_sdl
949
        endif
951
        endif
950
    endif
952
    endif
951
endif
953
endif
952
ifeq ($(PLATFORM),WII)
954
ifeq ($(PLATFORM),WII)
953
    LIBS+= -laesnd_tueidj -lpng -lfat -lwiiuse -lbte -logc -lm -lwiikeyboard
955
    LIBS+= -laesnd_tueidj -lpng -lfat -lwiiuse -lbte -logc -lm -lwiikeyboard
954
endif
956
endif
955
957
956
COMPILERFLAGS+= -DRENDERTYPE$(RENDERTYPE)=1 -DMIXERTYPE$(MIXERTYPE)=1 $(W_STRICT_OVERFLOW)
958
COMPILERFLAGS+= -DRENDERTYPE$(RENDERTYPE)=1 -DMIXERTYPE$(MIXERTYPE)=1 $(W_STRICT_OVERFLOW)
957
959
958
ifneq (0,$(USE_OPENGL))
960
ifneq (0,$(USE_OPENGL))
959
    COMPILERFLAGS+= -DUSE_OPENGL
961
    COMPILERFLAGS+= -DUSE_OPENGL
960
endif
962
endif
961
ifneq (0,$(NOASM))
963
ifneq (0,$(NOASM))
962
    COMPILERFLAGS+= -DNOASM
964
    COMPILERFLAGS+= -DNOASM
963
endif
965
endif
964
ifneq (0,$(USE_ASM64))
966
ifneq (0,$(USE_ASM64))
965
    COMPILERFLAGS+= -DUSE_ASM64
967
    COMPILERFLAGS+= -DUSE_ASM64
966
endif
968
endif
967
ifneq (0,$(LINKED_GTK))
969
ifneq (0,$(LINKED_GTK))
968
    COMPILERFLAGS+= -DLINKED_GTK
970
    COMPILERFLAGS+= -DLINKED_GTK
969
endif
971
endif
970
972
971
ifneq (0,$(POLYMER))
973
ifneq (0,$(POLYMER))
972
 ifneq (0,$(USE_OPENGL))
974
 ifneq (0,$(USE_OPENGL))
973
  COMPILERFLAGS+= -DPOLYMER
975
  COMPILERFLAGS+= -DPOLYMER
974
 endif
976
 endif
975
endif
977
endif
976
978
977
STATICSTDCPP?=
979
STATICSTDCPP?=
978
ifeq (1,$(STATICSTDCPP))
980
ifeq (1,$(STATICSTDCPP))
979
    STATICSTDCPP= -static
981
    STATICSTDCPP= -static
980
endif
982
endif
981
ifeq (0,$(STATICSTDCPP))
983
ifeq (0,$(STATICSTDCPP))
982
    STATICSTDCPP= -shared
984
    STATICSTDCPP= -shared
983
endif
985
endif
984
986
985
987
986
ifneq ($(PLATFORM),WINDOWS)
988
ifneq ($(PLATFORM),WINDOWS)
987
    ifneq ($(PLATFORM),WII)
989
    ifneq ($(PLATFORM),WII)
988
        LIBS+= -ldl
990
        LIBS+= -ldl
989
        ifneq ($(PLATFORM),DARWIN)
991
        ifneq ($(PLATFORM),DARWIN)
990
            LIBS+= -pthread
992
            LIBS+= -pthread
991
        endif
993
        endif
992
    endif
994
    endif
993
endif
995
endif
994
996
995
ifeq ($(PLATFORM),WINDOWS)
997
ifeq ($(PLATFORM),WINDOWS)
996
    ifneq ($(USE_LIBPNG),0)
998
    ifneq ($(USE_LIBPNG),0)
997
        LIBS+= -lpng_mini -lz_mini
999
        LIBS+= -lpng_mini -lz_mini
998
    endif
1000
    endif
999
else
1001
else
1000
    ifeq ($(PLATFORM),DARWIN)
1002
    ifeq ($(PLATFORM),DARWIN)
1001
        ifneq ($(USE_LIBPNG),0)
1003
        ifneq ($(USE_LIBPNG),0)
1002
            LIBS+= -lpng # -lz
1004
            LIBS+= -lpng # -lz
1003
        endif
1005
        endif
1004
    else
1006
    else
1005
        ifneq ($(USE_LIBPNG),0)
1007
        ifneq ($(USE_LIBPNG),0)
1006
            LIBS+= -lpng -lz
1008
            LIBS+= -lpng -lz
1007
        endif
1009
        endif
1008
    endif
1010
    endif
1009
endif
1011
endif
1010
1012
1011
1013
1012
ifeq ($(PLATFORM),WINDOWS)
1014
ifeq ($(PLATFORM),WINDOWS)
1013
    ifneq ($(findstring x86_64,$(COMPILERTARGET)),x86_64)
1015
    ifneq ($(findstring x86_64,$(COMPILERTARGET)),x86_64)
1014
        LINKERFLAGS+= -Wl,--large-address-aware
1016
        LINKERFLAGS+= -Wl,--large-address-aware
1015
    endif
1017
    endif
1016
endif
1018
endif
1017
1019
1018
ifneq (0,$(MEMMAP))
1020
ifneq (0,$(MEMMAP))
1019
ifeq ($(PLATFORM),DARWIN)
1021
ifeq ($(PLATFORM),DARWIN)
1020
    LINKERFLAGS+=-Wl,-map -Wl,$@.memmap
1022
    LINKERFLAGS+=-Wl,-map -Wl,$@.memmap
1021
else
1023
else
1022
    LINKERFLAGS+=-Wl,-Map=$@.memmap
1024
    LINKERFLAGS+=-Wl,-Map=$@.memmap
1023
endif
1025
endif
1024
endif
1026
endif
1025
1027
1026
ifneq (0,$(PROFILER))
1028
ifneq (0,$(PROFILER))
1027
    LINKERFLAGS+=-pg
1029
    LINKERFLAGS+=-pg
1028
endif
1030
endif
1029
ifeq ($(PLATFORM),WII)
1031
ifeq ($(PLATFORM),WII)
1030
    LINKERFLAGS+= -mrvl -meabi -mhard-float -Wl,--gc-sections
1032
    LINKERFLAGS+= -mrvl -meabi -mhard-float -Wl,--gc-sections
1031
    # -msdata=eabi
1033
    # -msdata=eabi
1032
endif
1034
endif
1033
1035
1034
# Detect version control revision, if applicable
1036
# Detect version control revision, if applicable
1035
ifeq (,$(VC_REV))
1037
ifeq (,$(VC_REV))
1036
    ifneq (,$(wildcard EDUKE32_REVISION))
1038
    ifneq (,$(wildcard EDUKE32_REVISION))
1037
        VC_REV    := $(shell cat EDUKE32_REVISION)
1039
        VC_REV    := $(shell cat EDUKE32_REVISION)
1038
    endif
1040
    endif
1039
endif
1041
endif
1040
ifeq (,$(VC_REV))
1042
ifeq (,$(VC_REV))
1041
    VC_REV    := $(shell svn info 2>&1 | grep Revision | cut -d' ' -f2)
1043
    VC_REV    := $(shell svn info 2>&1 | grep Revision | cut -d' ' -f2)
1042
endif
1044
endif
1043
ifeq (,$(VC_REV))
1045
ifeq (,$(VC_REV))
1044
    VC_REV    := $(shell git svn info 2>&1 | grep Revision | cut -d' ' -f2)
1046
    VC_REV    := $(shell git svn info 2>&1 | grep Revision | cut -d' ' -f2)
1045
endif
1047
endif
1046
ifneq (,$(VC_REV)$(VC_REV_CUSTOM))
1048
ifneq (,$(VC_REV)$(VC_REV_CUSTOM))
1047
    REVFLAG += -DREV="\"r$(VC_REV)$(VC_REV_CUSTOM)\""
1049
    REVFLAG += -DREV="\"r$(VC_REV)$(VC_REV_CUSTOM)\""
1048
endif
1050
endif
1049
1051
1050
COMPILER=$(CC) $(CONLYFLAGS)
1052
COMPILER=$(CC) $(CONLYFLAGS)
1051
LINKER=$(L_CC)
1053
LINKER=$(L_CC)
1052
ifneq ($(CPLUSPLUS),0)
1054
ifneq ($(CPLUSPLUS),0)
1053
    COMPILER=$(CXX) $(CPPONLYFLAGS)
1055
    COMPILER=$(CXX) $(CPPONLYFLAGS)
1054
    LINKER=$(L_CXX)
1056
    LINKER=$(L_CXX)
1055
endif
1057
endif
1056
1058
1057
ifneq (,$(CUSTOMOPT))
1059
ifneq (,$(CUSTOMOPT))
1058
    COMMONFLAGS+= $(CUSTOMOPT)
1060
    COMMONFLAGS+= $(CUSTOMOPT)
1059
endif
1061
endif
1060
ifneq (,$(CFLAGS))
1062
ifneq (,$(CFLAGS))
1061
    COMMONFLAGS+= $(CFLAGS)
1063
    COMMONFLAGS+= $(CFLAGS)
1062
endif
1064
endif
1063
ifneq (,$(CXXFLAGS))
1065
ifneq (,$(CXXFLAGS))
1064
    CPPONLYFLAGS+= $(CXXFLAGS)
1066
    CPPONLYFLAGS+= $(CXXFLAGS)
1065
endif
1067
endif
1066
ifneq (,$(LDFLAGS))
1068
ifneq (,$(LDFLAGS))
1067
    LINKERFLAGS+= $(LDFLAGS)
1069
    LINKERFLAGS+= $(LDFLAGS)
1068
endif
1070
endif
1069
1071
1070
ifeq ($(PRETTY_OUTPUT),1)
1072
ifeq ($(PRETTY_OUTPUT),1)
1071
RECIPE_IF = if
1073
RECIPE_IF = if
1072
BUILD_SETTINGS_COMPILER = \033[1;36mcompiler: \033[0;36m\"$(COMPILER) $(COMMONFLAGS) $(COMPILERFLAGS)\"
1074
BUILD_SETTINGS_COMPILER = \033[1;36mcompiler: \033[0;36m\"$(COMPILER) $(COMMONFLAGS) $(COMPILERFLAGS)\"
1073
BUILD_SETTINGS_ASSEMBLER = \033[1;36massembler: \033[0;36m\"$(AS) $(ASFLAGS)\"
1075
BUILD_SETTINGS_ASSEMBLER = \033[1;36massembler: \033[0;36m\"$(AS) $(ASFLAGS)\"
1074
BUILD_SETTINGS_LINKER = \033[1;36mlinker: \033[0;36m\"$(LINKER) $(COMMONFLAGS) $(LINKERFLAGS) $(LIBDIRS) $(LIBS) $(STATICSTDCPP) $(STDCPPLIB)\"
1076
BUILD_SETTINGS_LINKER = \033[1;36mlinker: \033[0;36m\"$(LINKER) $(COMMONFLAGS) $(LINKERFLAGS) $(LIBDIRS) $(LIBS) $(STATICSTDCPP) $(STDCPPLIB)\"
1075
ifeq (0,$(NOASM))
1077
ifeq (0,$(NOASM))
1076
    BUILD_SETTINGS = printf "$(BUILD_SETTINGS_COMPILER)\n$(BUILD_SETTINGS_ASSEMBLER)\n$(BUILD_SETTINGS_LINKER)\033[0m\n"
1078
    BUILD_SETTINGS = printf "$(BUILD_SETTINGS_COMPILER)\n$(BUILD_SETTINGS_ASSEMBLER)\n$(BUILD_SETTINGS_LINKER)\033[0m\n"
1077
else
1079
else
1078
    BUILD_SETTINGS = printf "$(BUILD_SETTINGS_COMPILER)\n$(BUILD_SETTINGS_LINKER)\033[0m\n"
1080
    BUILD_SETTINGS = printf "$(BUILD_SETTINGS_COMPILER)\n$(BUILD_SETTINGS_LINKER)\033[0m\n"
1079
endif
1081
endif
1080
BUILD_STARTED = printf "\033[K\033[1;36mBuild started using:\033[0m\n"; $(BUILD_SETTINGS)
1082
BUILD_STARTED = printf "\033[K\033[1;36mBuild started using:\033[0m\n"; $(BUILD_SETTINGS)
1081
BUILD_ECHOFLAGS = printf "\033[K\033[1;36mEnded compilation in this directory using:\n$(BUILD_SETTINGS_COMPILER)\033[0m\n"
1083
BUILD_ECHOFLAGS = printf "\033[K\033[1;36mEnded compilation in this directory using:\n$(BUILD_SETTINGS_COMPILER)\033[0m\n"
1082
BUILD_FINISHED = printf "\033[K\033[1;36mBuild successful:\033[0m\n"
1084
BUILD_FINISHED = printf "\033[K\033[1;36mBuild successful:\033[0m\n"
1083
COMPILE_STATUS = printf "\033[K\033[0mBuilding object \033[1m$@\033[0m...\033[0m\r"
1085
COMPILE_STATUS = printf "\033[K\033[0mBuilding object \033[1m$@\033[0m...\033[0m\r"
1084
COMPILE_OK = printf "\033[K\033[0;32mBuilt object \033[1;32m$@\033[0;32m \033[0m\n"
1086
COMPILE_OK = printf "\033[K\033[0;32mBuilt object \033[1;32m$@\033[0;32m \033[0m\n"
1085
COMPILE_FAILED = printf "\033[K\033[0;31mFailed building \033[1;31m$@\033[0;31m from\033[0m \033[1;31m$<\033[0;31m!\033[0m\n"; exit 1
1087
COMPILE_FAILED = printf "\033[K\033[0;31mFailed building \033[1;31m$@\033[0;31m from\033[0m \033[1;31m$<\033[0;31m!\033[0m\n"; exit 1
1086
RECIPE_RESULT_COMPILE = ; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
1088
RECIPE_RESULT_COMPILE = ; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
1087
ONESTEP_STATUS = printf "\033[K\033[0mBuilding executable \033[1m$@\033[0m...\033[0m\r"
1089
ONESTEP_STATUS = printf "\033[K\033[0mBuilding executable \033[1m$@\033[0m...\033[0m\r"
1088
ONESTEP_OK = printf "\033[K\033[0;32mBuilt executable \033[1;32m$@\033[0;32m \033[0m\n"
1090
ONESTEP_OK = printf "\033[K\033[0;32mBuilt executable \033[1;32m$@\033[0;32m \033[0m\n"
1089
ONESTEP_FAILED = printf "\033[K\033[0;31mFailed building executable \033[1;31m$@\033[0;31m!\033[0m\n"; exit 1
1091
ONESTEP_FAILED = printf "\033[K\033[0;31mFailed building executable \033[1;31m$@\033[0;31m!\033[0m\n"; exit 1
1090
RECIPE_RESULT_ONESTEP = ; then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
1092
RECIPE_RESULT_ONESTEP = ; then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
1091
ARCHIVE_STATUS = printf "\033[K\033[0mCreating library archive \033[1m$@\033[0m...\033[0m\r"
1093
ARCHIVE_STATUS = printf "\033[K\033[0mCreating library archive \033[1m$@\033[0m...\033[0m\r"
1092
ARCHIVE_OK = printf "\033[K\033[0;32mCreated library archive \033[1;32m$@\033[0;32m \033[0m\n"
1094
ARCHIVE_OK = printf "\033[K\033[0;32mCreated library archive \033[1;32m$@\033[0;32m \033[0m\n"
1093
ARCHIVE_FAILED = printf "\033[K\033[0;31mFailed creating library archive \033[1;31m$@\033[0;31m from\033[0m \033[1;31m$<\033[0;31m!\033[0m\n"; exit 1
1095
ARCHIVE_FAILED = printf "\033[K\033[0;31mFailed creating library archive \033[1;31m$@\033[0;31m from\033[0m \033[1;31m$<\033[0;31m!\033[0m\n"; exit 1
1094
RECIPE_RESULT_ARCHIVE = ; then $(ARCHIVE_OK); else $(ARCHIVE_FAILED); fi
1096
RECIPE_RESULT_ARCHIVE = ; then $(ARCHIVE_OK); else $(ARCHIVE_FAILED); fi
1095
LINK_STATUS = printf "\033[K\033[0;0mLinking executable \033[1m$@\033[0;0m...\033[0m\r"
1097
LINK_STATUS = printf "\033[K\033[0;0mLinking executable \033[1m$@\033[0;0m...\033[0m\r"
1096
LINK_OK = printf "\033[K\033[0;32mLinked executable \033[1;32m$@\033[0;32m \033[0m\n"
1098
LINK_OK = printf "\033[K\033[0;32mLinked executable \033[1;32m$@\033[0;32m \033[0m\n"
1097
LINK_FAILED = printf "\033[K\033[0;31mFailed linking executable \033[1;31m$@\033[0;31m!\033[0m\n"; exit 1
1099
LINK_FAILED = printf "\033[K\033[0;31mFailed linking executable \033[1;31m$@\033[0;31m!\033[0m\n"; exit 1
1098
RECIPE_RESULT_LINK = ; then $(LINK_OK); else $(LINK_FAILED); fi
1100
RECIPE_RESULT_LINK = ; then $(LINK_OK); else $(LINK_FAILED); fi
1099
else
1101
else
1100
RECIPE_IF =
1102
RECIPE_IF =
1101
BUILD_STARTED =
1103
BUILD_STARTED =
1102
BUILD_ECHOFLAGS =
1104
BUILD_ECHOFLAGS =
1103
BUILD_FINISHED =
1105
BUILD_FINISHED =
1104
COMPILE_STATUS =
1106
COMPILE_STATUS =
1105
COMPILE_OK = true
1107
COMPILE_OK = true
1106
COMPILE_FAILED = false; exit 1
1108
COMPILE_FAILED = false; exit 1
1107
RECIPE_RESULT_COMPILE =
1109
RECIPE_RESULT_COMPILE =
1108
ONESTEP_STATUS =
1110
ONESTEP_STATUS =
1109
ONESTEP_OK = true
1111
ONESTEP_OK = true
1110
ONESTEP_FAILED = false; exit 1
1112
ONESTEP_FAILED = false; exit 1
1111
RECIPE_RESULT_ONESTEP =
1113
RECIPE_RESULT_ONESTEP =
1112
ARCHIVE_STATUS =
1114
ARCHIVE_STATUS =
1113
ARCHIVE_OK = true
1115
ARCHIVE_OK = true
1114
ARCHIVE_FAILED = false; exit 1
1116
ARCHIVE_FAILED = false; exit 1
1115
RECIPE_RESULT_ARCHIVE =
1117
RECIPE_RESULT_ARCHIVE =
1116
LINK_STATUS =
1118
LINK_STATUS =
1117
LINK_OK = true
1119
LINK_OK = true
1118
LINK_FAILED = false; exit 1
1120
LINK_FAILED = false; exit 1
1119
RECIPE_RESULT_LINK =
1121
RECIPE_RESULT_LINK =
1120
endif
1122
endif