Subversion Repositories eduke32

Rev

Rev 3497 | Rev 3551 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1739 helixhorne 1
 
2
## source/jaudiolib/Makefile
3
4
 
3275 hendricks2 5
6
 
1739 helixhorne 7
PRETTY_OUTPUT ?= 1
1791 helixhorne 8
1739 helixhorne 9
 
3096 hendricks2 10
CC=gcc
11
CXX=g++
12
AS=nasm
13
AR=ar
14
RC=windres
15
RANLIB=ranlib
16
STRIP=strip
17
18
 
3122 hendricks2 19
L_CXX=$(CXX)
20
21
 
3096 hendricks2 22
23
 
24
    CC=clang -x c -std=gnu89
3116 hendricks2 25
    CXX=clang -x c++
26
    L_CC=clang -std=gnu89
3122 hendricks2 27
    L_CXX=clang
28
endif
3096 hendricks2 29
30
 
3278 hendricks2 31
 
32
    ifeq ($(strip $(DEVKITPPC)),)
33
        $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
34
    endif
35
36
 
37
38
 
39
    STRIP=powerpc-eabi-strip
40
endif
41
42
 
3096 hendricks2 43
ifndef GCC_MAJOR
3278 hendricks2 44
    GCC_MAJOR    := $(shell $(CC) -dumpversion 2>&1 | cut -d'.' -f1)
45
endif
46
ifeq ($(GCC_MAJOR),)
47
    GCC_MAJOR    := 4
48
endif
49
ifndef GCC_MINOR
50
    GCC_MINOR    := $(shell $(CC) -dumpversion 2>&1 | cut -d'.' -f2)
51
endif
52
ifeq ($(GCC_MINOR),)
53
    GCC_MINOR    := 7
54
endif
55
3096 hendricks2 56
 
57
ifndef SYSARCH
3278 hendricks2 58
    SYSARCH:=$(strip $(shell uname -m))
59
endif
60
3096 hendricks2 61
 
62
# the outside world. This allows cross-compilation by overriding
63
# CC and giving us PLATFORM specifically.
64
#
65
ifndef PLATFORM
66
    uname:=$(strip $(shell uname -s))
3278 hendricks2 67
    PLATFORM=UNKNOWN
3096 hendricks2 68
    ifeq ($(findstring Linux,$(uname)),Linux)
69
        PLATFORM=LINUX
70
    endif
71
    ifeq ($(findstring BSD,$(uname)),BSD)
72
        PLATFORM=BSD
73
    endif
74
    ifeq ($(findstring MINGW,$(uname)),MINGW)
75
        PLATFORM=WINDOWS
76
    endif
77
    ifeq ($(findstring Darwin,$(uname)),Darwin)
78
        PLATFORM=DARWIN
79
    endif
80
    ifeq ($(findstring BeOS,$(uname)),BeOS)
81
        PLATFORM=BEOS
82
    endif
83
    ifeq ($(findstring skyos,$(uname)),skyos)
84
        PLATFORM=SKYOS
85
    endif
86
    ifeq ($(findstring QNX,$(uname)),QNX)
87
        PLATFORM=QNX
88
    endif
89
    ifeq ($(findstring SunOS,$(uname)),SunOS)
90
        PLATFORM=SUNOS
91
    endif
92
    ifeq ($(findstring syllable,$(uname)),syllable)
93
        PLATFORM=SYLLABLE
94
    endif
95
endif
96
97
 
3272 hendricks2 98
    SUBPLATFORM=
99
    ifeq ($(PLATFORM),LINUX)
100
        SUBPLATFORM=LINUX
101
    endif
102
    ifeq ($(PLATFORM),DINGOO)
103
        SUBPLATFORM=LINUX
104
    endif
105
    ifeq ($(PLATFORM),GCW)
106
        SUBPLATFORM=LINUX
107
    endif
108
    ifeq ($(PLATFORM),CAANOO)
109
        SUBPLATFORM=LINUX
110
    endif
111
endif
112
113
 
3278 hendricks2 114
 
115
 
2476 hendricks2 116
EXESUFFIX_OVERRIDE ?=
117
118
 
2398 hendricks2 119
# Like above, use absolute paths.
120
APPLE_FRAMEWORKS ?=/Library/Frameworks
121
# Without the resource files packaged in the .app bundle, the startupwindow produces errors, so give it an off switch.
3368 hendricks2 122
OSX_STARTUPWINDOW ?= 1
3278 hendricks2 123
2398 hendricks2 124
 
1739 helixhorne 125
#  USE_OPENGL     - enables basic OpenGL Polymost renderer
1820 terminx 126
#  POLYMER        - enables fancy Polymer renderer
127
#  NOASM          - disables the use of inline assembly pragmas
1739 helixhorne 128
#  LINKED_GTK     - enables compile-time linkage to GTK
129
#
130
POLYMER = 1
131
USE_OPENGL = 1
132
NOASM = 0
133
LINKED_GTK = 0
134
BUILD32_ON_64 ?= 0
1907 helixhorne 135
# DO NOT SET THIS TO 1 AND COMMIT IT.
1850 terminx 136
USE_LIBPNG ?= 1
2843 helixhorne 137
USE_LIBVPX ?= 1
2076 helixhorne 138
NETCODE ?= 1
3260 helixhorne 139
1739 helixhorne 140
 
141
    POLYMER = 0
142
    USE_LIBVPX = 0
1933 helixhorne 143
endif
1739 helixhorne 144
145
 
146
 
147
#  CPLUSPLUS - 1 = enable C++ building
3116 hendricks2 148
#  RELEASE - 1 = no debugging
1739 helixhorne 149
#  DEBUGANYWAY - 1 = include debug symbols even when generating release code
150
#  DISABLEINLINING - 1 = compile inline functions as extern instead of static inline
3116 hendricks2 151
#  FORCEWARNINGS - 1 = do not disable any compiler warnings within the source
3237 hendricks2 152
#  KRANDDEBUG - 1 = include logging of krand() calls for debugging the demo system
1739 helixhorne 153
#  EFENCE  - 1 = compile with Electric Fence for malloc() debugging
154
#  OPTLEVEL	- 0..3 = GCC optimization strategy
155
#  LTO - 1 = enable link-time optimization, for GCC 4.5 and up
1856 helixhorne 156
#
1739 helixhorne 157
CPLUSPLUS?=0
3116 hendricks2 158
RELEASE?=1
1739 helixhorne 159
DEBUGANYWAY?=0
160
KRANDDEBUG?=0
161
DISABLEINLINING?=0
3116 hendricks2 162
FORCEWARNINGS?=0
3237 hendricks2 163
EFENCE?=0
1739 helixhorne 164
DMALLOC?=0
2254 helixhorne 165
OPTLEVEL?=2
1739 helixhorne 166
PROFILER?=0
167
MUDFLAP?=0
1850 terminx 168
1739 helixhorne 169
 
3422 helixhorne 170
    override STRIP=
3423 helixhorne 171
endif
3422 helixhorne 172
ifneq ($(DEBUGANYWAY),0)
173
    override STRIP=
3423 helixhorne 174
endif
3422 helixhorne 175
176
 
3122 hendricks2 177
    LTO=1
178
    ifneq (0,$(CLANG))
179
        ifeq ($(PLATFORM), WINDOWS)
180
            LTO=0
181
        endif
182
    endif
183
endif
184
185
 
3278 hendricks2 186
    F_NO_STACK_PROTECTOR := -fno-stack-protector
3096 hendricks2 187
    # there are some link-time issues with stack protectors, so make it possible to override
188
    F_STACK_PROTECTOR_ALL ?= -fstack-protector-all
189
    ifeq (0,$(CLANG))
190
        F_JUMP_TABLES := -fjump-tables
191
    endif
192
    M_TUNE_GENERIC := -mtune=generic
193
    M_STACKREALIGN := -mstackrealign
194
    W_STRICT_OVERFLOW := -Wstrict-overflow=1
195
endif
196
197
 
3278 hendricks2 198
    ifndef COMPILERTARGET
199
        COMPILERTARGET:=$(strip $(shell $(CC) -dumpmachine))
200
    endif
201
202
 
203
    ifeq ($(findstring x86_64,$(COMPILERTARGET)),x86_64)
204
        SYSARCH:=x86_64
205
        WINBITS=64
206
    endif
207
208
 
209
endif
210
211
 
3096 hendricks2 212
    ifndef DARWINVERSION
3278 hendricks2 213
        DARWINVERSION:=$(strip $(shell uname -r | cut -d . -f 1))
214
    endif
215
    ifeq (1,$(strip $(shell expr $(DARWINVERSION) \< 10)))
3096 hendricks2 216
        DARWIN9 ?= 1
217
    endif
218
219
 
3122 hendricks2 220
3096 hendricks2 221
 
222
        F_JUMP_TABLES :=
223
        W_STRICT_OVERFLOW :=
224
    endif
225
226
 
227
        BASECOMMONFLAGS += $(F_NO_STACK_PROTECTOR)
3122 hendricks2 228
    else
3096 hendricks2 229
        ifeq ($(findstring ppc,$(ARCH)),ppc)
230
            BASECOMMONFLAGS += $(F_NO_STACK_PROTECTOR)
3122 hendricks2 231
        endif
3096 hendricks2 232
    endif
233
    ifneq (0,$(OSX_STARTUPWINDOW))
3334 hendricks2 234
        BASECOMMONFLAGS+= -DOSX_STARTUPWINDOW
235
    endif
236
endif
3096 hendricks2 237
238
 
239
    ifeq ($(PLATFORM), WII)
240
        OPTOPT=
241
    else
242
        OPTOPTARCH=$(ARCH)
243
        ifeq (,$(OPTOPTARCH))
244
            OPTOPTARCH=$(SYSARCH)
245
        endif
246
247
 
248
            OPTOPT=-march=pentium3 $(M_TUNE_GENERIC) -mmmx
249
            # -msse2 -mfpmath=sse,387 -malign-double $(M_STACKREALIGN)
250
        else
251
            OPTOPT=
252
        endif
253
    endif
254
255
 
256
        OPTOPT+= $(CUSTOMOPT)
257
    endif
258
endif
259
260
 
1739 helixhorne 261
    RELEASE=0
262
endif
263
ifneq (0,$(PROFILER))
264
    DEBUGANYWAY=1
265
endif
266
267
 
268
 
269
 
270
BASECFLAGS=
3278 hendricks2 271
BASECONLYFLAGS=-Wimplicit -Wdeclaration-after-statement
3097 hendricks2 272
BASECXXFLAGS= -fno-exceptions -fno-rtti -fpermissive -Wno-write-strings -Wno-narrowing
3166 helixhorne 273
BASEASFLAGS=-s #-g
2520 hendricks2 274
BASELDFLAGS=
275
276
 
3278 hendricks2 277
 
278
    ifeq (1,$(strip $(shell expr $(GCC_MINOR) \>= 1)))
279
        BASECFLAGS+= -Wno-attributes
280
    endif
281
endif
282
283
 
2685 hendricks2 284
    override USE_LIBVPX = 0
285
endif
286
287
 
3219 hendricks2 288
BASELIBDIRS=
3278 hendricks2 289
ifneq (0,$(USE_LIBVPX))
1933 helixhorne 290
    # On Windows, we link statically to libvpx
2038 helixhorne 291
    BASELIBS+= -lvpx
3219 hendricks2 292
endif
1933 helixhorne 293
1852 helixhorne 294
 
2292 helixhorne 295
 
296
    # debug build or DEBUGANYWAY=1 --> -g flag
297
    ifneq (0,$(CLANG))
2672 helixhorne 298
        debug=-g
2292 helixhorne 299
    else ifeq ($(PLATFORM), WII)
2685 hendricks2 300
        debug=-g
301
    else
2292 helixhorne 302
        debug=-ggdb
303
    endif
304
endif
305
306
 
1739 helixhorne 307
    # Debugging disabled
308
    debug+= -O$(OPTLEVEL)
2292 helixhorne 309
    ifeq (0,$(CLANG))
2672 helixhorne 310
        debug+= -funswitch-loops
2292 helixhorne 311
        ifeq (1,$(strip $(shell expr $(GCC_MAJOR) \< 4)))
3278 hendricks2 312
            LTO=0
313
        endif
314
        ifeq (1,$(strip $(shell expr $(GCC_MAJOR) = 4)))
315
            ifeq (1,$(strip $(shell expr $(GCC_MINOR) \< 6)))
316
                LTO=0
317
            endif
318
        endif
319
    endif
2182 helixhorne 320
    ifeq (0,$(DEBUGANYWAY))
2040 helixhorne 321
        debug+= -fomit-frame-pointer -DNDEBUG
2239 helixhorne 322
    else
3138 Plagman 323
        debug+= -DDEBUGGINGAIDS
324
    endif
2040 helixhorne 325
    ifneq (0,$(LTO))
1856 helixhorne 326
        BASELDFLAGS+= -flto
2520 hendricks2 327
        debug+= -DUSING_LTO -flto
2107 helixhorne 328
    endif
1856 helixhorne 329
else
1739 helixhorne 330
    # Debugging enabled
331
    debug+= -O0
2292 helixhorne 332
333
 
2270 helixhorne 334
        debug+= -DDEBUGGINGAIDS
335
    else
336
        debug+= -DDEBUGGINGAIDS=2
337
    endif
338
339
 
2672 helixhorne 340
#        CLANG_MAJOR := $(shell clang -dM -E -x c /dev/null | grep __clang_major__ | awk '{ print $$3 }')
2292 helixhorne 341
        # KEEPINSYNC with build/Makefile:
3292 helixhorne 342
        BASECFLAGS+= -Xclang -fcatch-undefined-behavior
3122 hendricks2 343
#        ifeq ($(CLANG_MAJOR),3)
2292 helixhorne 344
#            debug+= -faddress-sanitizer
345
#        endif
346
    endif
2160 helixhorne 347
    ifeq ($(SUBPLATFORM),LINUX)
3272 hendricks2 348
        BASELIBS+=-rdynamic
3219 hendricks2 349
    endif
1770 plagman 350
    ifneq (0,$(MUDFLAP))
1850 terminx 351
        BASELIBS+= -lmudflapth
3219 hendricks2 352
        debug+= -fmudflapth
1850 terminx 353
    endif
354
    ifneq (0,$(PROFILER))
1739 helixhorne 355
        ifneq ($(PLATFORM),DARWIN)
3278 hendricks2 356
            BASELIBS+= -lprofiler
357
        endif
358
        debug+= -pg
1739 helixhorne 359
    endif
360
    ifneq (0,$(KRANDDEBUG))
361
        debug+=-DKRANDDEBUG=1
362
    endif
363
endif
364
365
 
3278 hendricks2 366
ifeq (0,$(CLANG))
2672 helixhorne 367
#    W_NO_UNUSED_RESULT := $(shell echo '' | $(CC) -E -Wno-unused-result - 2>/dev/null && echo -Wno-unused-result)
2972 hendricks2 368
#    W_NO_UNUSED_RESULT := $(findstring -Wno-unused-result,$(W_NO_UNUSED_RESULT))
369
    ifeq (1,$(strip $(shell expr $(GCC_MAJOR) \>= 4)))
3278 hendricks2 370
        ifeq (1,$(strip $(shell expr $(GCC_MINOR) \>= 4)))
371
            W_NO_UNUSED_RESULT := -Wno-unused-result
372
        endif
373
    endif
374
endif
2159 helixhorne 375
1791 helixhorne 376
 
3097 hendricks2 377
    -Wpointer-arith \
2797 helixhorne 378
    -Wextra \
379
    #-Wstrict-prototypes \
380
    #-Waggregate-return \
381
    #-Wwrite-strings \
382
    #-Wcast-qual -Wcast-align \
383
    #-Waddress -Wlogical-op
384
385
 
3122 hendricks2 386
	-funsigned-char -fno-strict-aliasing -DNO_GCC_BUILTINS -D_FORTIFY_SOURCE=2 \
1739 helixhorne 387
	$(F_JUMP_TABLES) $(W_NO_UNUSED_RESULT) $(ARCH)
2797 helixhorne 388
ifneq (0,$(CLANG))
2672 helixhorne 389
    BASECOMMONFLAGS+= -Wno-unused-value -Wno-parentheses
3122 hendricks2 390
endif
2159 helixhorne 391
BASECOMMONFLAGS+= -Wno-char-subscripts
3496 hendricks2 392
2159 helixhorne 393
 
3260 helixhorne 394
    BASECOMMONFLAGS+= -DNETCODE_DISABLE
395
endif
396
3148 helixhorne 397
 
3260 helixhorne 398
 
3275 hendricks2 399
ifeq ($(PLATFORM),WINDOWS)
400
    BASELIBDIRS+= -L$(abspath $(dir $(MAKEFILE_COMMON))Windows/lib$(WINLIB))
3278 hendricks2 401
    BASECOMMONFLAGS+= -I$(abspath $(dir $(MAKEFILE_COMMON))Windows/include)
3275 hendricks2 402
endif
403
ifeq ($(PLATFORM),DARWIN)
404
    # include port and brew
3278 hendricks2 405
    BASELIBDIRS+= -L$(abspath $(dir $(MAKEFILE_COMMON))Apple/lib) \
406
        -L/opt/local/lib -L/usr/local/lib
407
    BASECOMMONFLAGS+= -I$(abspath $(dir $(MAKEFILE_COMMON))Apple/include) \
408
        -I/opt/local/include -I/sw/include -I/usr/local/include
409
endif
3275 hendricks2 410
411
 
3148 helixhorne 412
LUNATIC=0
413
LUAJIT=luajit
414
415
 
416
LUAJIT_WIN_SRC:= g:/mod/luajit-2.0/src
3517 helixhorne 417
3148 helixhorne 418
 
419
    # FIXME: Lunatic doesn't build with inlining because of wacky include
420
    # chains!
421
    override DISABLEINLINING=1
422
423
 
424
        BASECOMMONFLAGS+= -I$(LUAJIT_WIN_SRC)
425
    else
426
        BASECOMMONFLAGS+= -I/usr/local/include/luajit-2.0
427
    endif
428
    BASECOMMONFLAGS+= -I$(SRC)/lunatic -DLUNATIC
3410 helixhorne 429
3148 helixhorne 430
 
3517 helixhorne 431
    # XXX: Runs way too many times because it's a "recursively expanded" variable.
432
    DEFS_BC_SIZE = $(shell $(LUAJIT) -bg -t h $(SRC)/lunatic/defs.ilua -)
433
    BASECOMMONFLAGS+= -DLUNATIC_DEFS_BC_SIZE=$(word 3, $(DEFS_BC_SIZE))
434
435
 
3148 helixhorne 436
        BASELIBS+= -lluajit
3275 hendricks2 437
    else
3148 helixhorne 438
        BASELIBS+= -lluajit-5.1
3219 hendricks2 439
    endif
3148 helixhorne 440
endif
441
442
 
443
444
 
3116 hendricks2 445
    BASECOMMONFLAGS+= -DDISABLE_INLINING
3122 hendricks2 446
endif
3116 hendricks2 447
ifneq (0,$(FORCEWARNINGS))
3237 hendricks2 448
    BASECOMMONFLAGS+= -DFORCE_WARNINGS
449
endif
450
3116 hendricks2 451
 
3096 hendricks2 452
453
 
2718 helixhorne 454
ifdef EDUKE32_MY_DEVELOPER_ID
455
    BASECOMMONFLAGS+= -DMY_DEVELOPER_ID=$(EDUKE32_MY_DEVELOPER_ID)
3122 hendricks2 456
endif
2718 helixhorne 457
458
 
1852 helixhorne 459
    BASECOMMONFLAGS+= -DUSE_LIBPNG
3122 hendricks2 460
endif
1852 helixhorne 461
ifneq (0,$(USE_LIBVPX))
1933 helixhorne 462
    BASECOMMONFLAGS+= -DUSE_LIBVPX
3122 hendricks2 463
endif
1933 helixhorne 464
1739 helixhorne 465
 
2059 hendricks2 466
    BASELIBS+= -lefence
3219 hendricks2 467
    BASECOMMONFLAGS+= -DEFENCE
3122 hendricks2 468
endif
2059 hendricks2 469
ifneq (0,$(DMALLOC))
2254 helixhorne 470
    BASELIBS+= -ldmalloc
3219 hendricks2 471
    BASECOMMONFLAGS+= -DDMALLOC
3122 hendricks2 472
endif
2254 helixhorne 473
2059 hendricks2 474
 
1739 helixhorne 475
EROOT:=build
476
477
 
478
EXESUFFIX=
479