Subversion Repositories eduke32

Rev

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

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