-
Notifications
You must be signed in to change notification settings - Fork 157
/
Makefile
1489 lines (1262 loc) · 33.4 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
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
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Quake3 Unix Makefile
#
# Nov '98 by Zoid <[email protected]>
#
# Loki Hacking by Bernd Kreimeier
# and a little more by Ryan C. Gordon.
# and a little more by Rafael Barrero
# and a little more by the ioq3 cr3w
#
# GNU Make required
#
COMPILE_PLATFORM=$(shell uname | sed -e 's/_.*//' | tr '[:upper:]' '[:lower:]' | sed -e 's/\//_/g')
COMPILE_ARCH=$(shell uname -m | sed -e 's/i.86/x86/' | sed -e 's/^arm.*/arm/')
ifeq ($(shell uname -m),arm64)
COMPILE_ARCH=aarch64
endif
ifeq ($(COMPILE_PLATFORM),mingw32)
ifeq ($(COMPILE_ARCH),i386)
COMPILE_ARCH=x86
endif
endif
BUILD_CLIENT = 1
BUILD_SERVER = 1
USE_SDL = 1
USE_CURL = 1
USE_LOCAL_HEADERS= 0
USE_SYSTEM_JPEG = 0
USE_OGG_VORBIS = 1
USE_SYSTEM_OGG = 0
USE_SYSTEM_VORBIS = 0
USE_VULKAN = 1
USE_OPENGL = 1
USE_OPENGL2 = 0
USE_OPENGL_API = 1
USE_VULKAN_API = 1
USE_RENDERER_DLOPEN = 1
# valid options: opengl, vulkan, opengl2
RENDERER_DEFAULT = opengl
CNAME = quake3e
DNAME = quake3e.ded
RENDERER_PREFIX = $(CNAME)
ifeq ($(V),1)
echo_cmd=@:
Q=
else
echo_cmd=@echo
Q=@
endif
#############################################################################
#
# If you require a different configuration from the defaults below, create a
# new file named "Makefile.local" in the same directory as this file and define
# your parameters there. This allows you to change configuration without
# causing problems with keeping up to date with the repository.
#
#############################################################################
-include Makefile.local
ifeq ($(COMPILE_PLATFORM),darwin)
USE_SDL=1
USE_LOCAL_HEADERS=1
USE_RENDERER_DLOPEN = 0
endif
ifeq ($(COMPILE_PLATFORM),cygwin)
PLATFORM=mingw32
endif
ifndef PLATFORM
PLATFORM=$(COMPILE_PLATFORM)
endif
export PLATFORM
ifeq ($(PLATFORM),mingw32)
MINGW=1
endif
ifeq ($(PLATFORM),mingw64)
MINGW=1
endif
ifeq ($(COMPILE_ARCH),i86pc)
COMPILE_ARCH=x86
endif
ifeq ($(COMPILE_ARCH),amd64)
COMPILE_ARCH=x86_64
endif
ifeq ($(COMPILE_ARCH),x64)
COMPILE_ARCH=x86_64
endif
ifndef ARCH
ARCH=$(COMPILE_ARCH)
endif
export ARCH
ifneq ($(PLATFORM),$(COMPILE_PLATFORM))
CROSS_COMPILING=1
else
CROSS_COMPILING=0
ifneq ($(ARCH),$(COMPILE_ARCH))
CROSS_COMPILING=1
endif
endif
export CROSS_COMPILING
ifndef DESTDIR
DESTDIR=/usr/local/games/quake3
endif
ifndef MOUNT_DIR
MOUNT_DIR=code
endif
ifndef BUILD_DIR
BUILD_DIR=build
endif
ifndef GENERATE_DEPENDENCIES
GENERATE_DEPENDENCIES=1
endif
ifndef USE_CCACHE
USE_CCACHE=0
endif
export USE_CCACHE
ifndef USE_LOCAL_HEADERS
USE_LOCAL_HEADERS=1
endif
ifndef USE_CURL
USE_CURL=1
endif
ifndef USE_CURL_DLOPEN
ifdef MINGW
USE_CURL_DLOPEN=0
else
USE_CURL_DLOPEN=1
endif
endif
ifndef USE_OGG_VORBIS
USE_OGG_VORBIS=1
endif
ifndef USE_SYSTEM_OGG
USE_SYSTEM_OGG=1
endif
ifndef USE_SYSTEM_VORBIS
USE_SYSTEM_VORBIS=1
endif
ifeq ($(USE_RENDERER_DLOPEN),0)
ifeq ($(RENDERER_DEFAULT),opengl)
USE_OPENGL=1
USE_OPENGL2=0
USE_VULKAN=0
USE_OPENGL_API=1
USE_VULKAN_API=0
endif
ifeq ($(RENDERER_DEFAULT),opengl2)
USE_OPENGL=0
USE_OPENGL2=1
USE_VULKAN=0
USE_OPENGL_API=1
USE_VULKAN_API=0
endif
ifeq ($(RENDERER_DEFAULT),vulkan)
USE_OPENGL=0
USE_OPENGL2=0
USE_VULKAN=1
USE_OPENGL_API=0
endif
endif
ifneq ($(USE_VULKAN),0)
USE_VULKAN_API=1
endif
#############################################################################
BD=$(BUILD_DIR)/debug-$(PLATFORM)-$(ARCH)
BR=$(BUILD_DIR)/release-$(PLATFORM)-$(ARCH)
ADIR=$(MOUNT_DIR)/asm
CDIR=$(MOUNT_DIR)/client
SDIR=$(MOUNT_DIR)/server
RCDIR=$(MOUNT_DIR)/renderercommon
R1DIR=$(MOUNT_DIR)/renderer
R2DIR=$(MOUNT_DIR)/renderer2
RVDIR=$(MOUNT_DIR)/renderervk
SDLDIR=$(MOUNT_DIR)/sdl
SDLHDIR=$(MOUNT_DIR)/libsdl/include/SDL2
CMDIR=$(MOUNT_DIR)/qcommon
UDIR=$(MOUNT_DIR)/unix
W32DIR=$(MOUNT_DIR)/win32
BLIBDIR=$(MOUNT_DIR)/botlib
JPDIR=$(MOUNT_DIR)/libjpeg
OGGDIR=$(MOUNT_DIR)/libogg
VORBISDIR=$(MOUNT_DIR)/libvorbis
bin_path=$(shell which $(1) 2> /dev/null)
STRIP ?= strip
PKG_CONFIG ?= pkg-config
INSTALL=install
MKDIR=mkdir -p
ifneq ($(call bin_path, $(PKG_CONFIG)),)
ifneq ($(USE_SDL),0)
SDL_INCLUDE ?= $(shell $(PKG_CONFIG) --silence-errors --cflags-only-I sdl2)
SDL_LIBS ?= $(shell $(PKG_CONFIG) --silence-errors --libs sdl2)
else
X11_INCLUDE ?= $(shell $(PKG_CONFIG) --silence-errors --cflags-only-I x11)
X11_LIBS ?= $(shell $(PKG_CONFIG) --silence-errors --libs x11)
endif
ifeq ($(USE_SYSTEM_OGG),1)
OGG_CFLAGS ?= $(shell $(PKG_CONFIG) --silence-errors --cflags ogg || true)
OGG_LIBS ?= $(shell $(PKG_CONFIG) --silence-errors --libs ogg || echo -logg)
endif
ifeq ($(USE_SYSTEM_VORBIS),1)
VORBIS_CFLAGS ?= $(shell $(PKG_CONFIG) --silence-errors --cflags vorbisfile || true)
VORBIS_LIBS ?= $(shell $(PKG_CONFIG) --silence-errors --libs vorbisfile || echo -lvorbisfile)
endif
endif
# supply some reasonable defaults for SDL/X11
ifeq ($(X11_INCLUDE),)
X11_INCLUDE = -I/usr/X11R6/include
endif
ifeq ($(X11_LIBS),)
X11_LIBS = -lX11
endif
ifeq ($(SDL_LIBS),)
SDL_LIBS = -lSDL2
endif
# supply some reasonable defaults for ogg/vorbis
ifeq ($(OGG_FLAGS),)
OGG_FLAGS = -I$(OGGDIR)/include
endif
ifeq ($(VORBIS_FLAGS),)
VORBIS_FLAGS = -I$(VORBISDIR)/include -I$(VORBISDIR)/lib
endif
ifeq ($(USE_SYSTEM_OGG),1)
ifeq ($(OGG_LIBS),)
OGG_LIBS = -logg
endif
endif
ifeq ($(USE_SYSTEM_VORBIS),1)
ifeq ($(VORBIS_LIBS),)
VORBIS_LIBS = -lvorbisfile
endif
endif
# extract version info
ifneq ($(COMPILE_PLATFORM),darwin)
VERSION=$(shell grep ".\+define[ \t]\+Q3_VERSION[ \t]\+\+" $(CMDIR)/q_shared.h | \
sed -e 's/.*".* \([^ ]*\)"/\1/')
else
VERSION=1.32e
endif
# common qvm definition
ifeq ($(ARCH),x86_64)
HAVE_VM_COMPILED = true
else
ifeq ($(ARCH),x86)
HAVE_VM_COMPILED = true
else
HAVE_VM_COMPILED = false
endif
endif
ifeq ($(ARCH),arm)
HAVE_VM_COMPILED = true
endif
ifeq ($(ARCH),aarch64)
HAVE_VM_COMPILED = true
endif
BASE_CFLAGS =
ifeq ($(USE_SYSTEM_JPEG),1)
BASE_CFLAGS += -DUSE_SYSTEM_JPEG
endif
ifneq ($(HAVE_VM_COMPILED),true)
BASE_CFLAGS += -DNO_VM_COMPILED
endif
ifneq ($(USE_RENDERER_DLOPEN),0)
BASE_CFLAGS += -DUSE_RENDERER_DLOPEN
BASE_CFLAGS += -DRENDERER_PREFIX=\\\"$(RENDERER_PREFIX)\\\"
BASE_CFLAGS += -DRENDERER_DEFAULT="$(RENDERER_DEFAULT)"
endif
ifdef DEFAULT_BASEDIR
BASE_CFLAGS += -DDEFAULT_BASEDIR=\\\"$(DEFAULT_BASEDIR)\\\"
endif
ifeq ($(USE_LOCAL_HEADERS),1)
BASE_CFLAGS += -DUSE_LOCAL_HEADERS=1
endif
ifeq ($(USE_CURL),1)
BASE_CFLAGS += -DUSE_CURL
ifeq ($(USE_CURL_DLOPEN),1)
BASE_CFLAGS += -DUSE_CURL_DLOPEN
else
ifeq ($(MINGW),1)
BASE_CFLAGS += -DCURL_STATICLIB
endif
endif
endif
ifeq ($(USE_VULKAN_API),1)
BASE_CFLAGS += -DUSE_VULKAN_API
endif
ifeq ($(USE_OPENGL_API),1)
BASE_CFLAGS += -DUSE_OPENGL_API
endif
ifeq ($(GENERATE_DEPENDENCIES),1)
BASE_CFLAGS += -MMD
endif
ARCHEXT=
CLIENT_EXTRA_FILES=
#############################################################################
# SETUP AND BUILD -- MINGW32
#############################################################################
ifdef MINGW
ifeq ($(CROSS_COMPILING),1)
# If CC is already set to something generic, we probably want to use
# something more specific
ifneq ($(findstring $(strip $(CC)),cc gcc),)
CC=
endif
# We need to figure out the correct gcc and windres
ifeq ($(ARCH),x86_64)
MINGW_PREFIXES=x86_64-w64-mingw32 amd64-mingw32msvc
STRIP=x86_64-w64-mingw32-strip
endif
ifeq ($(ARCH),x86)
MINGW_PREFIXES=i686-w64-mingw32 i586-mingw32msvc i686-pc-mingw32
endif
ifndef CC
CC=$(firstword $(strip $(foreach MINGW_PREFIX, $(MINGW_PREFIXES), \
$(call bin_path, $(MINGW_PREFIX)-gcc))))
endif
# STRIP=$(MINGW_PREFIX)-strip -g
ifndef WINDRES
WINDRES=$(firstword $(strip $(foreach MINGW_PREFIX, $(MINGW_PREFIXES), \
$(call bin_path, $(MINGW_PREFIX)-windres))))
endif
else
# Some MinGW installations define CC to cc, but don't actually provide cc,
# so check that CC points to a real binary and use gcc if it doesn't
ifeq ($(call bin_path, $(CC)),)
CC=gcc
endif
endif
# using generic windres if specific one is not present
ifeq ($(WINDRES),)
WINDRES=windres
endif
ifeq ($(CC),)
$(error Cannot find a suitable cross compiler for $(PLATFORM))
endif
BASE_CFLAGS += -Wall -Wimplicit -Wstrict-prototypes -DUSE_ICON -DMINGW=1
BASE_CFLAGS += -Wno-unused-result -fvisibility=hidden
BASE_CFLAGS += -ffunction-sections -flto
ifeq ($(ARCH),x86_64)
ARCHEXT = .x64
BASE_CFLAGS += -m64
OPTIMIZE = -O2 -ffast-math
endif
ifeq ($(ARCH),x86)
BASE_CFLAGS += -m32
OPTIMIZE = -O2 -march=i586 -mtune=i686 -ffast-math
endif
SHLIBEXT = dll
SHLIBCFLAGS = -fPIC -fvisibility=hidden
SHLIBLDFLAGS = -shared $(LDFLAGS)
BINEXT = .exe
LDFLAGS += -mwindows -Wl,--dynamicbase -Wl,--nxcompat
LDFLAGS += -Wl,--gc-sections -fvisibility=hidden
LDFLAGS += -lwsock32 -lgdi32 -lwinmm -lole32 -lws2_32 -lpsapi -lcomctl32
LDFLAGS += -flto
CLIENT_LDFLAGS=$(LDFLAGS)
ifeq ($(USE_SDL),1)
BASE_CFLAGS += -DUSE_LOCAL_HEADERS=1 -I$(SDLHDIR)
#CLIENT_CFLAGS += -DUSE_LOCAL_HEADERS=1
ifeq ($(ARCH),x86)
CLIENT_LDFLAGS += -L$(MOUNT_DIR)/libsdl/windows/mingw/lib32
CLIENT_LDFLAGS += -lSDL2
CLIENT_EXTRA_FILES += $(MOUNT_DIR)/libsdl/windows/mingw/lib32/SDL2.dll
else
CLIENT_LDFLAGS += -L$(MOUNT_DIR)/libsdl/windows/mingw/lib64
CLIENT_LDFLAGS += -lSDL264
CLIENT_EXTRA_FILES += $(MOUNT_DIR)/libsdl/windows/mingw/lib64/SDL264.dll
endif
endif
ifeq ($(USE_CURL),1)
BASE_CFLAGS += -I$(MOUNT_DIR)/libcurl/windows/include
ifeq ($(ARCH),x86)
CLIENT_LDFLAGS += -L$(MOUNT_DIR)/libcurl/windows/mingw/lib32
else
CLIENT_LDFLAGS += -L$(MOUNT_DIR)/libcurl/windows/mingw/lib64
endif
CLIENT_LDFLAGS += -lcurl -lwldap32 -lcrypt32
endif
ifeq ($(USE_OGG_VORBIS),1)
BASE_CFLAGS += -DUSE_OGG_VORBIS $(OGG_FLAGS) $(VORBIS_FLAGS)
CLIENT_LDFLAGS += $(OGG_LIBS) $(VORBIS_LIBS)
endif
DEBUG_CFLAGS = $(BASE_CFLAGS) -DDEBUG -D_DEBUG -g -O0
RELEASE_CFLAGS = $(BASE_CFLAGS) -DNDEBUG $(OPTIMIZE)
else # !MINGW
ifeq ($(COMPILE_PLATFORM),darwin)
#############################################################################
# SETUP AND BUILD -- MACOS
#############################################################################
BASE_CFLAGS += -Wall -Wimplicit -Wstrict-prototypes -pipe
BASE_CFLAGS += -Wno-unused-result
BASE_CFLAGS += -DMACOS_X
OPTIMIZE = -O2 -fvisibility=hidden
SHLIBEXT = dylib
SHLIBCFLAGS = -fPIC -fvisibility=hidden
SHLIBLDFLAGS = -dynamiclib $(LDFLAGS)
ARCHEXT = .$(ARCH)
LDFLAGS +=
ifeq ($(ARCH),x86_64)
BASE_CFLAGS += -arch x86_64
LDFLAGS += -arch x86_64
endif
ifeq ($(ARCH),aarch64)
BASE_CFLAGS += -arch arm64
LDFLAGS += -arch arm64
endif
ifeq ($(USE_LOCAL_HEADERS),1)
MACLIBSDIR=$(MOUNT_DIR)/libsdl/macosx
BASE_CFLAGS += -I$(SDLHDIR)
CLIENT_LDFLAGS += $(MACLIBSDIR)/libSDL2-2.0.0.dylib
CLIENT_EXTRA_FILES += $(MACLIBSDIR)/libSDL2-2.0.0.dylib
else
ifneq ($(SDL_INCLUDE),)
BASE_CFLAGS += $(SDL_INCLUDE)
CLIENT_LDFLAGS = $(SDL_LIBS)
else
BASE_CFLAGS += -I/Library/Frameworks/SDL2.framework/Headers
CLIENT_LDFLAGS += -F/Library/Frameworks -framework SDL2
endif
endif
ifeq ($(USE_SYSTEM_JPEG),1)
CLIENT_LDFLAGS += -ljpeg
endif
ifeq ($(USE_OGG_VORBIS),1)
BASE_CFLAGS += -DUSE_OGG_VORBIS $(OGG_FLAGS) $(VORBIS_FLAGS)
CLIENT_LDFLAGS += $(OGG_LIBS) $(VORBIS_LIBS)
endif
DEBUG_CFLAGS = $(BASE_CFLAGS) -DDEBUG -D_DEBUG -g -O0
RELEASE_CFLAGS = $(BASE_CFLAGS) -DNDEBUG $(OPTIMIZE)
else
#############################################################################
# SETUP AND BUILD -- *NIX PLATFORMS
#############################################################################
BASE_CFLAGS += -Wall -Wimplicit -Wstrict-prototypes -pipe
BASE_CFLAGS += -Wno-unused-result
BASE_CFLAGS += -DUSE_ICON
BASE_CFLAGS += -I/usr/include -I/usr/local/include
OPTIMIZE = -O2 -fvisibility=hidden
ifeq ($(ARCH),x86_64)
ARCHEXT = .x64
else
ifeq ($(ARCH),x86)
OPTIMIZE += -march=i586 -mtune=i686
endif
endif
ifeq ($(ARCH),arm)
OPTIMIZE += -march=armv7-a
ARCHEXT = .arm
endif
ifeq ($(ARCH),aarch64)
ARCHEXT = .aarch64
endif
SHLIBEXT = so
SHLIBCFLAGS = -fPIC -fvisibility=hidden
SHLIBLDFLAGS = -shared $(LDFLAGS)
LDFLAGS += -lm
LDFLAGS += -Wl,--gc-sections -fvisibility=hidden
ifeq ($(USE_SDL),1)
BASE_CFLAGS += $(SDL_INCLUDE)
CLIENT_LDFLAGS = $(SDL_LIBS)
else
BASE_CFLAGS += $(X11_INCLUDE)
CLIENT_LDFLAGS = $(X11_LIBS)
endif
ifeq ($(USE_SYSTEM_JPEG),1)
CLIENT_LDFLAGS += -ljpeg
endif
ifeq ($(USE_CURL),1)
ifeq ($(USE_CURL_DLOPEN),0)
CLIENT_LDFLAGS += -lcurl
endif
endif
ifeq ($(USE_OGG_VORBIS),1)
BASE_CFLAGS += -DUSE_OGG_VORBIS $(OGG_FLAGS) $(VORBIS_FLAGS)
CLIENT_LDFLAGS += $(OGG_LIBS) $(VORBIS_LIBS)
endif
ifeq ($(PLATFORM),linux)
LDFLAGS += -ldl -Wl,--hash-style=both
ifeq ($(ARCH),x86)
# linux32 make ...
BASE_CFLAGS += -m32
LDFLAGS += -m32
endif
endif
DEBUG_CFLAGS = $(BASE_CFLAGS) -DDEBUG -D_DEBUG -g -O0
RELEASE_CFLAGS = $(BASE_CFLAGS) -DNDEBUG $(OPTIMIZE)
DEBUG_LDFLAGS = -rdynamic
endif # *NIX platforms
endif # !MINGW
TARGET_CLIENT = $(CNAME)$(ARCHEXT)$(BINEXT)
TARGET_REND1 = $(RENDERER_PREFIX)_opengl_$(SHLIBNAME)
TARGET_REND2 = $(RENDERER_PREFIX)_opengl2_$(SHLIBNAME)
TARGET_RENDV = $(RENDERER_PREFIX)_vulkan_$(SHLIBNAME)
TARGET_SERVER = $(DNAME)$(ARCHEXT)$(BINEXT)
STRINGIFY = $(B)/rend2/stringify$(BINEXT)
TARGETS =
ifneq ($(BUILD_SERVER),0)
TARGETS += $(B)/$(TARGET_SERVER)
endif
ifneq ($(BUILD_CLIENT),0)
TARGETS += $(B)/$(TARGET_CLIENT)
ifneq ($(USE_RENDERER_DLOPEN),0)
ifeq ($(USE_OPENGL),1)
TARGETS += $(B)/$(TARGET_REND1)
endif
ifeq ($(USE_OPENGL2),1)
TARGETS += $(B)/$(TARGET_REND2)
endif
ifeq ($(USE_VULKAN),1)
TARGETS += $(B)/$(TARGET_RENDV)
endif
endif
endif
ifeq ($(USE_CCACHE),1)
CC := ccache $(CC)
endif
ifneq ($(USE_RENDERER_DLOPEN),0)
RENDCFLAGS=$(SHLIBCFLAGS)
else
RENDCFLAGS=$(NOTSHLIBCFLAGS)
endif
define DO_CC
$(echo_cmd) "CC $<"
$(Q)$(CC) $(CFLAGS) -o $@ -c $<
endef
define DO_REND_CC
$(echo_cmd) "REND_CC $<"
$(Q)$(CC) $(CFLAGS) $(RENDCFLAGS) -o $@ -c $<
endef
define DO_REF_STR
$(echo_cmd) "REF_STR $<"
$(Q)rm -f $@
$(Q)$(STRINGIFY) $< $@
endef
define DO_BOT_CC
$(echo_cmd) "BOT_CC $<"
$(Q)$(CC) $(CFLAGS) $(BOTCFLAGS) -DBOTLIB -o $@ -c $<
endef
define DO_AS
$(echo_cmd) "AS $<"
$(Q)$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
endef
define DO_DED_CC
$(echo_cmd) "DED_CC $<"
$(Q)$(CC) $(CFLAGS) -DDEDICATED -o $@ -c $<
endef
define DO_WINDRES
$(echo_cmd) "WINDRES $<"
$(Q)$(WINDRES) -i $< -o $@
endef
ifndef SHLIBNAME
SHLIBNAME=$(ARCH).$(SHLIBEXT)
endif
#############################################################################
# MAIN TARGETS
#############################################################################
default: release
all: debug release
debug:
@$(MAKE) targets B=$(BD) CFLAGS="$(CFLAGS) $(DEBUG_CFLAGS)" LDFLAGS="$(LDFLAGS) $(DEBUG_LDFLAGS)" V=$(V)
release:
@$(MAKE) targets B=$(BR) CFLAGS="$(CFLAGS) $(RELEASE_CFLAGS)" V=$(V)
define ADD_COPY_TARGET
TARGETS += $2
$2: $1
$(echo_cmd) "CP $$<"
@cp $1 $2
endef
# These functions allow us to generate rules for copying a list of files
# into the base directory of the build; this is useful for bundling libs,
# README files or whatever else
define GENERATE_COPY_TARGETS
$(foreach FILE,$1, \
$(eval $(call ADD_COPY_TARGET, \
$(FILE), \
$(addprefix $(B)/,$(notdir $(FILE))))))
endef
ifneq ($(BUILD_CLIENT),0)
$(call GENERATE_COPY_TARGETS,$(CLIENT_EXTRA_FILES))
endif
# Create the build directories and tools, print out
# an informational message, then start building
targets: makedirs tools
@echo ""
@echo "Building quake3 in $(B):"
@echo ""
@echo " VERSION: $(VERSION)"
@echo " PLATFORM: $(PLATFORM)"
@echo " ARCH: $(ARCH)"
@echo " COMPILE_PLATFORM: $(COMPILE_PLATFORM)"
@echo " COMPILE_ARCH: $(COMPILE_ARCH)"
ifdef MINGW
@echo " WINDRES: $(WINDRES)"
endif
@echo " CC: $(CC)"
@echo ""
@echo " CFLAGS:"
@for i in $(CFLAGS); \
do \
echo " $$i"; \
done
@echo ""
@echo " Output:"
@for i in $(TARGETS); \
do \
echo " $$i"; \
done
@echo ""
ifneq ($(TARGETS),)
@$(MAKE) $(TARGETS) V=$(V)
endif
makedirs:
@if [ ! -d $(BUILD_DIR) ];then $(MKDIR) $(BUILD_DIR);fi
@if [ ! -d $(B) ];then $(MKDIR) $(B);fi
@if [ ! -d $(B)/client ];then $(MKDIR) $(B)/client;fi
@if [ ! -d $(B)/client/jpeg ];then $(MKDIR) $(B)/client/jpeg;fi
ifeq ($(USE_SYSTEM_OGG),0)
@if [ ! -d $(B)/client/ogg ];then $(MKDIR) $(B)/client/ogg;fi
endif
ifeq ($(USE_SYSTEM_VORBIS),0)
@if [ ! -d $(B)/client/vorbis ];then $(MKDIR) $(B)/client/vorbis;fi
endif
@if [ ! -d $(B)/rend1 ];then $(MKDIR) $(B)/rend1;fi
@if [ ! -d $(B)/rend2 ];then $(MKDIR) $(B)/rend2;fi
@if [ ! -d $(B)/rend2/glsl ];then $(MKDIR) $(B)/rend2/glsl;fi
@if [ ! -d $(B)/rendv ];then $(MKDIR) $(B)/rendv;fi
ifneq ($(BUILD_SERVER),0)
@if [ ! -d $(B)/ded ];then $(MKDIR) $(B)/ded;fi
endif
#############################################################################
# CLIENT/SERVER
#############################################################################
Q3REND1OBJ = \
$(B)/rend1/tr_animation.o \
$(B)/rend1/tr_arb.o \
$(B)/rend1/tr_backend.o \
$(B)/rend1/tr_bsp.o \
$(B)/rend1/tr_cmds.o \
$(B)/rend1/tr_curve.o \
$(B)/rend1/tr_flares.o \
$(B)/rend1/tr_font.o \
$(B)/rend1/tr_image.o \
$(B)/rend1/tr_image_png.o \
$(B)/rend1/tr_image_jpg.o \
$(B)/rend1/tr_image_bmp.o \
$(B)/rend1/tr_image_tga.o \
$(B)/rend1/tr_image_pcx.o \
$(B)/rend1/tr_init.o \
$(B)/rend1/tr_light.o \
$(B)/rend1/tr_main.o \
$(B)/rend1/tr_marks.o \
$(B)/rend1/tr_mesh.o \
$(B)/rend1/tr_model.o \
$(B)/rend1/tr_model_iqm.o \
$(B)/rend1/tr_noise.o \
$(B)/rend1/tr_scene.o \
$(B)/rend1/tr_shade.o \
$(B)/rend1/tr_shade_calc.o \
$(B)/rend1/tr_shader.o \
$(B)/rend1/tr_shadows.o \
$(B)/rend1/tr_sky.o \
$(B)/rend1/tr_surface.o \
$(B)/rend1/tr_vbo.o \
$(B)/rend1/tr_world.o
ifneq ($(USE_RENDERER_DLOPEN), 0)
Q3REND1OBJ += \
$(B)/rend1/q_shared.o \
$(B)/rend1/puff.o \
$(B)/rend1/q_math.o
endif
Q3REND2OBJ = \
$(B)/rend2/tr_animation.o \
$(B)/rend2/tr_backend.o \
$(B)/rend2/tr_bsp.o \
$(B)/rend2/tr_cmds.o \
$(B)/rend2/tr_curve.o \
$(B)/rend2/tr_dsa.o \
$(B)/rend2/tr_extramath.o \
$(B)/rend2/tr_extensions.o \
$(B)/rend2/tr_fbo.o \
$(B)/rend2/tr_flares.o \
$(B)/rend2/tr_font.o \
$(B)/rend2/tr_glsl.o \
$(B)/rend2/tr_image.o \
$(B)/rend2/tr_image_bmp.o \
$(B)/rend2/tr_image_jpg.o \
$(B)/rend2/tr_image_pcx.o \
$(B)/rend2/tr_image_png.o \
$(B)/rend2/tr_image_tga.o \
$(B)/rend2/tr_image_dds.o \
$(B)/rend2/tr_init.o \
$(B)/rend2/tr_light.o \
$(B)/rend2/tr_main.o \
$(B)/rend2/tr_marks.o \
$(B)/rend2/tr_mesh.o \
$(B)/rend2/tr_model.o \
$(B)/rend2/tr_model_iqm.o \
$(B)/rend2/tr_noise.o \
$(B)/rend2/tr_postprocess.o \
$(B)/rend2/tr_scene.o \
$(B)/rend2/tr_shade.o \
$(B)/rend2/tr_shade_calc.o \
$(B)/rend2/tr_shader.o \
$(B)/rend2/tr_shadows.o \
$(B)/rend2/tr_sky.o \
$(B)/rend2/tr_surface.o \
$(B)/rend2/tr_vbo.o \
$(B)/rend2/tr_world.o
ifneq ($(USE_RENDERER_DLOPEN), 0)
Q3REND2OBJ += \
$(B)/rend2/q_shared.o \
$(B)/rend2/puff.o \
$(B)/rend2/q_math.o
endif
Q3REND2STROBJ = \
$(B)/rend2/glsl/bokeh_fp.o \
$(B)/rend2/glsl/bokeh_vp.o \
$(B)/rend2/glsl/calclevels4x_fp.o \
$(B)/rend2/glsl/calclevels4x_vp.o \
$(B)/rend2/glsl/depthblur_fp.o \
$(B)/rend2/glsl/depthblur_vp.o \
$(B)/rend2/glsl/dlight_fp.o \
$(B)/rend2/glsl/dlight_vp.o \
$(B)/rend2/glsl/down4x_fp.o \
$(B)/rend2/glsl/down4x_vp.o \
$(B)/rend2/glsl/fogpass_fp.o \
$(B)/rend2/glsl/fogpass_vp.o \
$(B)/rend2/glsl/generic_fp.o \
$(B)/rend2/glsl/generic_vp.o \
$(B)/rend2/glsl/lightall_fp.o \
$(B)/rend2/glsl/lightall_vp.o \
$(B)/rend2/glsl/pshadow_fp.o \
$(B)/rend2/glsl/pshadow_vp.o \
$(B)/rend2/glsl/shadowfill_fp.o \
$(B)/rend2/glsl/shadowfill_vp.o \
$(B)/rend2/glsl/shadowmask_fp.o \
$(B)/rend2/glsl/shadowmask_vp.o \
$(B)/rend2/glsl/ssao_fp.o \
$(B)/rend2/glsl/ssao_vp.o \
$(B)/rend2/glsl/texturecolor_fp.o \
$(B)/rend2/glsl/texturecolor_vp.o \
$(B)/rend2/glsl/tonemap_fp.o \
$(B)/rend2/glsl/tonemap_vp.o
Q3RENDVOBJ = \
$(B)/rendv/tr_animation.o \
$(B)/rendv/tr_backend.o \
$(B)/rendv/tr_bsp.o \
$(B)/rendv/tr_cmds.o \
$(B)/rendv/tr_curve.o \
$(B)/rendv/tr_font.o \
$(B)/rendv/tr_image.o \
$(B)/rendv/tr_image_png.o \
$(B)/rendv/tr_image_jpg.o \
$(B)/rendv/tr_image_bmp.o \
$(B)/rendv/tr_image_tga.o \
$(B)/rendv/tr_image_pcx.o \
$(B)/rendv/tr_init.o \
$(B)/rendv/tr_light.o \
$(B)/rendv/tr_main.o \
$(B)/rendv/tr_marks.o \
$(B)/rendv/tr_mesh.o \
$(B)/rendv/tr_model.o \
$(B)/rendv/tr_model_iqm.o \
$(B)/rendv/tr_noise.o \
$(B)/rendv/tr_scene.o \
$(B)/rendv/tr_shade.o \
$(B)/rendv/tr_shade_calc.o \
$(B)/rendv/tr_shader.o \
$(B)/rendv/tr_shadows.o \
$(B)/rendv/tr_sky.o \
$(B)/rendv/tr_surface.o \
$(B)/rendv/tr_world.o \
$(B)/rendv/vk.o \
$(B)/rendv/vk_flares.o \
$(B)/rendv/vk_vbo.o \
ifneq ($(USE_RENDERER_DLOPEN), 0)
Q3RENDVOBJ += \
$(B)/rendv/q_shared.o \
$(B)/rendv/puff.o \
$(B)/rendv/q_math.o
endif
JPGOBJ = \
$(B)/client/jpeg/jaricom.o \
$(B)/client/jpeg/jcapimin.o \
$(B)/client/jpeg/jcapistd.o \
$(B)/client/jpeg/jcarith.o \
$(B)/client/jpeg/jccoefct.o \
$(B)/client/jpeg/jccolor.o \
$(B)/client/jpeg/jcdctmgr.o \
$(B)/client/jpeg/jchuff.o \
$(B)/client/jpeg/jcinit.o \
$(B)/client/jpeg/jcmainct.o \
$(B)/client/jpeg/jcmarker.o \
$(B)/client/jpeg/jcmaster.o \
$(B)/client/jpeg/jcomapi.o \
$(B)/client/jpeg/jcparam.o \
$(B)/client/jpeg/jcprepct.o \
$(B)/client/jpeg/jcsample.o \
$(B)/client/jpeg/jctrans.o \
$(B)/client/jpeg/jdapimin.o \
$(B)/client/jpeg/jdapistd.o \
$(B)/client/jpeg/jdarith.o \
$(B)/client/jpeg/jdatadst.o \
$(B)/client/jpeg/jdatasrc.o \
$(B)/client/jpeg/jdcoefct.o \
$(B)/client/jpeg/jdcolor.o \
$(B)/client/jpeg/jddctmgr.o \
$(B)/client/jpeg/jdhuff.o \
$(B)/client/jpeg/jdinput.o \
$(B)/client/jpeg/jdmainct.o \
$(B)/client/jpeg/jdmarker.o \
$(B)/client/jpeg/jdmaster.o \
$(B)/client/jpeg/jdmerge.o \
$(B)/client/jpeg/jdpostct.o \
$(B)/client/jpeg/jdsample.o \
$(B)/client/jpeg/jdtrans.o \
$(B)/client/jpeg/jerror.o \
$(B)/client/jpeg/jfdctflt.o \
$(B)/client/jpeg/jfdctfst.o \
$(B)/client/jpeg/jfdctint.o \
$(B)/client/jpeg/jidctflt.o \
$(B)/client/jpeg/jidctfst.o \
$(B)/client/jpeg/jidctint.o \
$(B)/client/jpeg/jmemmgr.o \
$(B)/client/jpeg/jmemnobs.o \
$(B)/client/jpeg/jquant1.o \
$(B)/client/jpeg/jquant2.o \
$(B)/client/jpeg/jutils.o
ifeq ($(USE_OGG_VORBIS),1)
ifeq ($(USE_SYSTEM_OGG),0)
OGGOBJ = \
$(B)/client/ogg/bitwise.o \
$(B)/client/ogg/framing.o
endif
ifeq ($(USE_SYSTEM_VORBIS),0)
VORBISOBJ = \
$(B)/client/vorbis/analysis.o \
$(B)/client/vorbis/bitrate.o \
$(B)/client/vorbis/block.o \
$(B)/client/vorbis/codebook.o \
$(B)/client/vorbis/envelope.o \
$(B)/client/vorbis/floor0.o \
$(B)/client/vorbis/floor1.o \
$(B)/client/vorbis/info.o \
$(B)/client/vorbis/lookup.o \
$(B)/client/vorbis/lpc.o \
$(B)/client/vorbis/lsp.o \
$(B)/client/vorbis/mapping0.o \