-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
2906 lines (2632 loc) · 72.2 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
# KingpinQ3 Makefile
#
# GNU Make required
COMPILE_PLATFORM=$(shell uname|sed -e s/_.*//|tr '[:upper:]' '[:lower:]')
#GCC_VERSTR = $(shell $(CC) -dumpversion)
#GCC_VER1 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.`)
#GCC_VER2 := $(shell expr `$(CC) -dumpversion | cut -f2 -d.`)
#GCC_VER3 := $(shell expr `$(CC) -dumpversion | cut -f3 -d.`)
#FIXME: warning on som plattforms
COMPILE_ARCH=$(shell uname -m | sed -e s/i.86/i386/)
ifeq ($(COMPILE_PLATFORM),sunos)
# Solaris uname and GNU uname differ
COMPILE_ARCH=$(shell uname -p | sed -e s/i.86/i386/)
endif
ifeq ($(COMPILE_PLATFORM),darwin)
# Apple does some things a little differently...
COMPILE_ARCH=$(shell uname -p | sed -e s/i.86/i386/)
endif
ifeq ($(COMPILE_PLATFORM),mingw32)
ifeq ($(COMPILE_ARCH),i386)
COMPILE_ARCH=x86
endif
ifeq ($(COMPILE_ARCH),x86_64)
COMPILE_ARCH=x64
endif
endif
ifndef BUILD_STANDALONE
BUILD_STANDALONE =
LCCFLAGS =
else
LCCFLAGS = -DSTANDALONE
endif
LCCFLAGS = -DSTANDALONE
ifndef BUILD_CLIENT
BUILD_CLIENT = 1
endif
ifndef BUILD_CLIENT_SMP
BUILD_CLIENT_SMP = 0
endif
ifndef BUILD_SERVER
BUILD_SERVER = 0
endif
ifndef BUILD_KMAP2
BUILD_KMAP2 = 0
endif
ifndef BUILD_KAAS
BUILD_KAAS = 0
endif
ifndef BUILD_GAME_SO
BUILD_GAME_SO = 0
endif
ifndef BUILD_GAME_QVM
BUILD_GAME_QVM = 0
endif
USE_C_DLL = 0
ifndef USE_CPLUS_0X
USE_CPLUS_0X = 0
endif
ifneq ($(PLATFORM),darwin)
BUILD_CLIENT_SMP = 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.
#
#############################################################################
ifndef PLATFORM
PLATFORM=$(COMPILE_PLATFORM)
endif
export PLATFORM
ifeq ($(COMPILE_ARCH),powerpc)
COMPILE_ARCH=ppc
endif
ifeq ($(COMPILE_ARCH),powerpc64)
COMPILE_ARCH=ppc64
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
ifeq ($(CROSS_COMPILING), 1)
-include ConfigMinGw.mk
else
-include Config.mk
SLD=ar
CCC=g++
endif
ifndef COPYDIR
COPYDIR="/usr/local/games/kingpinq3"
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 USE_OPENAL
USE_OPENAL=1
endif
ifndef USE_OPENAL_DLOPEN
USE_OPENAL_DLOPEN=1
endif
ifndef USE_FREETYPE
USE_FREETYPE=1
endif
ifndef USE_FREETYPE_BUILDIN
USE_FREETYPE_BUILDIN=0
endif
ifndef USE_TCMALLOC
USE_TCMALLOC=0
endif
ifndef USE_CURL
USE_CURL=1
endif
ifndef USE_GPROF_PROFILING
USE_GPROF_PROFILING=0
endif
ifndef USE_CURL_DLOPEN
ifeq ($(PLATFORM),mingw32)
USE_CURL_DLOPEN=1
else
USE_CURL_DLOPEN=1
endif
endif
ifndef USE_CODEC_VORBIS
USE_CODEC_VORBIS=0
ifndef USE_INTERNAL_VORBIS
USE_INTERNAL_VORBIS=1
endif
endif
ifndef USE_CIN_THEORA
USE_CIN_THEORA=1
endif
ifndef USE_CIN_THEORA_BUILDIN
USE_CIN_THEORA_BUILDIN=0
endif
ifndef USE_MUMBLE
USE_MUMBLE=1
endif
ifndef USE_VOIP
USE_VOIP=1
endif
ifndef USE_INTERNAL_PNG
USE_INTERNAL_PNG=0
endif
ifndef USE_INTERNAL_SPEEX
USE_INTERNAL_SPEEX=1
endif
ifndef USE_INTERNAL_ZLIB
USE_INTERNAL_ZLIB=1
endif
ifndef USE_LOCAL_HEADERS
USE_LOCAL_HEADERS=1
endif
ifndef DEBUG_CFLAGS
DEBUG_CFLAGS=-g3 -dH
endif
ifndef USE_OLD_VM64
USE_OLD_VM64=0
endif
USE_SSE=1
ifndef USE_ASM_LIB
USE_ASM_LIB=0
endif
ifndef USE_OPENMP
USE_OPENMP=0
endif
ifndef USE_INTERNAL_GLEW
USE_INTERNAL_GLEW=0
endif
ifndef USE_UNSAFE_OPTIMIZATIONS
USE_UNSAFE_OPTIMIZATIONS=0
endif
#############################################################################
BD=$(BUILD_DIR)/debug-$(PLATFORM)-$(ARCH)
BR=$(BUILD_DIR)/release-$(PLATFORM)-$(ARCH)
CDIR=$(MOUNT_DIR)/client
SDIR=$(MOUNT_DIR)/server
RDIR=$(MOUNT_DIR)/renderer
CMDIR=$(MOUNT_DIR)/qcommon
SDLDIR=$(MOUNT_DIR)/sdl
ASMDIR=$(MOUNT_DIR)/asm
SYSDIR=$(MOUNT_DIR)/sys
GDIR=$(MOUNT_DIR)/game
CGDIR=$(MOUNT_DIR)/cgame
BLIBDIR=$(MOUNT_DIR)/botlib
NDIR=$(MOUNT_DIR)/null
UIDIR=$(MOUNT_DIR)/ui
JPDIR=$(MOUNT_DIR)/jpeg-8c
SPEEXDIR=$(MOUNT_DIR)/libspeex
ZDIR=$(MOUNT_DIR)/zlib
VORBISDIR=$(MOUNT_DIR)/vorbis
THEORADIR=$(MOUNT_DIR)/theora
OGGDIR=$(MOUNT_DIR)/ogg
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
LOKISETUPDIR=misc/setup
NSISDIR=misc/nsis
SDLHDIR=$(MOUNT_DIR)/SDL12
LIBSDIR=$(MOUNT_DIR)/libs
ASMLIBDIR=$(MOUNT_DIR)/asmlib
TEMPDIR=/tmp
KMAP2DIR=kmap2
FTDIR=$(MOUNT_DIR)/freetype
PNGDIR=$(MOUNT_DIR)/png
KAASDIR=$(MOUNT_DIR)/kaas
GLEWDIR=$(MOUNT_DIR)/glew
bin_path=$(shell which $(1) 2> /dev/null)
# We won't need this if we only build the server
ifneq ($(BUILD_CLIENT),0)
# set PKG_CONFIG_PATH to influence this, e.g.
# PKG_CONFIG_PATH=/opt/cross/i386-mingw32msvc/lib/pkgconfig
# ifeq ($(COMPILE_PLATFORM),mingw32)
# PKG_CONFIG_PATH=/usr/bin/x86_64-w64-mingw32-pkg-config
# endif
ifneq ($(CROSS_COMPILING),1)
PKG_CFG=pkg-config
else
PKG_CFG=x86_64-w64-mingw32-pkg-config
endif
ifneq ($(call bin_path, pkg-config),)
CURL_CFLAGS=$(shell $(PKG_CFG) --silence-errors --cflags libcurl)
CURL_LIBS=$(shell $(PKG_CFG) --silence-errors --libs libcurl)
OPENAL_CFLAGS=$(shell $(PKG_CFG) --silence-errors --cflags openal)
PNG_CFLAGS=$(shell $(PKG_CFG) --silence-errors --cflags libpng)
GLEW_FLAGS=$(shell $(PKG_CFG) --silence-errors --cflags glew)
OPENAL_LIBS=$(shell $(PKG_CFG) --silence-errors --libs openal)
SDL_CFLAGS=$(shell $(PKG_CFG) --silence-errors --cflags sdl|sed 's/-Dmain=SDL_main//')
SDL_LIBS=$(shell $(PKG_CFG) --silence-errors --libs sdl)
PNG_LIBS=$(shell $(PKG_CFG) --silence-errors --libs libpng)
GLEW_LIBS=$(shell $(PKG_CFG) --silence-errors --libs glew)
THEORA_LIBS=$(shell $(PKG_CFG) --silence-errors --libs theora)
THEORA_FLAGS=$(shell $(PKG_CFG) --silence-errors --cflags theora)
#FIXME: pkg-config --cflags theora pkg-config --libs theora
endif
# Use sdl-config if all else fails
ifeq ($(SDL_CFLAGS),)
ifneq ($(call bin_path, sdl-config),)
SDL_CFLAGS=$(shell sdl-config --cflags)
SDL_LIBS=$(shell sdl-config --libs)
endif
endif
endif
# version info
VERSION=""
USE_SVN=1
ifeq ($(wildcard .svn),.svn)
SVN_REV=$(shell LANG=C svnversion .)
ifneq ($(SVN_REV),)
VERSION:=$(VERSION)SVN$(SVN_REV)
USE_SVN=1
endif
else
ifeq ($(wildcard .git/svn/.metadata),.git/svn/.metadata)
SVN_REV=$(shell LANG=C git svn info | awk '$$1 == "Revision:" {print $$2; exit 0}')
ifneq ($(SVN_REV),)
VERSION:=$(VERSION)_SVN$(SVN_REV)
endif
endif
endif
#############################################################################
# SETUP AND BUILD -- LINUX
#############################################################################
## Defaults
LIB=lib
CCP=cpp
INSTALL=install
MKDIR=mkdir
ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu"))
ifeq ($(ARCH),axp)
ARCH=alpha
else
ifeq ($(ARCH),x86_64)
LIB=lib64
else
ifeq ($(ARCH),ppc64)
LIB=lib64
else
ifeq ($(ARCH),s390x)
LIB=lib64
endif
endif
endif
endif
ifeq ($(USE_GPROF_PROFILING),1)
DEBUG_CFLAGS += -pg
endif
SHLIBLIBS=
LANGFLAGS = -x c
SPECIALCC_FLAGS = -fno-rtti -Wno-write-strings -Wno-class-memaccess
SPECIALSOCC_FLAGS = -fno-rtti -Wno-write-strings -Wno-class-memaccess
ifeq ($(USE_CPLUS_0X),1)
SPECIALCC_FLAGS += -std=c++14
SPECIALSOCC_FLAGS += -std=c++14
endif
SPECIALC_FLAGS = -Wstrict-prototypes
BASE_CFLAGS = -Wall -pipe -DUSE_ICON -fno-strict-aliasing -Wno-reorder
# -fno-builtin
CLIENT_CFLAGS = $(SDL_CFLAGS)
SERVER_CFLAGS =
ifeq ($(USE_CPLUS_0X),1)
CLIENT_CFLAGS += -std=c++14
endif
ifeq ($(USE_GPROF_PROFILING),1)
CLIENT_LDFLAGS= -pg
CLIENT_CFLAGS += -pg
endif
#FIXME: why no warings when compiling jpeg lib (no-rtti)
ifeq ($(USE_OPENAL),1)
CLIENT_CFLAGS += -DUSE_OPENAL
ifeq ($(USE_OPENAL_DLOPEN),1)
CLIENT_CFLAGS += -DUSE_OPENAL_DLOPEN
endif
endif
ifeq ($(USE_CURL),1)
CLIENT_CFLAGS += -DUSE_CURL
ifeq ($(USE_CURL_DLOPEN),1)
CLIENT_CFLAGS += -DUSE_CURL_DLOPEN
endif
endif
ifeq ($(USE_CODEC_VORBIS),1)
CLIENT_CFLAGS += -DUSE_CODEC_VORBIS
ifeq ($(USE_INTERNAL_VORBIS),1)
CLIENT_CFLAGS += -I$(VORBISDIR)/include -I$(OGGDIR)/include -I$(VORBISDIR)/lib
endif
endif
ifeq ($(USE_CIN_THEORA),1)
CLIENT_CFLAGS += -DUSE_CIN_THEORA
ifeq ($(USE_LOCAL_HEADERS),1)
CLIENT_CFLAGS += -I$(THEORADIR)/include
else
ifeq ($(USE_CIN_THEORA_BUILDIN),1)
CLIENT_CFLAGS += -I$(THEORADIR)/include
else
CLIENT_CFLAGS += $(THEORA_FLAGS)
endif
endif
endif
#FIXME: optimize overwritten
OPTIMIZEVM = -O2 -DNDEBUG -ffast-math #-fexcess-precision=fast
OPTIMIZE = $(OPTIMIZEVM)
ifeq ($(USE_CPLUS_0X),1)
OPTIMIZEVM = -O2 -fexcess-precision=fast -ffast-math -DNDEBUG
OPTIMIZE = $(OPTIMIZEVM)
endif
# kmap2 optimization flags
KMAP2_OPTIMIZE = -O3 -DNDEBUG -ffast-math #-fexcess-precision=fast
KAAS_OPTIMIZE = -O2 -DNDEBUG
ifeq ($(USE_CPLUS_0X),1)
KMAP2_OPTIMIZE += -O3 -fexcess-precision=fast -ffast-math
KAAS_OPTIMIZE += -O2 -fexcess-precision=fast -ffast-math
endif
KMAP2_CFLAGS += -pthread -I$(KMAP2DIR)/common -I/usr/include/libxml2 $(shell pkg-config --silence-errors --cflags glib-2.0)
KMAP2_CFLAGS += -I$(KMAP2DIR)/libs
KMAP2_CFLAGS += -I$(KMAP2DIR)/zlib
KMAP2_CFLAGS += -I$(KMAP2DIR)/jpeg-6
KMAP2_CFLAGS += -DKMAP2 -D_CONSOLE
# KMAP2_CFLAGS += -m64
KMAP2_CFLAGS += $(KMAP2_OPTIMIZE)
KMAP2_LIBS = -lxml2 -lpthread -lm $(shell pkg-config --silence-errors --libs glib-2.0)
KAAS_CFLAGS = -I$(KAASDIR) -I/usr/include -Wall
KAAS_CFLAGS += -pthread -DBSPC -D_CONSOLE
KAAS_CFLAGS += $(KAAS_OPTIMIZE)
KAAS_LIBS = -lpthread -lm
ifeq ($(USE_FREETYPE), 1)
CLIENT_CFLAGS += -DFT2_BUILD_LIBRARY
CLIENT_CFLAGS += -DBUILD_FREETYPE
CLIENT_CFLAGS += -Icode/freetype/include
endif
CLIENT_CFLAGS += -Icode/asmlib
ifeq ($(USE_ASM_LIB),1)
CLIENT_CFLAGS+=-DUSE_ASM_LIB
SERVER_CFLAGS+=-DUSE_ASM_LIB
NOTSHLIBCFLAGS=-DUSE_ASM_LIB
KAAS_CFLAGS+=-DUSE_ASM_LIB
ifneq ($(ARCH),x86_64)
SHLIBCCFLAGS=-DUSE_ASM_LIB
endif
endif
ifeq ($(USE_OPENMP), 1)
CLIENT_CFLAGS += -fopenmp
NOTSHLIBCFLAGS += -fopenmp
endif
ifeq ($(ARCH),x86_64)
OPTIMIZEVM = -O2 -m64 -ffast-math
ifeq ($(USE_CPLUS_0X),1)
OPTIMIZEVM = -O2 -m64 -fexcess-precision=fast -ffast-math
endif
ifeq ($(USE_GPROF_PROFILING),1)
OPTIMIZE += -g
endif
# FIXME:
# should be added when using gcc 4.5.0 -fexcess-precision=fast
#untested flags -funswitch-loops
# -fno-builtin -Winline --param inline-unit-growth=120 -finline-limit=3600 #-Winline
ifeq ($(USE_SSE), 1)
OPTIMIZE += -msse2
CLIENT_CFLAGS += -DUSE_SSE
SERVER_CFLAGS+=-DUSE_SSE
NOTSHLIBCFLAGS +=-DUSE_SSE
KAAS_CFLAGS += -DUSE_SSE
SHLIBCCFLAGS +=-DUSE_SSE
endif
ifeq ($(USE_INTERNAL_PNG),0)
CLIENT_CFLAGS += -I/usr/include/libpng12
else
CLIENT_CFLAGS += -Icode/png -DUSE_INTERNAL_PNG
endif
HAVE_VM_COMPILED = true
ifeq ($(USE_ASM_LIB),1)
CLIENT_LIBS=$(ASMLIBDIR)/alibelf64.a
DED_LIBS=$(ASMLIBDIR)/alibelf64.a
KAAS_LIBS+=$(ASMLIBDIR)/alibelf64o.a
KMAP2_LIBS+=$(ASMLIBDIR)/alibelf64o.a
endif
else
ifeq ($(ARCH),i386)
OPTIMIZE = -O2 -ffast-math
# OPTIMIZE = -O2 -fexcess-precision=fast -ffast-math
ifeq ($(USE_GPROF_PROFILING),1)
OPTIMIZE += -g
endif
ifeq ($(USE_SSE), 1)
OPTIMIZE += -msse3
CLIENT_CFLAGS += -DUSE_SSE
NOTSHLIBCFLAGS +=-DUSE_SSE
KAAS_CFLAGS += -DUSE_SSE
SHLIBCCFLAGS +=-DUSE_SSE
endif
HAVE_VM_COMPILED=true
ifeq ($(USE_ASM_LIB),1)
CLIENT_LIBS=$(ASMLIBDIR)/alibelf32.a
DED_LIBS=$(ASMLIBDIR)/alibelf32.a
KAAS_LIBS+=$(ASMLIBDIR)/alibelf32o.a
SHLIBLIBS=$(ASMLIBDIR)/alibelf32p.a
KMAP2_LIBS+=$(ASMLIBDIR)/alibelf32o.a
endif
else
ifeq ($(ARCH),ppc)
BASE_CFLAGS += -maltivec
HAVE_VM_COMPILED=true
endif
ifeq ($(ARCH),ppc64)
BASE_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
ifeq ($(USE_TCMALLOC), 1)
BASE_CFLAGS += -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
#LIBS += -ltcmalloc
DED_LIBS+=-ltcmalloc_minimal
CLIENT_LIBS+=-ltcmalloc_minimal
#LIBS += -ltcmalloc_minimal
endif
ifneq ($(HAVE_VM_COMPILED),true)
BASE_CFLAGS += -DNO_VM_COMPILED
endif
CLIENT_CFLAGS += -Icode/jpeg-8c
CLIENT_CFLAGS += -DUSE_INTERNAL_JPG
CLIENT_CFLAGS += -DCOMPAT_KPQ3
CLIENT_LIBS += $(B)/kpq3jpeg8c.a
SHLIBEXT=so
SHLIBCFLAGS=-fPIC -fvisibility=hidden
SHLIBCFLAGS += -DCOMPAT_KPQ3
SHLIBLDFLAGS=-shared $(LDFLAGS)
STATICLIBCFLAGS=$(CLIENT_CFLAGS) --static
STATICLIBLDFLAGS=-static
THREAD_LIBS=-lpthread
#FIXME
#SOTHREAD_LIBS=-lboost_thread
LIBS+=-ldl -lm
CLIENT_LIBS += $(SDL_LIBS) -lGL
ifneq ($(USE_CIN_THEORA),0)
ifeq ($(USE_CIN_THEORA_BUILDIN),0)
CLIENT_LIBS += $(THEORA_LIBS)
endif
endif
ifeq ($(USE_INTERNAL_PNG),0)
CLIENT_LIBS += $(PNG_LIBS)
endif
ifeq ($(USE_INTERNAL_GLEW),0)
CLIENT_CFLAGS+= $(GLEW_FLAGS)
CLIENT_LIBS += $(GLEW_LIBS)
endif
ifeq ($(USE_OPENAL),1)
ifneq ($(USE_OPENAL_DLOPEN),1)
CLIENT_LIBS += -lopenal
endif
endif
ifeq ($(USE_CURL),1)
ifneq ($(USE_CURL_DLOPEN),1)
CLIENT_LIBS += -lcurl
endif
endif
ifeq ($(USE_CODEC_VORBIS),1)
ifeq ($(USE_INTERNAL_VORBIS),0)
CLIENT_LIBS += -lvorbisfile -lvorbis -logg
endif
endif
#CLIENT_LIBS += -lboost_thread
ifeq ($(USE_MUMBLE),1)
CLIENT_LIBS += -lrt
endif
ifeq ($(USE_FREETYPE),1)
ifeq ($(USE_FREETYPE_BUILDIN),0)
#CLIENT_LDFLAGS += $(shell freetype-config --libs)
CLIENT_LIBS += -lfreetype
endif
endif
ifeq ($(USE_LOCAL_HEADERS),1)
CLIENT_CFLAGS += -I$(SDLHDIR)/include
CLIENT_CFLAGS += -I$(GLEWDIR)/include
endif
ifeq ($(USE_INTERNAL_GLEW),1)
CLIENT_CFLAGS += -I$(GLEWDIR)/include -DUSE_INTERNAL_GLEW
endif
ifeq ($(ARCH),i386)
# linux32 make ...
BASE_CFLAGS += -m32
else
ifeq ($(ARCH),ppc64)
BASE_CFLAGS += -m64
endif
endif
ifeq ($(USE_UNSAFE_OPTIMIZATIONS),1)
OPTIMIZE+=-funsafe-loop-optimizations -funsafe-math-optimizations
endif
SHLIBCCFLAGS += $(SHLIBCFLAGS) $(SPECIALSOCC_FLAGS)
LD=g++
else # ifeq Linux
#############################################################################
# SETUP AND BUILD -- MINGW32
#############################################################################
ifeq ($(PLATFORM),mingw32)
# Some MinGW installations define CC to cc, but don't actually provide cc,
# so explicitly use gcc instead (which is the only option anyway)
ifeq ($(call bin_path, $(CC)),)
CC=gcc
endif
SHLIBLIBS=
ifndef WINDRES
WINDRES=windres
endif
LANGFLAGS = -x c
SPECIALCC_FLAGS = -fno-rtti -Wno-write-strings
SPECIALSOCC_FLAGS = -fno-rtti -Wno-write-strings
SPECIALC_FLAGS = -Wstrict-prototypes
BASE_CFLAGS = -Wall -fno-strict-aliasing -DUSE_ICON
CLIENT_CFLAGS = -DSDL_VIDEO_DRIVER_WINDIB
SERVER_CFLAGS =
# In the absence of wspiapi.h, require Windows XP or later
ifeq ($(shell test -e $(CMDIR)/wspiapi.h; echo $$?),1)
BASE_CFLAGS += -DWINVER=0x501
# xp = 0x501
endif
#BASE_CFLAGS += -D_WIN32
ifeq ($(USE_FREETYPE), 1)
CLIENT_CFLAGS += -DFT2_BUILD_LIBRARY
CLIENT_CFLAGS += -DBUILD_FREETYPE
CLIENT_CFLAGS += -Icode/freetype/include
endif
ifeq ($(USE_OPENAL),1)
CLIENT_CFLAGS += -DUSE_OPENAL
CLIENT_CFLAGS += $(OPENAL_CFLAGS)
ifeq ($(USE_OPENAL_DLOPEN),1)
CLIENT_CFLAGS += -DUSE_OPENAL_DLOPEN
else
CLIENT_LDFLAGS += $(OPENAL_LDFLAGS)
endif
endif
ifeq ($(USE_CODEC_VORBIS),1)
CLIENT_CFLAGS += -DUSE_CODEC_VORBIS
CLIENT_CFLAGS += -I$(VORBISDIR)/include -I$(OGGDIR)/include -I$(VORBISDIR)/lib
endif
ifeq ($(ARCH),x64)
OPTIMIZEVM = -O2 -fno-omit-frame-pointer \
-falign-loops=2 -funroll-loops -falign-jumps=2 -falign-functions=2 \
-fstrength-reduce
OPTIMIZE = $(OPTIMIZEVM) --fast-math
HAVE_VM_COMPILED = true
endif
# -fexcess-precision=fast
ifeq ($(ARCH),x86)
OPTIMIZEVM = -O2 -march=i586 -fno-omit-frame-pointer \
-falign-loops=2 -funroll-loops -falign-jumps=2 -falign-functions=2 \
-fstrength-reduce
OPTIMIZE = $(OPTIMIZEVM) -ffast-math
# -mpreferred-stack-boundary=4
ifeq ($(USE_SSE), 1)
OPTIMIZE += -msse2
CLIENT_CFLAGS += -DUSE_SSE
NOTSHLIBCFLAGS +=-DUSE_SSE
SERVER_CFLAGS+=-DUSE_SSE
SHLIBCCFLAGS +=-DUSE_SSE
endif
HAVE_VM_COMPILED = true
endif
KMAP2_OPTIMIZE = -O2 -DNDEBUG
KAAS_OPTIMIZE = -O2 -DNDEBUG
ifeq ($(USE_CPLUS_0X),1)
KMAP2_OPTIMIZE += -O2 -ffast-math
KAAS_OPTIMIZE += -O2 -ffast-math
endif
KMAP2_CFLAGS += -pthread -I$(KMAP2DIR)/common -I/usr/include/libxml2 $(shell pkg-config --silence-errors --cflags glib-2.0)
KMAP2_CFLAGS += -I$(KMAP2DIR)/libs
KMAP2_CFLAGS += -I$(KMAP2DIR)/zlib
KMAP2_CFLAGS += -I$(KMAP2DIR)/jpeg-6
KMAP2_CFLAGS += -DKMAP2 -D_CONSOLE
# KMAP2_CFLAGS += -m64
KMAP2_CFLAGS += $(KMAP2_OPTIMIZE)
KMAP2_LIBS = -lxml2 -lpthread $(shell pkg-config --silence-errors --libs glib-2.0)
KAAS_CFLAGS = -I$(KAASDIR) -Wall
KAAS_CFLAGS += -DBSPC -D_CONSOLE
KAAS_CFLAGS += $(KAAS_OPTIMIZE)
KAAS_LIBS = -lws2_32 -lwinmm
SHLIBEXT=dll
SHLIBCFLAGS=
SHLIBCCFLAGS=-fno-rtti
SHLIBLDFLAGS=-shared $(LDFLAGS)
BINEXT=.exe
LIBS= -lws2_32 -lwinmm -lpsapi
CLIENT_LDFLAGS = -mwindows
CLIENT_LIBS = -lgdi32 -lole32 -lopengl32
ifeq ($(USE_CURL),1)
CLIENT_CFLAGS += -DUSE_CURL
CLIENT_CFLAGS += $(CURL_CFLAGS)
ifneq ($(USE_CURL_DLOPEN),1)
ifeq ($(USE_LOCAL_HEADERS),1)
CLIENT_CFLAGS += -DCURL_STATICLIB
ifeq ($(ARCH),x64)
CLIENT_LIBS += $(LIBSDIR)/win64/libcurl.a
else
CLIENT_LIBS += $(LIBSDIR)/win32/libcurl.a
endif
else
CLIENT_LIBS += $(CURL_LIBS)
endif
else
CLIENT_CFLAGS += -DUSE_CURL_DLOPEN
endif
endif
ifeq ($(USE_CODEC_VORBIS),1)
ifeq ($(USE_VORBIS_INTERNAL),0)
CLIENT_LIBS += -lvorbisfile -lvorbis -logg
else
ifeq ($(ARCH),x86)
CLIENT_LIBS += $(LIBSDIR)/win32/libogg.lib \
$(LIBSDIR)/win32/libvorbis.lib \
$(LIBSDIR)/win32/libvorbisfile.lib
else
CLIENT_LIBS += $(LIBSDIR)/win64/libogg.lib \
$(LIBSDIR)/win64/libvorbis.lib \
$(LIBSDIR)/win64/libvorbisfile.lib
endif
endif
endif
ifeq ($(USE_CIN_THEORA),1)
CLIENT_CFLAGS += -DUSE_CIN_THEORA #-DUSE_CIN_XVID
CLIENT_CFLAGS += -I$(THEORADIR)/include
##CLIENT_CFLAGS += $(THEORA_FLAGS)
#FIXME: local and not local headers
endif
CLIENT_CFLAGS += -Icode/png
ifeq ($(ARCH),x86)
# build 32bit
BASE_CFLAGS += -m32
else
BASE_CFLAGS += -m64
endif
ifeq ($(USE_ASM_LIB),1)
CLIENT_CFLAGS+=-DUSE_ASM_LIB
SERVER_CFLAGS+=-DUSE_ASM_LIB
NOTSHLIBCFLAGS=-DUSE_ASM_LIB
SHLIBCCFLAGS+=-DUSE_ASM_LIB
ifeq ($(ARCH), x86)
CLIENT_LIBS+=$(ASMLIBDIR)/alibcof32.lib
DED_LIBS+=$(ASMLIBDIR)/alibcof32.lib
SHLIBLIBS+=-L$(ASMLIBDIR) $(ASMLIBDIR)/alibd32.lib
else
CLIENT_LIBS+=$(ASMLIBDIR)/alibcof64.lib
DED_LIBS+=$(ASMLIBDIR)/alibcof64.lib
SHLIBLIBS+= -L$(ASMLIBDIR) $(ASMLIBDIR)/alibd64.lib
endif
endif
ifeq ($(USE_INTERNAL_GLEW),0)
# CLIENT_LIBS += -lGLEW
CLIENT_LIBS += -L$(GLEWDIR)/lib $(GLEWDIR)/lib/glew32mx.lib
endif
ifeq ($(USE_INTERNAL_GLEW),1)
CLIENT_CFLAGS += -DGLEW_STATIC -DUSE_INTERNAL_GLEW
endif
ifeq ($(USE_INTERNAL_PNG),0)
CLIENT_CFLAGS += -Icode/png
else
CLIENT_CFLAGS += -Icode/png -DUSE_INTERNAL_PNG
endif
CLIENT_CFLAGS += -Icode/jpeg-8c
CLIENT_CFLAGS += -DUSE_INTERNAL_JPG
CLIENT_CFLAGS += -DCOMPAT_KPQ3
CLIENT_LIBS += $(B)/kpq3jpeg8c.a
ifeq ($(USE_INTERNAL_PNG),0)
ifeq ($(ARCH), x64)
CLIENT_LIBS += $(LIBSDIR)/win64/libpng14.lib
else
CLIENT_LIBS += $(LIBSDIR)/win32/libpng14.lib
endif
endif
ifeq ($(USE_FREETYPE),1)
ifeq ($(USE_FREETYPE_BUILDIN),0)
ifeq ($(ARCH), x86)
CLIENT_LIBS += $(LIBSDIR)/win32/freetype244MT.lib
else
CLIENT_LIBS += $(LIBSDIR)/win64/freetype244MT.lib
endif
endif
endif
# libmingw32 must be linked before libSDLmain
CLIENT_LIBS += -lmingw32
ifeq ($(USE_LOCAL_HEADERS),1)
CLIENT_CFLAGS += -I$(GLEWDIR)/include
CLIENT_CFLAGS += -I$(SDLHDIR)/include
ifeq ($(ARCH), x86)
CLIENT_LIBS += $(LIBSDIR)/win32/SDLmain.lib \
$(LIBSDIR)/win32/SDL.lib
else
CLIENT_LIBS += $(LIBSDIR)/win64/SDLmain.lib \
$(LIBSDIR)/win64/SDL.lib
endif
else
CLIENT_CFLAGS += $(SDL_CFLAGS)
CLIENT_LIBS += $(SDL_LIBS)
endif
ifeq ($(USE_CIN_THEORA),1)
ifeq ($(USE_CIN_THEORA_BUILDIN),0)
ifeq ($(ARCH), x86)
CLIENT_LIBS += $(LIBSDIR)/win32/libtheora.lib
else
CLIENT_LIBS += $(LIBSDIR)/win64/libtheora.lib
endif
endif
endif
BUILD_CLIENT_SMP = 0
SHLIBCCFLAGS += $(SHLIBCFLAGS) $(SPECIALSOCC_FLAGS)
endif # Linux
endif # mingw32
TARGETS =
ifndef FULLBINEXT
FULLBINEXT=.$(ARCH)$(BINEXT)
endif
ifndef SHLIBNAME
SHLIBNAME=$(ARCH).$(SHLIBEXT)
endif
ifneq ($(BUILD_SERVER),0)
TARGETS += $(B)/kpq3ded$(FULLBINEXT)
endif
ifneq ($(BUILD_CLIENT),0)
TARGETS += $(JPEGSLIB)
TARGETS += $(B)/kingpinq3$(FULLBINEXT)
ifneq ($(BUILD_CLIENT_SMP),0)
TARGETS += $(B)/kingpinq3-smp$(FULLBINEXT)
endif
endif
ifneq ($(BUILD_GAME_SO),0)
TARGETS += \
$(B)/basekpq3/cgame$(SHLIBNAME) \
$(B)/basekpq3/qagame$(SHLIBNAME) \
$(B)/basekpq3/ui$(SHLIBNAME)
endif
ifneq ($(BUILD_GAME_QVM),0)
ifneq ($(CROSS_COMPILING),1)
TARGETS += \
$(B)/basekpq3/vm/cgame.qvm \
$(B)/basekpq3/vm/qagame.qvm \
$(B)/basekpq3/vm/ui.qvm
endif
endif
ifneq ($(BUILD_KMAP2),0)
TARGETS += $(B)/kmap2$(FULLBINEXT)
#KMAP2_CFLAGS += -DPRODUCT_VERSION=\\\"$(VERSION)\\\"
endif
ifneq ($(BUILD_KAAS),0)
TARGETS += $(B)/kaas$(FULLBINEXT)
endif
ifeq ($(USE_MUMBLE),1)
CLIENT_CFLAGS += -DUSE_MUMBLE
endif
ifeq ($(USE_VOIP),1)
CLIENT_CFLAGS += -DUSE_VOIP
SERVER_CFLAGS += -DUSE_VOIP
ifeq ($(USE_INTERNAL_SPEEX),1)
CLIENT_CFLAGS += -DFLOATING_POINT -DUSE_ALLOCA -I$(SPEEXDIR)/include
else
CLIENT_LIBS += -lspeex -lspeexdsp
endif
endif
ifeq ($(USE_INTERNAL_ZLIB),1)
BASE_CFLAGS += -DNO_GZIP
ifneq ($(USE_LOCAL_HEADERS),1)
BASE_CFLAGS += -I$(ZDIR)
endif
else
ifeq ($(CROSS_COMPILING), 0)
LIBS += -lz
else
ifeq ($(ARCH),x64)
LIBS += $(LIBSDIR)/mingw64/libz.a
else
LIBS += $(LIBSDIR)/win32/zlib1.lib
endif
#FIXME
endif
endif
ifdef DEFAULT_BASEDIR
BASE_CFLAGS += -DDEFAULT_BASEDIR=\\\"$(DEFAULT_BASEDIR)\\\"
BASE_CCFLAGS += -DDEFAULT_BASEDIR=\\\"$(DEFAULT_BASEDIR)\\\"
endif
ifeq ($(USE_LOCAL_HEADERS),1)
BASE_CFLAGS += -DUSE_LOCAL_HEADERS
endif
ifeq ($(BUILD_STANDALONE),1)
BASE_CFLAGS += -DSTANDALONE
endif
ifeq ($(GENERATE_DEPENDENCIES),1)
DEPEND_CFLAGS = -MMD
else
DEPEND_CFLAGS =
endif
ifeq ($(NO_STRIP),1)
STRIP_FLAG =
else
STRIP_FLAG = -s
endif
BASE_CFLAGS += -DPRODUCT_VERSION=\\\"$(VERSION)\\\"
BASE_CXXFLAGS = $(BASE_CFLAGS) -Wno-reorder
ifeq ($(V),1)
echo_cmd=@:
Q=
else
echo_cmd=@echo
Q=@
endif
define DO_CC
$(echo_cmd) "CC $<"