forked from darklegion/tremulous
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Makefile
2929 lines (2513 loc) · 77.3 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
#
# Tremulous 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
ifeq ($(COMPILE_PLATFORM),linux)
ifeq ($(COMPILE_ARCH),arm)
# Get full arch name
COMPILE_ARCH=$(shell file /bin/true | sed -e 's/^.*ld-linux-\(arm.*\)\.so.*/\1/')
endif
endif
ifndef BUILD_STANDALONE
BUILD_STANDALONE =
endif
ifndef BUILD_CLIENT
BUILD_CLIENT =
endif
ifndef BUILD_SERVER
BUILD_SERVER =
endif
ifndef BUILD_GRANGER
BUILD_GRANGER =
endif
ifndef BUILD_GAME_SO
BUILD_GAME_SO =
endif
ifndef BUILD_GAME_QVM
BUILD_GAME_QVM =
endif
ifndef BUILD_GAME_QVM_11
BUILD_GAME_QVM_11 =
endif
ifndef BUILD_RENDERER_OPENGL2
BUILD_RENDERER_OPENGL2=
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.3.0
endif
ifndef CLIENTBIN
CLIENTBIN=tremulous
endif
ifndef SERVERBIN
SERVERBIN=tremded
endif
ifndef BASEGAME
BASEGAME=gpp
endif
BASEGAME_CFLAGS=-I../../${MOUNT_DIR}
ifndef COPYDIR
COPYDIR="/usr/local/games/tremulous"
endif
ifndef COPYBINDIR
COPYBINDIR=$(COPYDIR)
endif
ifndef MOUNT_DIR
MOUNT_DIR=src
endif
ifndef EXTERNAL_DIR
EXTERNAL_DIR=external
endif
ifndef ASSETS_DIR
ASSETS_DIR=assets
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_RESTCLIENT
USE_RESTCLIENT=1
USE_CURL=1
USE_CURL_DLOPEN=0
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_CODEC_VORBIS
USE_CODEC_VORBIS=1
endif
ifndef USE_CODEC_OPUS
USE_CODEC_OPUS=1
endif
ifndef USE_MUMBLE
USE_MUMBLE=0
endif
ifndef USE_VOIP
USE_VOIP=0
endif
ifndef USE_FREETYPE
USE_FREETYPE=0
endif
ifndef USE_INTERNAL_LIBS
USE_INTERNAL_LIBS=1
endif
ifndef USE_INTERNAL_OGG
USE_INTERNAL_OGG=$(USE_INTERNAL_LIBS)
endif
ifndef USE_INTERNAL_VORBIS
USE_INTERNAL_VORBIS=$(USE_INTERNAL_LIBS)
endif
ifndef USE_INTERNAL_OPUS
USE_INTERNAL_OPUS=$(USE_INTERNAL_LIBS)
endif
ifndef USE_INTERNAL_ZLIB
USE_INTERNAL_ZLIB=$(USE_INTERNAL_LIBS)
endif
ifndef USE_INTERNAL_JPEG
USE_INTERNAL_JPEG=$(USE_INTERNAL_LIBS)
endif
ifndef USE_INTERNAL_LUA
USE_INTERNAL_LUA=$(USE_INTERNAL_LIBS)
endif
ifndef USE_LOCAL_HEADERS
USE_LOCAL_HEADERS=$(USE_INTERNAL_LIBS)
endif
ifndef USE_RENDERER_DLOPEN
USE_RENDERER_DLOPEN=1
endif
ifndef USE_YACC
USE_YACC=0
endif
ifndef DEBUG_CFLAGS
DEBUG_CFLAGS=-ggdb -O0
endif
ifndef BASE_CFLAGS
BASE_CFLAGS=-fno-strict-aliasing
endif
#############################################################################
BD=$(BUILD_DIR)/debug-$(PLATFORM)-$(ARCH)
BR=$(BUILD_DIR)/release-$(PLATFORM)-$(ARCH)
CDIR=$(MOUNT_DIR)/client
SDIR=$(MOUNT_DIR)/server
RCOMMONDIR=$(MOUNT_DIR)/renderercommon
RGL1DIR=$(MOUNT_DIR)/renderergl1
RGL2DIR=$(MOUNT_DIR)/renderergl2
CMDIR=$(MOUNT_DIR)/qcommon
SDLDIR=$(MOUNT_DIR)/sdl
ASMDIR=$(MOUNT_DIR)/asm
SYSDIR=$(MOUNT_DIR)/sys
SCRIPTDIR=$(MOUNT_DIR)/script
GDIR=$(MOUNT_DIR)/game
CGDIR=$(MOUNT_DIR)/cgame
NDIR=$(MOUNT_DIR)/null
UIDIR=$(MOUNT_DIR)/ui
GRANGERDIR=$(MOUNT_DIR)/granger/src
JPDIR=$(EXTERNAL_DIR)/jpeg-8c
OGGDIR=$(EXTERNAL_DIR)/libogg-1.3.2
VORBISDIR=$(EXTERNAL_DIR)/libvorbis-1.3.5
OPUSDIR=$(EXTERNAL_DIR)/opus-1.1.4
OPUSFILEDIR=$(EXTERNAL_DIR)/opusfile-0.8
ZDIR=$(EXTERNAL_DIR)/zlib
LUADIR=$(EXTERNAL_DIR)/lua-5.3.3/src
RESTDIR=$(EXTERNAL_DIR)/restclient
NETTLEDIR=$(EXTERNAL_DIR)/nettle-3.3
SEMVERDIR=$(EXTERNAL_DIR)/semver
LUA_RAPIDJSONDIR=$(MOUNT_DIR)/script/rapidjson
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
SDLHDIR=$(EXTERNAL_DIR)/SDL2
CURLHDIR=$(EXTERNAL_DIR)/libcurl-7.35.0
ALHDIR=$(EXTERNAL_DIR)/AL
LIBSDIR=$(EXTERNAL_DIR)/libs
TEMPDIR=/tmp
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
ifneq ($(call bin_path, pkg-config),)
CURL_CFLAGS ?= $(shell pkg-config --silence-errors --cflags libcurl)
CURL_LIBS ?= $(shell pkg-config --silence-errors --libs libcurl)
OPENAL_CFLAGS ?= $(shell pkg-config --silence-errors --cflags openal)
OPENAL_LIBS ?= $(shell pkg-config --silence-errors --libs openal)
SDL_CFLAGS ?= $(shell pkg-config --silence-errors --cflags sdl2|sed 's/-Dmain=SDL_main//')
SDL_LIBS ?= $(shell pkg-config --silence-errors --libs sdl2)
else
# assume they're in the system default paths (no -I or -L needed)
CURL_LIBS ?= -lcurl
OPENAL_LIBS ?= -lopenal
endif
# Use sdl2-config if all else fails
ifeq ($(SDL_CFLAGS),)
ifneq ($(call bin_path, sdl2-config),)
SDL_CFLAGS ?= $(shell sdl2-config --cflags)
SDL_LIBS ?= $(shell sdl2-config --libs)
endif
endif
endif
# Add git version info
USE_GIT=
ifeq ($(wildcard .git),.git)
GIT_REV=$(shell git describe --tag)
ifneq ($(GIT_REV),)
VERSION:=$(GIT_REV)
USE_GIT=1
endif
endif
#############################################################################
# SETUP AND BUILD -- LINUX
#############################################################################
INSTALL=install
MKDIR=mkdir
EXTRA_FILES=
CLIENT_EXTRA_FILES=
ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu" "gnu"))
BASE_CFLAGS += -DUSE_ICON
CLIENT_CFLAGS += $(SDL_CFLAGS)
OPTIMIZEVM = -O3
OPTIMIZE = $(OPTIMIZEVM) -ffast-math
ifeq ($(ARCH),x86_64)
OPTIMIZEVM = -O3
OPTIMIZE = $(OPTIMIZEVM) -ffast-math -msse2
HAVE_VM_COMPILED = true
else
ifeq ($(ARCH),x86)
OPTIMIZEVM = -O3
OPTIMIZE = $(OPTIMIZEVM) -ffast-math -msse2 -mfpmath=387+sse
HAVE_VM_COMPILED=true
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
ifeq ($(ARCH),armhf)
BASE_CFLAGS += -D__armhf__
endif
endif
endif
SHLIBEXT=so
SHLIBCFLAGS=-fPIC -fvisibility=hidden
SHLIBLDFLAGS=-shared
#$(LDFLAGS)
THREAD_LIBS=-lpthread
LIBS=-ldl -lm
GRANGER_LIBS=-lm -ldl
CLIENT_LIBS=$(SDL_LIBS)
RENDERER_LIBS = $(SDL_LIBS) -lGL
ifeq ($(USE_OPENAL),1)
ifneq ($(USE_OPENAL_DLOPEN),1)
CLIENT_LIBS += $(THREAD_LIBS) $(OPENAL_LIBS)
endif
endif
ifeq ($(USE_CURL),1)
ifneq ($(USE_CURL_DLOPEN),1)
CLIENT_LIBS += $(CURL_LIBS)
ifeq ($(USE_LOCAL_HEADERS),1)
CLIENT_CFLAGS += -I$(CURLHDIR)
else
CLIENT_CFLAGS += $(CURL_CFLAGS)
endif
endif
endif
ifeq ($(USE_MUMBLE),1)
CLIENT_LIBS += -lrt
endif
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
CLIENT_LIBS=
RENDERER_LIBS=
OPTIMIZEVM=
#CXXFLAGS+=-stdlib=libc++
# FIXME This is probably bad idea to comment this out
#BASE_CFLAGS += -mmacosx-version-min=10.7 -DMAC_OS_X_VERSION_MIN_REQUIRED=1070
GRANGER_LIBS = -framework Cocoa -framework Security
ifeq ($(USE_RESTCLIENT),1)
CLIENT_LIBS += -framework Security
endif
ifeq ($(ARCH),ppc)
BASE_CFLAGS += -arch ppc -faltivec
OPTIMIZEVM += -O3
endif
ifeq ($(ARCH),ppc64)
BASE_CFLAGS += -arch ppc64 -faltivec
endif
ifeq ($(ARCH),x86)
OPTIMIZEVM += -mfpmath=387+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 += -arch x86_64 -mfpmath=sse -msse2
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
ifeq ($(USE_OPENAL),1)
ifneq ($(USE_OPENAL_DLOPEN),1)
CLIENT_LIBS += -framework OpenAL
endif
endif
ifeq ($(USE_CURL),1)
CLIENT_CFLAGS += $(CURL_CFLAGS)
ifneq ($(USE_CURL_DLOPEN),1)
CLIENT_LIBS += $(CURL_LIBS)
endif
endif
BASE_CFLAGS += -D_THREAD_SAFE=1
# FIXME: It is not possible to build using system SDL2 framework
# 1. IF you try, this Makefile will still drop libSDL-2.0.0.dylib into the builddir
# 2. Debugger warns that you have 2- which one will be used is undefined
ifeq ($(USE_LOCAL_HEADERS),1)
BASE_CFLAGS += -I$(SDLHDIR)/include -I$(CURLHDIR) -I$(ALHDIR)
endif
# We copy sdlmain before ranlib'ing it so that subversion doesn't think
# the file has been modified by each build.
LIBSDLMAIN=$(B)/libSDL2main.a
LIBSDLMAINSRC=$(LIBSDIR)/macosx/libSDL2main.a
CLIENT_LIBS += -framework IOKit \
$(LIBSDIR)/macosx/libSDL2-2.0.0.dylib
RENDERER_LIBS += -framework OpenGL $(LIBSDIR)/macosx/libSDL2-2.0.0.dylib
CLIENT_EXTRA_FILES += $(LIBSDIR)/macosx/libSDL2-2.0.0.dylib
OPTIMIZE = $(OPTIMIZEVM) -ffast-math
SHLIBEXT=dylib
SHLIBCFLAGS=-fPIC -fno-common
#SHLIBLDFLAGS=-dynamiclib $(LDFLAGS) -Wl,-U,_com_altivec
SHLIBLDFLAGS=-dynamiclib -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
ifneq ($(findstring $(strip $(CXX)),c++ g++),)
CXX=
endif
# We need to figure out the correct gcc and windres
ifeq ($(ARCH),x86_64)
MINGW_PREFIXES=x86_64-w64-mingw32
endif
ifeq ($(ARCH),x86)
MINGW_PREFIXES=i686-w64-mingw32
endif
ifndef CC
CC=$(firstword $(strip $(foreach MINGW_PREFIX, $(MINGW_PREFIXES), $(call bin_path, $(MINGW_PREFIX)-gcc))))
endif
ifndef CXX
CXX=$(firstword $(strip $(foreach MINGW_PREFIX, $(MINGW_PREFIXES), $(call bin_path, $(MINGW_PREFIX)-g++))))
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
ifeq ($(call bin_path, $(CXX)),)
CXX=g++
endif
ifndef WINDRES
WINDRES=windres
endif
endif
ifeq ($(CC),)
$(error Cannot find a suitable cross compiler for $(PLATFORM) CC)
endif
ifeq ($(CXX),)
$(error Cannot find a suitable cross compiler for $(PLATFORM) CXX)
endif
CFLAGS += -static -static-libgcc -static-libstdc++
CXXFLAGS += -static -static-libgcc -static-libstdc++
LDFLAGS += -static -static-libgcc -static-libstdc++
GRANGER_CFLAGS = -D_CRT_SECURE_NO_WARNINGS
BASE_CFLAGS += -DUSE_ICON
# In the absence of wspiapi.h, require Windows XP or later
ifeq ($(shell test -e $(CMDIR)/wspiapi.h; echo $$?),1)
# FIXIT-L Update WINVER=_WIN32_WINNT_WIN7 (see https://msdn.microsoft.com/en-us/library/6sehtctf.aspx)
BASE_CFLAGS += -DWINVER=0x501
endif
ifeq ($(USE_OPENAL),1)
CLIENT_CFLAGS += $(OPENAL_CFLAGS)
ifneq ($(USE_OPENAL_DLOPEN),1)
CLIENT_LDFLAGS += $(OPENAL_LDFLAGS)
endif
ifeq ($(USE_LOCAL_HEADERS),1)
CLIENT_CFLAGS += -I$(ALHDIR)
endif
endif
ifeq ($(ARCH),x86_64)
OPTIMIZEVM = -O3
OPTIMIZE = $(OPTIMIZEVM) -ffast-math -msse2
HAVE_VM_COMPILED = true
BASE_CFLAGS += -m64
endif
ifeq ($(ARCH),x86)
OPTIMIZEVM = -O3
OPTIMIZE = $(OPTIMIZEVM) -ffast-math -msse2 -mfpmath=387+sse
HAVE_VM_COMPILED = true
BASE_CFLAGS += -m32
endif
SHLIBEXT=dll
SHLIBCFLAGS=
#SHLIBLDFLAGS=-shared $(LDFLAGS)
SHLIBLDFLAGS=-shared
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
# clang 3.4 doesn't support this
ifneq ("$(CC)", $(findstring "$(CC)", "clang" "clang++"))
CLIENT_LDFLAGS += -mwindows
endif
CLIENT_LIBS = -lgdi32 -lole32
RENDERER_LIBS = -lgdi32 -lole32 -lopengl32
ifeq ($(USE_FREETYPE),1)
FREETYPE_CFLAGS = -Ifreetype2
endif
ifeq ($(USE_CURL),1)
ifneq ($(USE_CURL_DLOPEN),1)
ifeq ($(USE_LOCAL_HEADERS),1)
CLIENT_CFLAGS += -DCURL_STATICLIB -I$(CURLHDIR)
ifeq ($(ARCH),x86_64)
CLIENT_LIBS += $(LIBSDIR)/win64/libcurl.a
else
CLIENT_LIBS += $(LIBSDIR)/win32/libcurl.a
endif
else
CLIENT_CFLAGS += $(CURL_CFLAGS)
CLIENT_LIBS += $(CURL_LIBS)
endif
endif
endif
# libmingw32 must be linked before libSDLmain
CLIENT_LIBS += -lmingw32
RENDERER_LIBS += -lmingw32
ifeq ($(USE_LOCAL_HEADERS),1)
CLIENT_CFLAGS += -I$(SDLHDIR)/include
ifeq ($(ARCH), x86)
CLIENT_LIBS += $(LIBSDIR)/win32/libSDL2main.a $(LIBSDIR)/win32/libSDL2.dll.a
RENDERER_LIBS += $(LIBSDIR)/win32/libSDL2main.a $(LIBSDIR)/win32/libSDL2.dll.a
SDLDLL=SDL2.dll
CLIENT_EXTRA_FILES += $(LIBSDIR)/win32/SDL2.dll
else
CLIENT_LIBS += $(LIBSDIR)/win64/libSDL264main.a $(LIBSDIR)/win64/libSDL264.dll.a
RENDERER_LIBS += $(LIBSDIR)/win64/libSDL264main.a $(LIBSDIR)/win64/libSDL264.dll.a
SDLDLL=SDL264.dll
CLIENT_EXTRA_FILES += $(LIBSDIR)/win64/SDL264.dll
endif
else
CLIENT_CFLAGS += $(SDL_CFLAGS)
CLIENT_LIBS += $(SDL_LIBS)
RENDERER_LIBS += $(SDL_LIBS)
SDLDLL=SDL2.dll
endif
else # ifdef MINGW
#############################################################################
# SETUP AND BUILD -- FREEBSD
#############################################################################
ifeq ($(PLATFORM),freebsd)
# flags
BASE_CFLAGS = $(shell env MACHINE_ARCH=$(ARCH) make -f /dev/null -VCFLAGS) \
-Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes -DUSE_ICON -DMAP_ANONYMOUS=MAP_ANON
CLIENT_CFLAGS += $(SDL_CFLAGS)
HAVE_VM_COMPILED = true
OPTIMIZEVM = -O3
OPTIMIZE = $(OPTIMIZEVM) -ffast-math
SHLIBEXT=so
SHLIBCFLAGS=-fPIC
#SHLIBLDFLAGS=-shared $(LDFLAGS)
SHLIBLDFLAGS=-shared
THREAD_LIBS=-lpthread
# don't need -ldl (FreeBSD)
LIBS=-lm
GRANGER_LIBS = -lm
CLIENT_LIBS =
CLIENT_LIBS += $(SDL_LIBS)
RENDERER_LIBS = $(SDL_LIBS) -lGL
# optional features/libraries
ifeq ($(USE_OPENAL),1)
ifeq ($(USE_OPENAL_DLOPEN),1)
CLIENT_LIBS += $(THREAD_LIBS) $(OPENAL_LIBS)
endif
endif
ifeq ($(USE_CURL),1)
CLIENT_CFLAGS += $(CURL_CFLAGS)
ifeq ($(USE_CURL_DLOPEN),1)
CLIENT_LIBS += $(CURL_LIBS)
endif
endif
# 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 -- GENERIC
#############################################################################
BASE_CFLAGS=
OPTIMIZE = -O3
SHLIBEXT=so
SHLIBCFLAGS=-fPIC
SHLIBLDFLAGS=-shared
endif #Linux
endif #darwin
endif #MINGW
endif #FreeBSD
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=$(BINEXT)
endif
ifndef SHLIBNAME
SHLIBNAME=.$(SHLIBEXT)
endif
ifneq ($(BUILD_SERVER),0)
TARGETS += $(B)/$(SERVERBIN)$(FULLBINEXT)
endif
ifneq ($(BUILD_CLIENT),0)
ifneq ($(USE_RENDERER_DLOPEN),0)
TARGETS += $(B)/$(CLIENTBIN)$(FULLBINEXT) $(B)/renderer_opengl1$(SHLIBNAME)
ifneq ($(BUILD_RENDERER_OPENGL2),0)
TARGETS += $(B)/renderer_opengl2$(SHLIBNAME)
endif
else
TARGETS += $(B)/$(CLIENTBIN)$(FULLBINEXT)
ifneq ($(BUILD_RENDERER_OPENGL2),0)
TARGETS += $(B)/$(CLIENTBIN)_opengl2$(FULLBINEXT)
endif
endif
endif
ifneq ($(BUILD_GAME_SO),0)
TARGETS += \
$(B)/$(BASEGAME)/cgame$(SHLIBNAME) \
$(B)/$(BASEGAME)/game$(SHLIBNAME) \
$(B)/$(BASEGAME)/ui$(SHLIBNAME)
endif
ifneq ($(BUILD_GAME_QVM),0)
TARGETS += \
$(B)/$(BASEGAME)/vm/cgame.qvm \
$(B)/$(BASEGAME)/vm/game.qvm \
$(B)/$(BASEGAME)/vm/ui.qvm \
$(B)/$(BASEGAME)/vms-gpp-$(VERSION).pk3
endif
ifneq ($(BUILD_GAME_QVM_11),0)
TARGETS += \
$(B)/$(BASEGAME)_11/vm/cgame.qvm \
$(B)/$(BASEGAME)_11/vm/ui.qvm \
$(B)/$(BASEGAME)_11/vms-1.1.0-$(VERSION).pk3
endif
ifneq ($(BUILD_DATA_PK3),0)
TARGETS += \
$(B)/$(BASEGAME)/data-$(VERSION).pk3
endif
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_VOIP),1)
CLIENT_CFLAGS += -DUSE_VOIP
SERVER_CFLAGS += -DUSE_VOIP
NEED_OPUS=1
endif
ifeq ($(USE_CODEC_OPUS),1)
CLIENT_CFLAGS += -DUSE_CODEC_OPUS
NEED_OPUS=1
endif
ifeq ($(NEED_OPUS),1)
ifeq ($(USE_INTERNAL_OPUS),1)
OPUS_CFLAGS = -DOPUS_BUILD -DHAVE_LRINTF -DFLOATING_POINT -DFLOAT_APPROX -DUSE_ALLOCA -D __OPTIMIZE__ \
-I$(OPUSDIR)/include -I$(OPUSDIR)/celt -I$(OPUSDIR)/silk \
-I$(OPUSDIR)/silk/float -I$(OPUSFILEDIR)/include
else
OPUS_CFLAGS ?= $(shell pkg-config --silence-errors --cflags opusfile opus || true)
OPUS_LIBS ?= $(shell pkg-config --silence-errors --libs opusfile opus || echo -lopusfile -lopus)
endif
CLIENT_CFLAGS += $(OPUS_CFLAGS)
CLIENT_LIBS += $(OPUS_LIBS)
NEED_OGG=1
endif
ifeq ($(USE_CODEC_VORBIS),1)
CLIENT_CFLAGS += -DUSE_CODEC_VORBIS
ifeq ($(USE_INTERNAL_VORBIS),1)
CLIENT_CFLAGS += -I$(VORBISDIR)/include -I$(VORBISDIR)/lib
else
VORBIS_CFLAGS ?= $(shell pkg-config --silence-errors --cflags vorbisfile vorbis || true)
VORBIS_LIBS ?= $(shell pkg-config --silence-errors --libs vorbisfile vorbis || echo -lvorbisfile -lvorbis)
endif
CLIENT_CFLAGS += $(VORBIS_CFLAGS)
CLIENT_LIBS += $(VORBIS_LIBS)
NEED_OGG=1
endif
#-bbq
ifeq ($(USE_RESTCLIENT),1)
CLIENT_CFLAGS += -DUSE_RESTCLIENT -I$(RESTDIR)
endif
ifeq ($(NEED_OGG),1)
ifeq ($(USE_INTERNAL_OGG),1)
OGG_CFLAGS = -I$(OGGDIR)/include
else
OGG_CFLAGS ?= $(shell pkg-config --silence-errors --cflags ogg || true)
OGG_LIBS ?= $(shell pkg-config --silence-errors --libs ogg || echo -logg)
endif
CLIENT_CFLAGS += $(OGG_CFLAGS)
CLIENT_LIBS += $(OGG_LIBS)
endif
ifeq ($(USE_RENDERER_DLOPEN),1)
CLIENT_CFLAGS += -DUSE_RENDERER_DLOPEN
endif
ifeq ($(USE_MUMBLE),1)
CLIENT_CFLAGS += -DUSE_MUMBLE
endif
ifeq ($(USE_INTERNAL_ZLIB),1)
ZLIB_CFLAGS = -DNO_GZIP -I$(ZDIR)
else
ZLIB_CFLAGS ?= $(shell pkg-config --silence-errors --cflags zlib || true)
ZLIB_LIBS ?= $(shell pkg-config --silence-errors --libs zlib || echo -lz)
endif
BASE_CFLAGS += $(ZLIB_CFLAGS)
LIBS += $(ZLIB_LIBS)
ifeq ($(USE_INTERNAL_JPEG),1)
BASE_CFLAGS += -DUSE_INTERNAL_JPEG
BASE_CFLAGS += -I$(JPDIR)
else
# IJG libjpeg doesn't have pkg-config, but libjpeg-turbo uses libjpeg.pc;
# we fall back to hard-coded answers if libjpeg.pc is unavailable
JPEG_CFLAGS ?= $(shell pkg-config --silence-errors --cflags libjpeg || true)
JPEG_LIBS ?= $(shell pkg-config --silence-errors --libs libjpeg || echo -ljpeg)
BASE_CFLAGS += $(JPEG_CFLAGS)
RENDERER_LIBS += $(JPEG_LIBS)
endif
ifeq ($(USE_FREETYPE),1)
FREETYPE_CFLAGS ?= $(shell pkg-config --silence-errors --cflags freetype2 || true)
FREETYPE_LIBS ?= $(shell pkg-config --silence-errors --libs freetype2 || echo -lfreetype)
BASE_CFLAGS += -DBUILD_FREETYPE $(FREETYPE_CFLAGS)
RENDERER_LIBS += $(FREETYPE_LIBS)
endif
ifeq ("$(CC)", $(findstring "$(CC)", "clang" "clang++"))
BASE_CFLAGS += -Qunused-arguments
endif
ifdef DEFAULT_BASEDIR
BASE_CFLAGS += -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)\\\"
ifeq ($(V),1)
echo_cmd=@:
Q=
else
echo_cmd=@echo
Q=@
endif
EXEC_CC = $(CC) ${1} -o ${2} -c ${3}
EXEC_CXX = $(CXX) -std=c++1y ${CXXFLAGS} ${1} -o ${2} -c ${3}
# TREMULOUS CLIENT
CC_FLAGS=${NOTSHLIBCFLAGS} ${CFLAGS} ${CLIENT_CFLAGS} ${OPTIMIZE}
define DO_CC
$(echo_cmd) "CC $<"
$(Q)$(call EXEC_CC,-std=gnu99 ${CC_FLAGS},'$@','$<')
$(Q)$(call LOG_CC,tremulous,${CC_FLAGS},$@,$<)
endef
define DO_CXX
$(echo_cmd) "CXX $<"
$(Q)$(call EXEC_CXX,${CC_FLAGS},'$@','$<')
$(Q)$(call LOG_CXX,tremulous,${CC_FLAGS},$@,$<)
endef
##########################################
# Renderers
##########################################
# Common Rendering Code
define DO_RENDERER_COMMON_CC
$(echo_cmd) "RENDERER_COMMON_CC $<"