forked from clover-moe/mint-arena
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
1602 lines (1336 loc) · 44.5 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
#
# Spearmint Makefile
#
# 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 ($(COMPILE_PLATFORM),sunos)
# Solaris uname and GNU uname differ
COMPILE_ARCH=$(shell uname -p | sed -e 's/i.86/x86/')
endif
ifndef BUILD_GAME_SO
BUILD_GAME_SO = 0
endif
ifndef BUILD_GAME_QVM
BUILD_GAME_QVM = 1
endif
ifndef BUILD_BASEGAME
BUILD_BASEGAME = 1
endif
ifndef BUILD_MISSIONPACK
BUILD_MISSIONPACK= 0
endif
ifndef USE_MISSIONPACK_Q3_UI
USE_MISSIONPACK_Q3_UI =
endif
ifndef BUILD_FINAL
BUILD_FINAL =0
endif
ifndef USE_YACC
USE_YACC=0
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),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
ifeq ($(COMPILE_ARCH),powerpc)
COMPILE_ARCH=ppc
endif
ifeq ($(COMPILE_ARCH),powerpc64)
COMPILE_ARCH=ppc64
endif
ifeq ($(COMPILE_ARCH),axp)
COMPILE_ARCH=alpha
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 VERSION
VERSION=1.0.1
endif
ifndef VM_PREFIX
VM_PREFIX=mint-
endif
ifndef SOURCE_ARCHIVE
SOURCE_ARCHIVE=mint-arena
endif
ifndef BASEGAME
BASEGAME=baseq3
endif
ifndef BASEGAME_CFLAGS
BASEGAME_CFLAGS=
endif
BASEGAME_CFLAGS+=-DMODDIR=\"$(BASEGAME)\" -DBASETA=\"$(MISSIONPACK)\"
ifndef MISSIONPACK
MISSIONPACK=missionpack
endif
ifndef MISSIONPACK_CFLAGS
ifeq ($(USE_MISSIONPACK_Q3_UI), 1)
MISSIONPACK_CFLAGS=-DMISSIONPACK
else
MISSIONPACK_CFLAGS=-DMISSIONPACK -DMISSIONPACK_HUD
endif
endif
MISSIONPACK_CFLAGS+=-DMODDIR=\"$(MISSIONPACK)\" -DBASEQ3=\"$(BASEGAME)\"
# Add "-DEXAMPLE" to define EXAMPLE in engine and game/cgame.
ifndef BUILD_DEFINES
BUILD_DEFINES =
endif
ifndef COPYDIR
COPYDIR="/usr/local/games/spearmint"
endif
ifndef COPYBINDIR
COPYBINDIR=$(COPYDIR)
endif
ifndef MOUNT_DIR
MOUNT_DIR=code
endif
ifndef BUILD_DIR
BUILD_DIR=build
endif
ifndef TEMPDIR
TEMPDIR=/tmp
endif
ifndef GENERATE_DEPENDENCIES
GENERATE_DEPENDENCIES=1
endif
ifndef DEBUG_CFLAGS
DEBUG_CFLAGS=-ggdb -O0
endif
#############################################################################
BD=$(BUILD_DIR)/debug-$(PLATFORM)-$(ARCH)
BR=$(BUILD_DIR)/release-$(PLATFORM)-$(ARCH)
CMDIR=$(MOUNT_DIR)/qcommon
BLIBDIR=$(MOUNT_DIR)/botlib
GDIR=$(MOUNT_DIR)/game
CGDIR=$(MOUNT_DIR)/cgame
UIDIR=$(MOUNT_DIR)/ui
Q3UIDIR=$(MOUNT_DIR)/q3_ui
Q3ASMDIR=$(MOUNT_DIR)/tools/asm
LBURGDIR=$(MOUNT_DIR)/tools/lcc/lburg
Q3CPPDIR=$(MOUNT_DIR)/tools/lcc/cpp
Q3LCCETCDIR=$(MOUNT_DIR)/tools/lcc/etc
Q3LCCSRCDIR=$(MOUNT_DIR)/tools/lcc/src
bin_path=$(shell which $(1) 2> /dev/null)
ifneq ($(BUILD_FINAL),1)
# Add git version info
USE_GIT=
ifeq ($(wildcard .git),.git)
GIT_REV=$(shell git show -s --pretty=format:%ad+%h --date=short | tr -d '-')
ifneq ($(GIT_REV),)
VERSION:=$(VERSION)+$(GIT_REV)
USE_GIT=1
endif
endif
endif
#############################################################################
# SETUP AND BUILD -- LINUX
#############################################################################
INSTALL=install
MKDIR=mkdir -p
ifneq (,$(findstring "$(COMPILE_PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu" "gnu"))
TOOLS_CFLAGS += -DARCH_STRING=\"$(COMPILE_ARCH)\"
endif
ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu" "gnu"))
BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \
-pipe -DUSE_ICON -DARCH_STRING=\\\"$(ARCH)\\\"
OPTIMIZEVM = -O3
OPTIMIZE = $(OPTIMIZEVM) -ffast-math
ifeq ($(ARCH),x86_64)
OPTIMIZEVM = -O3
OPTIMIZE = $(OPTIMIZEVM) -ffast-math
HAVE_VM_COMPILED = true
else
ifeq ($(ARCH),x86)
OPTIMIZEVM = -O3 -march=i586
OPTIMIZE = $(OPTIMIZEVM) -ffast-math
HAVE_VM_COMPILED=true
else
ifeq ($(ARCH),ppc)
ALTIVEC_CFLAGS = -maltivec
HAVE_VM_COMPILED=true
endif
ifeq ($(ARCH),ppc64)
ALTIVEC_CFLAGS = -maltivec
HAVE_VM_COMPILED=true
endif
ifeq ($(ARCH),sparc)
OPTIMIZE += -mtune=ultrasparc3 -mv8plus
OPTIMIZEVM += -mtune=ultrasparc3 -mv8plus
HAVE_VM_COMPILED=true
endif
ifeq ($(ARCH),alpha)
# According to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=410555
# -ffast-math will cause the client to die with SIGFPE on Alpha
OPTIMIZE = $(OPTIMIZEVM)
endif
endif
endif
SHLIBEXT=so
SHLIBCFLAGS=-fPIC -fvisibility=hidden
SHLIBLDFLAGS=-shared $(LDFLAGS)
THREAD_LIBS=-lpthread
LIBS=-ldl -lm
ifeq ($(ARCH),x86)
# linux32 make ...
BASE_CFLAGS += -m32
else
ifeq ($(ARCH),ppc64)
BASE_CFLAGS += -m64
endif
endif
else # ifeq Linux
#############################################################################
# SETUP AND BUILD -- MAC OS X
#############################################################################
ifeq ($(PLATFORM),darwin)
HAVE_VM_COMPILED=true
LIBS = -framework Cocoa
OPTIMIZEVM = -O3
# Default minimum Mac OS X version
ifeq ($(MACOSX_VERSION_MIN),)
MACOSX_VERSION_MIN=10.7
endif
MACOSX_MAJOR=$(shell echo $(MACOSX_VERSION_MIN) | cut -d. -f1)
MACOSX_MINOR=$(shell echo $(MACOSX_VERSION_MIN) | cut -d. -f2)
ifeq ($(shell test $(MACOSX_MINOR) -gt 9; echo $$?),0)
# Multiply and then remove decimal. 10.10 -> 101000.0 -> 101000
MAC_OS_X_VERSION_MIN_REQUIRED=$(shell echo "$(MACOSX_MAJOR) * 10000 + $(MACOSX_MINOR) * 100" | bc | cut -d. -f1)
else
# Multiply by 100 and then remove decimal. 10.7 -> 1070.0 -> 1070
MAC_OS_X_VERSION_MIN_REQUIRED=$(shell echo "$(MACOSX_VERSION_MIN) * 100" | bc | cut -d. -f1)
endif
LDFLAGS += -mmacosx-version-min=$(MACOSX_VERSION_MIN)
BASE_CFLAGS += -mmacosx-version-min=$(MACOSX_VERSION_MIN) \
-DMAC_OS_X_VERSION_MIN_REQUIRED=$(MAC_OS_X_VERSION_MIN_REQUIRED)
ifeq ($(ARCH),ppc)
BASE_CFLAGS += -arch ppc
ALTIVEC_CFLAGS = -faltivec
endif
ifeq ($(ARCH),ppc64)
BASE_CFLAGS += -arch ppc64
ALTIVEC_CFLAGS = -faltivec
endif
ifeq ($(ARCH),x86)
OPTIMIZEVM += -march=prescott -mfpmath=sse
# x86 vm will crash without -mstackrealign since MMX instructions will be
# used no matter what and they corrupt the frame pointer in VM calls
BASE_CFLAGS += -arch i386 -m32 -mstackrealign
endif
ifeq ($(ARCH),x86_64)
OPTIMIZEVM += -mfpmath=sse
BASE_CFLAGS += -arch x86_64
endif
# When compiling on OSX for OSX, we're not cross compiling as far as the
# Makefile is concerned, as target architecture is specified as a compiler
# argument
ifeq ($(COMPILE_PLATFORM),darwin)
CROSS_COMPILING=0
endif
ifeq ($(CROSS_COMPILING),1)
ifeq ($(ARCH),x86_64)
CC=x86_64-apple-darwin13-cc
RANLIB=x86_64-apple-darwin13-ranlib
else
ifeq ($(ARCH),x86)
CC=i386-apple-darwin13-cc
RANLIB=i386-apple-darwin13-ranlib
else
$(error Architecture $(ARCH) is not supported when cross compiling)
endif
endif
endif
BASE_CFLAGS += -fno-strict-aliasing -fno-common -pipe
BASE_CFLAGS += -D_THREAD_SAFE=1
OPTIMIZE = $(OPTIMIZEVM) -ffast-math
SHLIBEXT=dylib
SHLIBCFLAGS=-fPIC -fno-common
SHLIBLDFLAGS=-dynamiclib $(LDFLAGS) -Wl,-U,_com_altivec
NOTSHLIBCFLAGS=-mdynamic-no-pic
else # ifeq darwin
#############################################################################
# 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
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
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
ifndef WINDRES
WINDRES=windres
endif
BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \
-DUSE_ICON
# In the absence of wspiapi.h, require Windows XP or later
ifeq ($(shell test -e $(CMDIR)/wspiapi.h; echo $$?),1)
BASE_CFLAGS += -DWINVER=0x501
endif
ifeq ($(ARCH),x86_64)
OPTIMIZEVM = -O3
OPTIMIZE = $(OPTIMIZEVM) -ffast-math
HAVE_VM_COMPILED = true
endif
ifeq ($(ARCH),x86)
OPTIMIZEVM = -O3 -march=i586
OPTIMIZE = $(OPTIMIZEVM) -ffast-math
HAVE_VM_COMPILED = true
endif
SHLIBEXT=dll
SHLIBCFLAGS=
SHLIBLDFLAGS=-shared $(LDFLAGS)
BINEXT=.exe
ifeq ($(CROSS_COMPILING),0)
TOOLS_BINEXT=.exe
endif
ifeq ($(COMPILE_PLATFORM),cygwin)
TOOLS_BINEXT=.exe
TOOLS_CC=$(CC)
endif
LIBS= -lws2_32 -lwinmm -lpsapi
ifeq ($(ARCH),x86)
# build 32bit
BASE_CFLAGS += -m32
else
BASE_CFLAGS += -m64
endif
else # ifdef MINGW
#############################################################################
# SETUP AND BUILD -- FREEBSD
#############################################################################
ifeq ($(PLATFORM),freebsd)
# flags
BASE_CFLAGS = \
-Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \
-DUSE_ICON -DMAP_ANONYMOUS=MAP_ANON
HAVE_VM_COMPILED = true
OPTIMIZEVM =
OPTIMIZE = $(OPTIMIZEVM) -ffast-math
SHLIBEXT=so
SHLIBCFLAGS=-fPIC
SHLIBLDFLAGS=-shared $(LDFLAGS)
THREAD_LIBS=-lpthread
# don't need -ldl (FreeBSD)
LIBS=-lm
# cross-compiling tweaks
ifeq ($(ARCH),x86)
ifeq ($(CROSS_COMPILING),1)
BASE_CFLAGS += -m32
endif
endif
ifeq ($(ARCH),x86_64)
ifeq ($(CROSS_COMPILING),1)
BASE_CFLAGS += -m64
endif
endif
else # ifeq freebsd
#############################################################################
# SETUP AND BUILD -- OPENBSD
#############################################################################
ifeq ($(PLATFORM),openbsd)
BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \
-pipe -DUSE_ICON -DMAP_ANONYMOUS=MAP_ANON
CLIENT_CFLAGS += $(SDL_CFLAGS)
OPTIMIZEVM = -O3
OPTIMIZE = $(OPTIMIZEVM) -ffast-math
ifeq ($(ARCH),x86_64)
OPTIMIZEVM = -O3
OPTIMIZE = $(OPTIMIZEVM) -ffast-math
HAVE_VM_COMPILED = true
else
ifeq ($(ARCH),x86)
OPTIMIZEVM = -O3 -march=i586
OPTIMIZE = $(OPTIMIZEVM) -ffast-math
HAVE_VM_COMPILED=true
else
ifeq ($(ARCH),ppc)
ALTIVEC_CFLAGS = -maltivec
HAVE_VM_COMPILED=true
endif
ifeq ($(ARCH),ppc64)
ALTIVEC_CFLAGS = -maltivec
HAVE_VM_COMPILED=true
endif
ifeq ($(ARCH),sparc64)
OPTIMIZE += -mtune=ultrasparc3 -mv8plus
OPTIMIZEVM += -mtune=ultrasparc3 -mv8plus
HAVE_VM_COMPILED=true
endif
ifeq ($(ARCH),alpha)
# According to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=410555
# -ffast-math will cause the client to die with SIGFPE on Alpha
OPTIMIZE = $(OPTIMIZEVM)
endif
endif
endif
SHLIBEXT=so
SHLIBCFLAGS=-fPIC
SHLIBLDFLAGS=-shared $(LDFLAGS)
THREAD_LIBS=-lpthread
LIBS=-lm
else # ifeq openbsd
#############################################################################
# SETUP AND BUILD -- NETBSD
#############################################################################
ifeq ($(PLATFORM),netbsd)
LIBS=-lm
SHLIBEXT=so
SHLIBCFLAGS=-fPIC
SHLIBLDFLAGS=-shared $(LDFLAGS)
THREAD_LIBS=-lpthread
BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes
ifeq ($(ARCH),x86)
HAVE_VM_COMPILED=true
endif
else # ifeq netbsd
#############################################################################
# SETUP AND BUILD -- IRIX
#############################################################################
ifeq ($(PLATFORM),irix64)
LIB=lib
ARCH=mips
CC = c99
BASE_CFLAGS=-Dstricmp=strcasecmp -Xcpluscomm -woff 1185 \
-I. -I$(ROOT)/usr/include
OPTIMIZE = -O3
SHLIBEXT=so
SHLIBCFLAGS=
SHLIBLDFLAGS=-shared
LIBS=-ldl -lm -lgen
else # ifeq IRIX
#############################################################################
# SETUP AND BUILD -- SunOS
#############################################################################
ifeq ($(PLATFORM),sunos)
CC=gcc
INSTALL=ginstall
MKDIR=gmkdir -p
COPYDIR="/usr/local/share/games/spearmint"
ifneq ($(ARCH),x86)
ifneq ($(ARCH),sparc)
$(error arch $(ARCH) is currently not supported)
endif
endif
BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \
-pipe -DUSE_ICON
CLIENT_CFLAGS += $(SDL_CFLAGS)
OPTIMIZEVM = -O3 -funroll-loops
ifeq ($(ARCH),sparc)
OPTIMIZEVM += -O3 \
-fstrength-reduce -falign-functions=2 \
-mtune=ultrasparc3 -mv8plus -mno-faster-structs
HAVE_VM_COMPILED=true
else
ifeq ($(ARCH),x86)
OPTIMIZEVM += -march=i586 -fomit-frame-pointer \
-falign-functions=2 -fstrength-reduce
HAVE_VM_COMPILED=true
BASE_CFLAGS += -m32
CLIENT_CFLAGS += -I/usr/X11/include/NVIDIA
CLIENT_LDFLAGS += -L/usr/X11/lib/NVIDIA -R/usr/X11/lib/NVIDIA
endif
endif
OPTIMIZE = $(OPTIMIZEVM) -ffast-math
SHLIBEXT=so
SHLIBCFLAGS=-fPIC
SHLIBLDFLAGS=-shared $(LDFLAGS)
THREAD_LIBS=-lpthread
LIBS=-lsocket -lnsl -ldl -lm
BOTCFLAGS=-O0
else # ifeq sunos
#############################################################################
# SETUP AND BUILD -- GENERIC
#############################################################################
BASE_CFLAGS=
OPTIMIZE = -O3
SHLIBEXT=so
SHLIBCFLAGS=-fPIC
SHLIBLDFLAGS=-shared
endif #Linux
endif #darwin
endif #MINGW
endif #FreeBSD
endif #OpenBSD
endif #NetBSD
endif #IRIX
endif #SunOS
ifndef CC
CC=gcc
endif
ifndef RANLIB
RANLIB=ranlib
endif
ifneq ($(HAVE_VM_COMPILED),true)
BASE_CFLAGS += -DNO_VM_COMPILED
BUILD_GAME_QVM=0
endif
TARGETS =
ifndef FULLBINEXT
FULLBINEXT=_$(ARCH)$(BINEXT)
endif
ifndef SHLIBNAME
SHLIBNAME=$(ARCH).$(SHLIBEXT)
endif
ifneq ($(BUILD_GAME_SO),0)
ifneq ($(BUILD_BASEGAME),0)
TARGETS += \
$(B)/$(BASEGAME)/$(VM_PREFIX)cgame_$(SHLIBNAME) \
$(B)/$(BASEGAME)/$(VM_PREFIX)game_$(SHLIBNAME)
endif
ifneq ($(BUILD_MISSIONPACK),0)
TARGETS += \
$(B)/$(MISSIONPACK)/$(VM_PREFIX)cgame_$(SHLIBNAME) \
$(B)/$(MISSIONPACK)/$(VM_PREFIX)game_$(SHLIBNAME)
endif
endif
ifneq ($(BUILD_GAME_QVM),0)
ifneq ($(BUILD_BASEGAME),0)
TARGETS += \
$(B)/$(BASEGAME)/vm/$(VM_PREFIX)cgame.qvm \
$(B)/$(BASEGAME)/vm/$(VM_PREFIX)game.qvm
endif
ifneq ($(BUILD_MISSIONPACK),0)
TARGETS += \
$(B)/$(MISSIONPACK)/vm/$(VM_PREFIX)cgame.qvm \
$(B)/$(MISSIONPACK)/vm/$(VM_PREFIX)game.qvm
endif
endif
ifeq ("$(CC)", $(findstring "$(CC)", "clang" "clang++"))
BASE_CFLAGS += -Qunused-arguments
endif
ifeq ($(GENERATE_DEPENDENCIES),1)
DEPEND_CFLAGS = -MMD
else
DEPEND_CFLAGS =
endif
ifeq ($(NO_STRIP),1)
STRIP_FLAG =
else
STRIP_FLAG = -s
endif
# https://reproducible-builds.org/specs/source-date-epoch/
ifdef SOURCE_DATE_EPOCH
BASE_BUILD_DEFINES += -DPRODUCT_DATE=\\\"$(shell date --date="@$$SOURCE_DATE_EPOCH" "+%b %_d %Y" | sed -e 's/ /\\\ /g')\\\"
endif
BASE_BUILD_DEFINES += -DPRODUCT_VERSION=\\\"$(VERSION)\\\"
ifeq ($(USE_GIT),1)
BASE_BUILD_DEFINES += -DPRODUCT_VERSION_HAS_DATE
endif
BASE_CFLAGS += -Wformat=2 -Wno-format-zero-length -Wformat-security -Wno-format-nonliteral
BASE_CFLAGS += -Wstrict-aliasing=2 -Wmissing-format-attribute
BASE_CFLAGS += -Wdisabled-optimization
BASE_CFLAGS += -Werror-implicit-function-declaration
ifeq ($(V),1)
echo_cmd=@:
Q=
else
echo_cmd=@echo
Q=@
endif
ifeq ($(GENERATE_DEPENDENCIES),1)
DO_QVM_DEP=cat $(@:%.o=%.d) | sed -e 's/\.o/\.asm/g' >> $(@:%.o=%.d)
endif
define DO_SHLIB_CC
$(echo_cmd) "SHLIB_CC $<"
$(Q)$(CC) $(BASEGAME_CFLAGS) $(SHLIBCFLAGS) $(CFLAGS) $(OPTIMIZEVM) -o $@ -c $<
$(Q)$(DO_QVM_DEP)
endef
define DO_GAME_CC
$(echo_cmd) "GAME_CC $<"
$(Q)$(CC) $(BASEGAME_CFLAGS) -DGAME $(SHLIBCFLAGS) $(CFLAGS) $(OPTIMIZEVM) -o $@ -c $<
$(Q)$(DO_QVM_DEP)
endef
define DO_CGAME_CC
$(echo_cmd) "CGAME_CC $<"
$(Q)$(CC) $(BASEGAME_CFLAGS) -DCGAME $(SHLIBCFLAGS) $(CFLAGS) $(OPTIMIZEVM) -o $@ -c $<
$(Q)$(DO_QVM_DEP)
endef
define DO_SHLIB_CC_MISSIONPACK
$(echo_cmd) "SHLIB_CC_MISSIONPACK $<"
$(Q)$(CC) $(MISSIONPACK_CFLAGS) $(SHLIBCFLAGS) $(CFLAGS) $(OPTIMIZEVM) -o $@ -c $<
$(Q)$(DO_QVM_DEP)
endef
define DO_GAME_CC_MISSIONPACK
$(echo_cmd) "GAME_CC_MISSIONPACK $<"
$(Q)$(CC) $(MISSIONPACK_CFLAGS) -DGAME $(SHLIBCFLAGS) $(CFLAGS) $(OPTIMIZEVM) -o $@ -c $<
$(Q)$(DO_QVM_DEP)
endef
define DO_CGAME_CC_MISSIONPACK
$(echo_cmd) "CGAME_CC_MISSIONPACK $<"
$(Q)$(CC) $(MISSIONPACK_CFLAGS) -DCGAME $(SHLIBCFLAGS) $(CFLAGS) $(OPTIMIZEVM) -o $@ -c $<
$(Q)$(DO_QVM_DEP)
endef
#############################################################################
# MAIN TARGETS
#############################################################################
default: release
all: debug release
debug:
@$(MAKE) targets B=$(BD) CFLAGS="$(CFLAGS) $(BASE_BUILD_DEFINES) $(BASE_CFLAGS) $(BUILD_DEFINES) $(DEPEND_CFLAGS)" \
OPTIMIZE="$(DEBUG_CFLAGS)" OPTIMIZEVM="$(DEBUG_CFLAGS)" \
CLIENT_CFLAGS="$(CLIENT_CFLAGS)" SERVER_CFLAGS="$(SERVER_CFLAGS)" V=$(V) \
QVM_CFLAGS="$(BASE_BUILD_DEFINES) $(BUILD_DEFINES)"
release:
@$(MAKE) targets B=$(BR) CFLAGS="$(CFLAGS) $(BASE_BUILD_DEFINES) $(BASE_CFLAGS) $(BUILD_DEFINES) $(DEPEND_CFLAGS)" \
OPTIMIZE="-DNDEBUG $(OPTIMIZE)" OPTIMIZEVM="-DNDEBUG $(OPTIMIZEVM)" \
CLIENT_CFLAGS="$(CLIENT_CFLAGS)" SERVER_CFLAGS="$(SERVER_CFLAGS)" V=$(V) \
QVM_CFLAGS="-DNDEBUG $(BASE_BUILD_DEFINES) $(BUILD_DEFINES)"
ifneq ($(call bin_path, tput),)
TERM_COLUMNS=$(shell if c=`tput cols`; then echo $$(($$c-4)); else echo 76; fi)
else
TERM_COLUMNS=76
endif
NAKED_TARGETS=$(shell echo $(TARGETS) | sed -e "s!$(B)/!!g")
print_list=-@for i in $(1); \
do \
echo " $$i"; \
done
ifneq ($(call bin_path, fmt),)
print_wrapped=@echo $(1) | fmt -w $(TERM_COLUMNS) | sed -e "s/^\(.*\)$$/ \1/"
else
print_wrapped=$(print_list)
endif
# Create the build directories, check libraries and print out
# an informational message, then start building
targets: makedirs
@echo ""
@echo "Building in $(B):"
@echo " PLATFORM: $(PLATFORM)"
@echo " ARCH: $(ARCH)"
@echo " VERSION: $(VERSION)"
@echo " COMPILE_PLATFORM: $(COMPILE_PLATFORM)"
@echo " COMPILE_ARCH: $(COMPILE_ARCH)"
@echo " CC: $(CC)"
ifeq ($(PLATFORM),mingw32)
@echo " WINDRES: $(WINDRES)"
endif
@echo ""
@echo " CFLAGS:"
$(call print_wrapped, $(CFLAGS) $(OPTIMIZE))
@echo ""
@echo " LDFLAGS:"
$(call print_wrapped, $(LDFLAGS))
@echo ""
@echo " LIBS:"
$(call print_wrapped, $(LIBS))
@echo ""
@echo " Output:"
$(call print_list, $(NAKED_TARGETS))
@echo ""
ifneq ($(TARGETS),)
ifndef DEBUG_MAKEFILE
@$(MAKE) $(TARGETS) $(B).zip V=$(V)
endif
endif
$(B).zip: $(TARGETS)
ifdef ARCHIVE
@rm -f $@
@(cd $(B) && zip -r9 ../../$@ $(NAKED_TARGETS))
endif
makedirs:
@$(MKDIR) $(B)/$(BASEGAME)/cgame
@$(MKDIR) $(B)/$(BASEGAME)/botlib
@$(MKDIR) $(B)/$(BASEGAME)/game
@$(MKDIR) $(B)/$(BASEGAME)/ui
@$(MKDIR) $(B)/$(BASEGAME)/qcommon
@$(MKDIR) $(B)/$(BASEGAME)/vm
@$(MKDIR) $(B)/$(MISSIONPACK)/cgame
@$(MKDIR) $(B)/$(MISSIONPACK)/botlib
@$(MKDIR) $(B)/$(MISSIONPACK)/game
@$(MKDIR) $(B)/$(MISSIONPACK)/ui
@$(MKDIR) $(B)/$(MISSIONPACK)/qcommon
@$(MKDIR) $(B)/$(MISSIONPACK)/vm
@$(MKDIR) $(B)/tools/asm
@$(MKDIR) $(B)/tools/etc
@$(MKDIR) $(B)/tools/rcc
@$(MKDIR) $(B)/tools/cpp
@$(MKDIR) $(B)/tools/lburg
#############################################################################
# QVM BUILD TOOLS
#############################################################################
ifndef TOOLS_CC
# A compiler which probably produces native binaries
TOOLS_CC = gcc
endif
ifndef YACC
YACC = yacc
endif
TOOLS_OPTIMIZE = -g -Wall -fno-strict-aliasing
TOOLS_CFLAGS += $(TOOLS_OPTIMIZE) \
-DTEMPDIR=\"$(TEMPDIR)\" -DSYSTEM=\"\" \
-I$(Q3LCCSRCDIR) \
-I$(LBURGDIR)
TOOLS_LIBS =
TOOLS_LDFLAGS =
ifeq ($(GENERATE_DEPENDENCIES),1)
TOOLS_CFLAGS += -MMD
endif
define DO_YACC
$(echo_cmd) "YACC $<"
$(Q)$(YACC) $<
$(Q)mv -f y.tab.c $@
endef
define DO_TOOLS_CC
$(echo_cmd) "TOOLS_CC $<"
$(Q)$(TOOLS_CC) $(TOOLS_CFLAGS) -o $@ -c $<
endef
define DO_TOOLS_CC_DAGCHECK
$(echo_cmd) "TOOLS_CC_DAGCHECK $<"
$(Q)$(TOOLS_CC) $(TOOLS_CFLAGS) -Wno-unused -o $@ -c $<
endef
LBURG = $(B)/tools/lburg/lburg$(TOOLS_BINEXT)
DAGCHECK_C = $(B)/tools/rcc/dagcheck.c
Q3RCC = $(B)/tools/q3rcc$(TOOLS_BINEXT)
Q3CPP = $(B)/tools/q3cpp$(TOOLS_BINEXT)
Q3LCC = $(B)/tools/q3lcc$(TOOLS_BINEXT)
Q3ASM = $(B)/tools/q3asm$(TOOLS_BINEXT)
LBURGOBJ= \
$(B)/tools/lburg/lburg.o \
$(B)/tools/lburg/gram.o
# override GNU Make built-in rule for converting gram.y to gram.c
%.c: %.y
ifeq ($(USE_YACC),1)
$(DO_YACC)
endif
$(B)/tools/lburg/%.o: $(LBURGDIR)/%.c
$(DO_TOOLS_CC)
$(LBURG): $(LBURGOBJ)
$(echo_cmd) "LD $@"
$(Q)$(TOOLS_CC) $(TOOLS_CFLAGS) $(TOOLS_LDFLAGS) -o $@ $^ $(TOOLS_LIBS)
Q3RCCOBJ = \
$(B)/tools/rcc/alloc.o \
$(B)/tools/rcc/bind.o \
$(B)/tools/rcc/bytecode.o \
$(B)/tools/rcc/dag.o \
$(B)/tools/rcc/dagcheck.o \
$(B)/tools/rcc/decl.o \
$(B)/tools/rcc/enode.o \
$(B)/tools/rcc/error.o \
$(B)/tools/rcc/event.o \
$(B)/tools/rcc/expr.o \
$(B)/tools/rcc/gen.o \
$(B)/tools/rcc/init.o \
$(B)/tools/rcc/inits.o \
$(B)/tools/rcc/input.o \
$(B)/tools/rcc/lex.o \
$(B)/tools/rcc/list.o \
$(B)/tools/rcc/main.o \
$(B)/tools/rcc/null.o \
$(B)/tools/rcc/output.o \
$(B)/tools/rcc/prof.o \
$(B)/tools/rcc/profio.o \
$(B)/tools/rcc/simp.o \
$(B)/tools/rcc/stmt.o \
$(B)/tools/rcc/string.o \
$(B)/tools/rcc/sym.o \
$(B)/tools/rcc/symbolic.o \
$(B)/tools/rcc/trace.o \
$(B)/tools/rcc/tree.o \
$(B)/tools/rcc/types.o
$(DAGCHECK_C): $(LBURG) $(Q3LCCSRCDIR)/dagcheck.md
$(echo_cmd) "LBURG $(Q3LCCSRCDIR)/dagcheck.md"
$(Q)$(LBURG) $(Q3LCCSRCDIR)/dagcheck.md $@
$(B)/tools/rcc/dagcheck.o: $(DAGCHECK_C)
$(DO_TOOLS_CC_DAGCHECK)
$(B)/tools/rcc/%.o: $(Q3LCCSRCDIR)/%.c
$(DO_TOOLS_CC)
$(Q3RCC): $(Q3RCCOBJ)
$(echo_cmd) "LD $@"
$(Q)$(TOOLS_CC) $(TOOLS_CFLAGS) $(TOOLS_LDFLAGS) -o $@ $^ $(TOOLS_LIBS)
Q3CPPOBJ = \
$(B)/tools/cpp/cpp.o \
$(B)/tools/cpp/lex.o \
$(B)/tools/cpp/nlist.o \
$(B)/tools/cpp/tokens.o \
$(B)/tools/cpp/macro.o \
$(B)/tools/cpp/eval.o \
$(B)/tools/cpp/include.o \
$(B)/tools/cpp/hideset.o \
$(B)/tools/cpp/getopt.o \
$(B)/tools/cpp/unix.o
$(B)/tools/cpp/%.o: $(Q3CPPDIR)/%.c
$(DO_TOOLS_CC)
$(Q3CPP): $(Q3CPPOBJ)
$(echo_cmd) "LD $@"
$(Q)$(TOOLS_CC) $(TOOLS_CFLAGS) $(TOOLS_LDFLAGS) -o $@ $^ $(TOOLS_LIBS)
Q3LCCOBJ = \
$(B)/tools/etc/lcc.o \
$(B)/tools/etc/bytecode.o
$(B)/tools/etc/%.o: $(Q3LCCETCDIR)/%.c
$(DO_TOOLS_CC)