GNUmakefile 22.9 KB
Newer Older
1
#
2
# EDuke32 Makefile for GNU Make
3
4
#

5
6
7
### Global Profiles
ifeq ($(FURY),1)
    APPBASENAME := fury
8
    APPNAME := Ion Fury
9
    NETCODE := 0
10
    POLYMER := 0
11
    RETAIL_MENU := 1
12
13
    STANDALONE := 1
    USE_LIBVPX := 0
14
    SDL_STATIC := 1
15
16
17
endif

### Platform and Toolchain Configuration
18
include Common.mak
19

20
### File Extensions
21
22
asm := nasm
o := o
23
24

### Directories
25
26
source := source
obj := obj
27

28
### Functions
29
30
31
define parent
$(word 1,$(subst _, ,$1))
endef
32
define expandobjs
33
$$(addprefix $$($$(call parent,$1)_obj)/,$$(addsuffix .$$o,$$(basename $$($1_objs) $$($1_rsrc_objs) $$($1_gen_objs))))
34
35
endef
define expandsrcs
36
$(addprefix $($(call parent,$1)_src)/,$($1_objs)) $(addprefix $($(call parent,$1)_rsrc)/,$($1_rsrc_objs)) $(addprefix $($(call parent,$1)_obj)/,$($1_gen_objs))
37
38
endef
define expanddeps
39
$(strip $1 $(foreach j,$1,$(call $0,$($j_deps))))
40
41
endef
define getdeps
42
$(call expanddeps,$1_$2 $(common_$2_deps) engine)
43
44
endef

Evan Ramos's avatar
Evan Ramos committed
45

46
47
##### External Library Definitions

48
49
#### libxmp-lite

50
libxmplite := libxmp-lite
51

52
libxmplite_objs := \
53
    common.c \
54
55
56
57
58
59
    control.c \
    dataio.c \
    effects.c \
    filter.c \
    format.c \
    hio.c \
60
61
    it_load.c \
    itsex.c \
62
63
64
65
66
    lfo.c \
    load.c \
    load_helpers.c \
    memio.c \
    mix_all.c \
67
68
69
    mixer.c \
    mod_load.c \
    mtm_load.c \
70
71
72
    period.c \
    player.c \
    read_event.c \
73
74
    s3m_load.c \
    sample.c \
75
76
77
    scan.c \
    smix.c \
    virtual.c \
78
    win32.c \
79
    xm_load.c \
80

81
82
83
84
libxmplite_root := $(source)/$(libxmplite)
libxmplite_src := $(libxmplite_root)/src
libxmplite_inc := $(libxmplite_root)/include
libxmplite_obj := $(obj)/$(libxmplite)
85

86
libxmplite_cflags := -DHAVE_ROUND -DLIBXMP_CORE_PLAYER -DLIBXMP_NO_PROWIZARD -DLIBXMP_NO_DEPACKERS -DBUILDING_STATIC -I$(libxmplite_inc)/libxmp-lite -Wno-unused-parameter -Wno-sign-compare
87
88


89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#### PhysicsFS

physfs := physfs

physfs_objs := \
    physfs.c \
    physfs_archiver_7z.c \
    physfs_archiver_dir.c \
    physfs_archiver_grp.c \
    physfs_archiver_hog.c \
    physfs_archiver_iso9660.c \
    physfs_archiver_mvl.c \
    physfs_archiver_qpak.c \
    physfs_archiver_slb.c \
    physfs_archiver_unpacked.c \
    physfs_archiver_vdf.c \
    physfs_archiver_wad.c \
    physfs_archiver_zip.c \
    physfs_byteorder.c \
    physfs_unicode.c \

ifeq ($(PLATFORM),APPLE)
    physfs_objs += physfs_platform_apple.m
else ifeq ($(PLATFORM),WINDOWS)
    physfs_objs += physfs_platform_windows.c
else
    physfs_objs += physfs_platform_unix.c
endif

physfs_root := $(source)/$(physfs)
physfs_src := $(physfs_root)/src
physfs_inc := $(physfs_root)/include
physfs_obj := $(obj)/$(physfs)

physfs_cflags :=


126
127
128
129
130
131
132
133
134
135
136
137
#### glad

glad := glad

glad_objs := \
    glad.c \

glad_root := $(source)/$(glad)
glad_src := $(glad_root)/src
glad_inc := $(glad_root)/include
glad_obj := $(obj)/$(glad)

Evan Ramos's avatar
Evan Ramos committed
138
glad_cflags :=
Evan Ramos's avatar
Evan Ramos committed
139

140
141
142
143
ifeq ($(RENDERTYPE),WIN)
    glad_objs += glad_wgl.c
endif

144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#### mimalloc

mimalloc := mimalloc

mimalloc_objs := \
    alloc.c \
    alloc-aligned.c \
    alloc-posix.c \
    arena.c \
    bitmap.c \
    heap.c \
    init.c \
    options.c \
    os.c \
    page.c \
    random.c \
    region.c \
    segment.c \
    stats.c \

ifeq ($(PLATFORM),APPLE)
    mimalloc_objs += alloc-override-osx.c
endif

mimalloc_root := $(source)/$(mimalloc)
mimalloc_src := $(mimalloc_root)/src
mimalloc_inc := $(mimalloc_root)/include
mimalloc_obj := $(obj)/$(mimalloc)

173
mimalloc_cflags := -D_WIN32_WINNT=0x0600 -DMI_USE_RTLGENRANDOM -DMI_SHOW_ERRORS -I$(mimalloc_inc) -fexceptions -Wno-cast-qual -Wno-class-memaccess -Wno-unknown-pragmas -Wno-array-bounds -Wno-null-dereference
174

175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#### imgui

imgui := imgui

imgui_objs := \
    imgui.cpp \
    imgui_demo.cpp \
    imgui_draw.cpp \
    imgui_impl_opengl3.cpp \
    imgui_impl_sdl.cpp \
    imgui_tables.cpp \
    imgui_widgets.cpp \

imgui_root := $(source)/$(imgui)
imgui_src := $(imgui_root)/src
imgui_inc := $(imgui_root)/include
imgui_obj := $(obj)/$(imgui)

imgui_cflags := -I$(imgui_inc) -Wno-cast-qual -Wno-cast-function-type

195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#### Voidwrap

voidwrap := voidwrap

voidwrap_objs := \
    voidwrap_steam.cpp

voidwrap_root := $(source)/$(voidwrap)
voidwrap_src := $(voidwrap_root)/src
voidwrap_inc := $(voidwrap_root)/include
voidwrap_obj := $(obj)/$(voidwrap)

ifeq ($(IMPLICIT_ARCH),x86_64)
    ifeq ($(PLATFORM),WINDOWS)
        voidwrap_lib := voidwrap_steam_x64.dll
        steamworks_lib := win64/steam_api64.dll
    else
212
        voidwrap_lib := libvoidwrap_steam.so
213
214
215
216
217
218
219
        steamworks_lib := linux64/libsteam_api.so
    endif
else
    ifeq ($(PLATFORM),WINDOWS)
        voidwrap_lib := voidwrap_steam_x86.dll
        steamworks_lib := steam_api.dll
    else
220
        voidwrap_lib := libvoidwrap_steam.so
221
222
223
224
        steamworks_lib := linux32/libsteam_api.so
    endif
endif

225
voidwrap_cflags := -I$(voidwrap_root)/sdk/public/steam -fPIC -fvisibility=hidden -Wno-invalid-offsetof
226

227

228
229
230
##### Component Definitions

#### EBacktrace
Evan Ramos's avatar
Evan Ramos committed
231

232
233
ifndef ebacktrace_dll
    ebacktrace_dll := ebacktrace1.dll
Evan Ramos's avatar
Evan Ramos committed
234
    ifeq ($(findstring x86_64,$(COMPILERTARGET)),x86_64)
235
        ebacktrace_dll := ebacktrace1-64.dll
Evan Ramos's avatar
Evan Ramos committed
236
237
238
    endif
endif

239

240
#### BUILD Engine
241

242
engine := build
243

244
245
246
247
engine_root := $(source)/$(engine)
engine_src := $(engine_root)/src
engine_inc := $(engine_root)/include
engine_obj := $(obj)/$(engine)
248

249
engine_cflags := -I$(engine_src) -I$(mimalloc_inc) -I$(imgui_inc)
Evan Ramos's avatar
Evan Ramos committed
250

251
252
253
254
255
engine_deps := mimalloc

ifneq (1,$(SDL_TARGET))
    engine_deps += imgui
endif
256

257
258
259
260
ifneq (0,$(USE_PHYSFS))
    engine_deps += physfs
endif

261
engine_objs := \
262
    asan_guarded_allocator.cpp \
263
    2d.cpp \
264
265
    baselayer.cpp \
    cache1d.cpp \
266
267
    clip.cpp \
    colmatch.cpp \
268
    common.cpp \
269
    communityapi.cpp \
270
    compat.cpp \
271
    cpuid.cpp \
272
273
    crc32.cpp \
    defs.cpp \
274
    dxtfilter.cpp \
275
    enet.cpp \
276
    engine.cpp \
277
    fix16.cpp \
278
279
    hash.cpp \
    hightile.cpp \
280
    klzw.cpp \
281
    kplib.cpp \
282
    loguru.cpp \
283
    lz4.c \
284
285
286
287
288
    md4.cpp \
    mhk.cpp \
    miniz.c \
    miniz_tdef.c \
    miniz_tinfl.c \
289
    mmulti.cpp \
290
    mutex.cpp \
291
    osd.cpp \
292
293
294
295
296
    palette.cpp \
    pngwrite.cpp \
    polymost.cpp \
    polymost1Frag.glsl \
    polymost1Vert.glsl \
297
    pragmas.cpp \
298
299
    rev.cpp \
    screenshot.cpp \
Evan Ramos's avatar
Evan Ramos committed
300
    screentext.cpp \
301
    scriptfile.cpp \
302
303
    sjson.cpp \
    smalltextfont.cpp \
Richard Gobeille's avatar
Richard Gobeille committed
304
305
306
    smmalloc.cpp \
    smmalloc_generic.cpp \
    smmalloc_tls.cpp \
307
    softsurface.cpp \
308
309
310
    texcache.cpp \
    textfont.cpp \
    tiles.cpp \
311
    timer.cpp \
312
    vfs.cpp \
313
    xxhash.c \
314

315
engine_editor_objs := \
316
317
318
    build.cpp \
    config.cpp \
    defs.cpp \
319

320
engine_tools_objs := \
321
    colmatch.cpp \
322
323
    compat.cpp \
    crc32.cpp \
324
325
    klzw.cpp \
    kplib.cpp \
326
    loguru.cpp \
327
    lz4.cpp \
328
    pragmas.cpp \
Richard Gobeille's avatar
Richard Gobeille committed
329
330
331
    smmalloc.cpp \
    smmalloc_generic.cpp \
    smmalloc_tls.cpp \
332
    vfs.cpp \
333

334
ifeq (0,$(NOASM))
335
  engine_objs += a.nasm
336
else
337
  engine_objs += a-c.cpp
338
339
endif
ifeq (1,$(USE_OPENGL))
340
    engine_objs += glbuild.cpp glsurface.cpp voxmodel.cpp mdsprite.cpp tilepacker.cpp
341
    engine_deps += glad
342
    ifeq (1,$(POLYMER))
343
        engine_objs += polymer.cpp
344
345
346
    endif
endif
ifeq ($(PLATFORM),DARWIN)
347
    engine_objs += osxbits.mm
348
    engine_tools_objs += osxbits.mm
349
    ifeq ($(STARTUP_WINDOW),1)
350
        engine_editor_objs += startosx.editor.mm
351
    endif
352
    ifeq ($(SDL_TARGET),1)
353
        ifneq ($(SDL_FRAMEWORK),0)
354
            engine_objs += SDLMain.mm
355
        endif
356
357
358
    endif
endif
ifeq ($(PLATFORM),WINDOWS)
359
    engine_objs += winbits.cpp
360
    ifeq ($(STARTUP_WINDOW),1)
361
        engine_editor_objs += startwin.editor.cpp
362
    endif
363
endif
364
ifeq ($(PLATFORM),WII)
365
    engine_objs += wiibits.cpp
366
    LINKERFLAGS += -Wl,-wrap,c_default_exceptionhandler
367
endif
368
ifeq ($(RENDERTYPE),SDL)
369
    engine_objs += sdlayer.cpp
370
371

    ifeq (1,$(HAVE_GTK2))
372
        engine_objs += gtkbits.cpp dynamicgtk.cpp
373
        ifeq ($(STARTUP_WINDOW),1)
374
            engine_editor_objs += startgtk.editor.cpp
375
        endif
376
377
378
    endif
endif
ifeq ($(RENDERTYPE),WIN)
379
    engine_objs += winlayer.cpp rawinput.cpp
380
381
endif

382
ifneq ($(USE_LIBVPX),0)
383
    engine_objs += animvpx.cpp
384
385
endif

386

387
#### mact
Evan Ramos's avatar
Evan Ramos committed
388

389
mact := mact
390

391
392
393
394
mact_root := $(source)/$(mact)
mact_src := $(mact_root)/src
mact_inc := $(mact_root)/include
mact_obj := $(obj)/$(mact)
395

396
mact_objs := \
397
    animlib.cpp \
398
399
    control.cpp \
    joystick.cpp \
400
    keyboard.cpp \
401
    scriplib.cpp \
402

Evan Ramos's avatar
Evan Ramos committed
403

404
#### AudioLib
405

406
audiolib := audiolib
407

408
audiolib_objs := \
Richard Gobeille's avatar
Richard Gobeille committed
409
    driver_adlib.cpp \
Richard Gobeille's avatar
Richard Gobeille committed
410
    driver_sf2.cpp \
411
    drivers.cpp \
412
413
    flac.cpp \
    formats.cpp \
414
    fx_man.cpp \
415
416
    gmtimbre.cpp \
    midi.cpp \
417
418
    mix.cpp \
    mixst.cpp \
419
420
421
    multivoc.cpp \
    music.cpp \
    opl3.cpp \
422
423
424
425
    pitch.cpp \
    vorbis.cpp \
    xa.cpp \
    xmp.cpp \
426

427
428
429
430
audiolib_root := $(source)/$(audiolib)
audiolib_src := $(audiolib_root)/src
audiolib_inc := $(audiolib_root)/include
audiolib_obj := $(obj)/$(audiolib)
431

432
audiolib_cflags :=
433

434
audiolib_deps :=
435
436

ifeq ($(PLATFORM),WINDOWS)
Richard Gobeille's avatar
Richard Gobeille committed
437
    audiolib_objs += driver_directsound.cpp driver_winmm.cpp 
438
endif
439
440
441
ifeq ($(SUBPLATFORM),LINUX)
    audiolib_objs += driver_alsa.cpp
endif
442

Richard Gobeille's avatar
Richard Gobeille committed
443
ifeq ($(RENDERTYPE),SDL)
444
    audiolib_objs += driver_sdl.cpp
445
446
endif

447
ifneq (0,$(HAVE_XMP))
448
449
    audiolib_cflags += -I$(libxmplite_inc)
    audiolib_deps += libxmplite
450
endif
451

452

453
#### Tools
454

455
tools := tools
456

457
tools_objs := \
458
    compat_tools.cpp \
459

460
461
462
tools_root := $(source)/$(tools)
tools_src := $(tools_root)/src
tools_obj := $(obj)/$(tools)
463

464
tools_cflags := $(engine_cflags)
465

466
tools_deps := engine_tools mimalloc
467

468
tools_targets := \
469
470
471
472
473
474
    arttool \
    bsuite \
    cacheinfo \
    generateicon \
    givedepth \
    ivfrate \
475
476
477
    kextract \
    kgroup \
    kmd2tool \
478
    map2stl \
479
480
    md2tool \
    mkpalette \
481
    transpal \
482
    unpackssi \
483
484
    wad2art \
    wad2map \
485

486
ifeq ($(PLATFORM),WINDOWS)
487
    tools_targets += enumdisplay getdxdidf
488
489
endif
ifeq ($(RENDERTYPE),SDL)
490
    tools_targets += makesdlkeytrans
491
endif
492
493


494
#### KenBuild (Test Game)
495

496
kenbuild := kenbuild
497

498
499
500
501
kenbuild_root := $(source)/$(kenbuild)
kenbuild_src := $(kenbuild_root)/src
kenbuild_rsrc := $(kenbuild_root)/rsrc
kenbuild_obj := $(obj)/$(kenbuild)
Evan Ramos's avatar
Evan Ramos committed
502

503
kenbuild_cflags := -I$(kenbuild_src)
Evan Ramos's avatar
Evan Ramos committed
504

505
506
kenbuild_game := ekenbuild
kenbuild_editor := ekenbuild-editor
Evan Ramos's avatar
Evan Ramos committed
507

508
509
kenbuild_game_deps := audiolib

510
511
kenbuild_game_proper := EKenBuild
kenbuild_editor_proper := EKenBuild Editor
512

513
kenbuild_game_objs := \
514
515
    common.cpp \
    config.cpp \
516
    kdmeng.cpp \
517
    game.cpp \
518

519
kenbuild_editor_objs := \
520
521
    bstub.cpp \
    common.cpp \
Evan Ramos's avatar
Evan Ramos committed
522

523
524
525
526
kenbuild_game_rsrc_objs :=
kenbuild_editor_rsrc_objs :=
kenbuild_game_gen_objs :=
kenbuild_editor_rsrc_objs :=
527

528
ifeq (11,$(HAVE_GTK2)$(STARTUP_WINDOW))
529
530
531
    kenbuild_game_objs += startgtk.game.cpp
    kenbuild_game_gen_objs += game_banner.c
    kenbuild_editor_gen_objs += build_banner.c
532
endif
Evan Ramos's avatar
Evan Ramos committed
533
ifeq ($(RENDERTYPE),SDL)
534
535
    kenbuild_game_rsrc_objs += game_icon.c
    kenbuild_editor_rsrc_objs += build_icon.c
Evan Ramos's avatar
Evan Ramos committed
536
537
endif
ifeq ($(PLATFORM),WINDOWS)
538
539
540
    kenbuild_game_objs += startwin.game.cpp
    kenbuild_game_rsrc_objs += gameres.rc
    kenbuild_editor_rsrc_objs += buildres.rc
541
542
endif

Evan Ramos's avatar
Evan Ramos committed
543
ifeq ($(PLATFORM),DARWIN)
544
    ifeq ($(STARTUP_WINDOW),1)
545
        kenbuild_game_objs += StartupWinController.game.mm
Evan Ramos's avatar
Evan Ramos committed
546
547
548
    endif
endif

Evan Ramos's avatar
Evan Ramos committed
549

550
#### Duke Nukem 3D
Evan Ramos's avatar
Evan Ramos committed
551

552
duke3d := duke3d
553

554
555
duke3d_game_ldflags :=
duke3d_editor_ldflags :=
556

557
558
duke3d_game_stripflags :=
duke3d_editor_stripflags :=
559

560
561
562
563
duke3d_root := $(source)/$(duke3d)
duke3d_src := $(duke3d_root)/src
duke3d_rsrc := $(duke3d_root)/rsrc
duke3d_obj := $(obj)/$(duke3d)
564

565
566
567
568
569
570
571
ifeq ($(FURY),1)
    ifeq ($(PLATFORM),WINDOWS)
        duke3d_rsrc := $(duke3d_root)/rsrc/fury
    endif
    duke3d_obj := $(obj)/fury
endif

572
duke3d_cflags := -I$(duke3d_src)
573

574
common_editor_deps := duke3d_common_editor engine_editor
575

Richard Gobeille's avatar
Richard Gobeille committed
576
duke3d_game_deps := audiolib mact
577
duke3d_editor_deps := audiolib
578

579
580
duke3d_game := eduke32
duke3d_editor := mapster32
581

582
ifneq (,$(APPBASENAME))
583
    duke3d_game := $(APPBASENAME)
584
585
endif

586
587
duke3d_game_proper := EDuke32
duke3d_editor_proper := Mapster32
588

589
duke3d_common_editor_objs := \
590
591
592
593
    m32common.cpp \
    m32def.cpp \
    m32exec.cpp \
    m32vars.cpp \
594

595
duke3d_game_objs := \
596
597
    actors.cpp \
    anim.cpp \
598
599
    cheats.cpp \
    cmdline.cpp \
600
601
602
    common.cpp \
    config.cpp \
    demo.cpp \
603
    dnames.cpp \
604
605
606
    game.cpp \
    gamedef.cpp \
    gameexec.cpp \
607
    gamestructures.cpp \
608
609
610
    gamevars.cpp \
    global.cpp \
    grpscan.cpp \
611
612
    input.cpp \
    menus.cpp \
Evan Ramos's avatar
Evan Ramos committed
613
    network.cpp \
614
    osdcmds.cpp \
615
616
617
618
619
    osdfuncs.cpp \
    player.cpp \
    premap.cpp \
    rts.cpp \
    savegame.cpp \
620
621
    sbar.cpp \
    screens.cpp \
622
623
    sector.cpp \
    sounds.cpp \
Evan Ramos's avatar
Evan Ramos committed
624
    text.cpp \
625

626
duke3d_editor_objs := \
627
628
629
630
    astub.cpp \
    common.cpp \
    grpscan.cpp \
    sounds_mapster32.cpp \
631

632
633
634
635
duke3d_game_rsrc_objs :=
duke3d_editor_rsrc_objs :=
duke3d_game_gen_objs :=
duke3d_editor_gen_objs :=
636

637
638
639
640
duke3d_game_miscdeps :=
duke3d_editor_miscdeps :=
duke3d_game_orderonlydeps :=
duke3d_editor_orderonlydeps :=
641

642
ifeq ($(SUBPLATFORM),LINUX)
643
    LIBS += -lFLAC -lasound
644
645
646
endif

ifeq ($(PLATFORM),BSD)
647
    LIBS += -lFLAC -lexecinfo
648
649
650
endif

ifeq ($(PLATFORM),DARWIN)
651
    LIBS += -lFLAC -lm \
652
            -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,OpenGL \
653
            -Wl,-framework,CoreMIDI -Wl,-framework,AudioUnit \
Evan Ramos's avatar
Evan Ramos committed
654
655
656
657
            -Wl,-framework,AudioToolbox -Wl,-framework,IOKit -Wl,-framework,AGL
    ifneq (00,$(DARWIN9)$(DARWIN10))
        LIBS += -Wl,-framework,QuickTime -lm
    endif
Evan Ramos's avatar
Evan Ramos committed
658

659
    ifeq ($(STARTUP_WINDOW),1)
660
        duke3d_game_objs += GrpFile.game.mm GameListSource.game.mm startosx.game.mm
661
    endif
662
663
endif

664
ifeq ($(PLATFORM),WINDOWS)
665
    LIBS += -lFLAC -ldsound
666
667
668
    duke3d_game_objs += winbits.cpp
    duke3d_game_rsrc_objs += gameres.rc
    duke3d_editor_rsrc_objs += buildres.rc
669
    ifeq ($(STARTUP_WINDOW),1)
670
        duke3d_game_objs += startwin.game.cpp
671
    endif
672
endif
673

674
ifeq (11,$(HAVE_GTK2)$(STARTUP_WINDOW))
675
676
677
    duke3d_game_objs += startgtk.game.cpp
    duke3d_game_gen_objs += game_banner.c
    duke3d_editor_gen_objs += build_banner.c
678
endif
679
ifeq ($(RENDERTYPE),SDL)
680
681
    duke3d_game_rsrc_objs += game_icon.c
    duke3d_editor_rsrc_objs += build_icon.c
682
endif
683

684
685

#### Shadow Warrior
686

687
sw := sw
688

689
690
691
692
sw_root := $(source)/$(sw)
sw_src := $(sw_root)/src
sw_rsrc := $(sw_root)/rsrc
sw_obj := $(obj)/$(sw)
693

694
sw_cflags := -I$(sw_src)
695

Richard Gobeille's avatar
Richard Gobeille committed
696
sw_game_deps := audiolib mact
697
sw_editor_deps := audiolib
698

699
sw_game := voidsw
Evan Ramos's avatar
Evan Ramos committed
700
sw_editor := wangulator
701

702
sw_game_proper := VoidSW
Evan Ramos's avatar
Evan Ramos committed
703
sw_editor_proper := Wangulator
704

705
sw_game_objs := \
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
    actor.cpp \
    ai.cpp \
    anim.cpp \
    border.cpp \
    break.cpp \
    bunny.cpp \
    cache.cpp \
    cheats.cpp \
    colormap.cpp \
    common.cpp \
    config.cpp \
    console.cpp \
    coolg.cpp \
    coolie.cpp \
    copysect.cpp \
    demo.cpp \
    draw.cpp \
    eel.cpp \
    game.cpp \
    girlninj.cpp \
    goro.cpp \
    grpscan.cpp \
    hornet.cpp \
    interp.cpp \
    interpsh.cpp \
731
    interpso.cpp \
732
733
734
735
736
737
738
739
740
741
742
    inv.cpp \
    jplayer.cpp \
    jsector.cpp \
    jweapon.cpp \
    lava.cpp \
    light.cpp \
    mclip.cpp \
    mdastr.cpp \
    menus.cpp \
    miscactr.cpp \
    morph.cpp \
Evan Ramos's avatar
Evan Ramos committed
743
    network.cpp \
744
745
746
747
748
749
750
751
752
753
754
    ninja.cpp \
    panel.cpp \
    player.cpp \
    predict.cpp \
    quake.cpp \
    ripper.cpp \
    ripper2.cpp \
    rooms.cpp \
    rotator.cpp \
    rts.cpp \
    save.cpp \
755
    saveable.cpp \
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
    scrip2.cpp \
    sector.cpp \
    serp.cpp \
    setup.cpp \
    skel.cpp \
    skull.cpp \
    slidor.cpp \
    sounds.cpp \
    spike.cpp \
    sprite.cpp \
    sumo.cpp \
    swconfig.cpp \
    sync.cpp \
    text.cpp \
    track.cpp \
    vator.cpp \
    vis.cpp \
    wallmove.cpp \
    warp.cpp \
    weapon.cpp \
    zilla.cpp \
    zombie.cpp \
778

779
sw_editor_objs := \
780
    bldscript.cpp \
781
    brooms.cpp \
782
783
    colormap.cpp \
    common.cpp \
784
785
786
    grpscan.cpp \
    jbhlp.cpp \
    jnstub.cpp \
787

788
789
790
791
sw_game_rsrc_objs :=
sw_editor_rsrc_objs :=
sw_game_gen_objs :=
sw_editor_gen_objs :=
792

793
ifeq (11,$(HAVE_GTK2)$(STARTUP_WINDOW))
794
795
796
    sw_game_objs += startgtk.game.cpp
    sw_game_gen_objs += game_banner.c
    sw_editor_gen_objs += build_banner.c
797
endif
798
ifeq ($(RENDERTYPE),SDL)
799
800
    sw_game_rsrc_objs += game_icon.c
    sw_editor_rsrc_objs += game_icon.c
801
802
endif
ifeq ($(PLATFORM),WINDOWS)
803
804
805
    sw_game_objs += startwin.game.cpp
    sw_game_rsrc_objs += gameres.rc
    sw_editor_rsrc_objs += buildres.rc
806
endif
807
808
809
810
811
ifeq ($(PLATFORM),DARWIN)
    ifeq ($(STARTUP_WINDOW),1)
        sw_game_objs += GrpFile.game.mm GameListSource.game.mm StartupWinController.game.mm
    endif
endif
812

813
814
815

#### Final setup

816
817
818
819
820
821
COMPILERFLAGS += \
    -I$(engine_inc) \
    -I$(mact_inc) \
    -I$(audiolib_inc) \
    -I$(glad_inc) \
    -I$(voidwrap_inc) \
822
    -I$(mimalloc_inc) \
823
    -I$(imgui_inc) \
824
825
    -MP -MMD \

826
827
828
ifneq (0,$(USE_PHYSFS))
    COMPILERFLAGS += -I$(physfs_inc) -DUSE_PHYSFS
endif
829

830
831
832
ifneq (0,$(MICROPROFILE))
  COMPILERFLAGS += -DMICROPROFILE_ENABLED=1
endif
833

834
##### Recipes
835

836
837
games := \
    duke3d \
838
    kenbuild \
839
    sw \
840

841
842
libraries := \
    audiolib \
843
844
    engine \
    glad \
845
    imgui \
846
    libxmplite \
847
    mimalloc \
848
    mact \
849
    voidwrap \
850

851
852
853
854
ifneq (0,$(USE_PHYSFS))
    libraries += physfs
endif

855
856
857
858
components := \
    $(games) \
    $(libraries) \
    tools \
859

860
861
862
roles := \
    game \
    editor \
863
864


Richard Gobeille's avatar
   
Richard Gobeille committed
865
ifeq ($(PRETTY_OUTPUT),1)
Richard Gobeille's avatar
Richard Gobeille committed
866
.SILENT:
Richard Gobeille's avatar
   
Richard Gobeille committed
867
endif
868
.PHONY: \
869
    $(addprefix clean,$(games) test utils tools) \
870
871
872
    $(engine_obj)/rev.$o \
    all \
    clang-tools \
873
874
    clean \
    printtools \
875
    printutils \
876
    rev \
877
878
    start \
    veryclean \
879

880
.SUFFIXES:
881
882
.SECONDEXPANSION:

883

884
#### Targets
885

886
887
all: duke3d

Evan Ramos's avatar
Evan Ramos committed
888
start:
Richard Gobeille's avatar
   
Richard Gobeille committed
889
	$(BUILD_STARTED)
890

891
tools: $(addsuffix $(EXESUFFIX),$(tools_targets)) | start
892
	@$(call LL,$^)
893

894
$(games): $$(foreach i,$(roles),$$($$@_$$i)$(EXESUFFIX)) | start
895
	@$(call LL,$^)
896

897
ebacktrace: $(ebacktrace_dll) | start
898
	@$(call LL,$^)
Evan Ramos's avatar
Evan Ramos committed
899

900
901
ifeq ($(PLATFORM),WII)
ifneq ($(ELF2DOL),)
902
%$(DOLSUFFIX): %$(EXESUFFIX)
903
904
endif
endif
905
906


907
define BUILDRULE
908

909
$$($1_$2)$$(EXESUFFIX): $$(foreach i,$(call getdeps,$1,$2),$$(call expandobjs,$$i)) $$($1_$2_miscdeps) | $$($1_$2_orderonlydeps)
910
	$$(LINK_STATUS)
911
	$$(RECIPE_IF) $$(LINKER) -o $$@ $$^ $$(GUI_LIBS) $$($1_$2_ldflags) $$(LIBDIRS) $$(LIBS) $$(RECIPE_RESULT_LINK)
912
913
914
ifeq ($$(PLATFORM),WII)
ifneq ($$(ELF2DOL),)
	$$(ELF2DOL) $$@ $$($1_$2)$$(DOLSUFFIX)
915
916
endif
endif
917
ifneq ($$(STRIP),)
918
	$$(STRIP) $$@ $$($1_$2_stripflags)
919
endif
920
ifeq ($$(PLATFORM),DARWIN)
921
	cp -RPf "platform/Apple/bundles/$$($1_$2_proper).app" "./"
922
	$(call MKDIR,"$$($1_$2_proper).app/Contents/MacOS")
923
	cp -f "$$($1_$2)$$(EXESUFFIX)" "$$($1_$2_proper).app/Contents/MacOS/"
924
endif
925

926
927
endef

928
$(foreach i,$(games),$(foreach j,$(roles),$(eval $(call BUILDRULE,$i,$j))))
929
930


931
#### Rules
932

933
$(ebacktrace_dll): platform/Windows/src/backtrace.c
Evan Ramos's avatar
Evan Ramos committed
934
	$(COMPILE_STATUS)
935
	$(RECIPE_IF) $(CC) $(CONLYFLAGS) -O2 -ggdb -shared -Wall -Wextra -static-libgcc -I$(engine_inc) -o $@ $^ -lbfd -liberty -limagehlp $(RECIPE_RESULT_COMPILE)
936

937
libklzw$(DLLSUFFIX): $(engine_src)/klzw.cpp
Richard Gobeille's avatar