1 ##### DP_MAKE_TARGET autodetection and arch specific variables #####
11 DP_ARCH:=$(shell uname)
12 ifneq ($(filter %BSD,$(DP_ARCH)),)
15 ifeq ($(DP_ARCH), Darwin)
18 ifeq ($(DP_ARCH), SunOS)
23 endif # ifeq ($(DP_ARCH), SunOS)
24 endif # ifeq ($(DP_ARCH), Darwin)
25 endif # ifneq ($(filter %BSD,$(DP_ARCH)),)
27 endif # ifndef DP_MAKE_TARGET
29 # If we're targeting an x86 CPU we want to enable DP_SSE (CFLAGS_SSE and SSE2)
30 ifeq ($(DP_MAKE_TARGET), mingw)
32 else ifeq ($(OS),Windows_NT)
33 ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
35 else ifeq ($(PROCESSOR_ARCHITEW6432),AMD64)
37 else ifeq ($(PROCESSOR_ARCHITECTURE),x86)
43 DP_MACHINE:=$(shell uname -m)
44 ifeq ($(DP_MACHINE),x86_64)
46 else ifeq ($(DP_MACHINE),i686)
48 else ifeq ($(DP_MACHINE),i386)
66 CMD_MKDIR=$(CMD_UNIXMKDIR)
69 # 64bits AMD CPUs use another lib directory
70 ifeq ($(DP_MACHINE),x86_64)
71 UNIX_X11LIBPATH:=/usr/X11R6/lib64
73 UNIX_X11LIBPATH:=/usr/X11R6/lib
77 TARGETS_DEBUG=sv-debug sdl-debug
78 TARGETS_PROFILE=sv-profile sdl-profile
79 TARGETS_RELEASE=sv-release sdl-release
80 TARGETS_RELEASE_PROFILE=sv-release-profile sdl-release-profile
81 TARGETS_NEXUIZ=sv-nexuiz sdl-nexuiz
83 ###### Optional features #####
84 DP_VIDEO_CAPTURE?=enabled
85 ifeq ($(DP_VIDEO_CAPTURE), enabled)
86 CFLAGS_VIDEO_CAPTURE=-DCONFIG_VIDEO_CAPTURE
87 OBJ_VIDEO_CAPTURE=cap_avi.o cap_ogg.o
94 ifeq ($(DP_MAKE_TARGET), linux)
98 LDFLAGS_SV=$(LDFLAGS_LINUXSV)
99 LDFLAGS_SDL=$(LDFLAGS_LINUXSDL)
101 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
102 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
103 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
106 EXE_SDL=$(EXE_UNIXSDL)
107 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
108 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
114 DP_LINK_CRYPTO?=dlopen
115 DP_LINK_CRYPTO_RIJNDAEL?=dlopen
119 # Mac OS X configuration
120 ifeq ($(DP_MAKE_TARGET), macosx)
124 LDFLAGS_SV=$(LDFLAGS_MACOSXSV)
125 LDFLAGS_SDL=$(LDFLAGS_MACOSXSDL)
127 SDLCONFIG_CFLAGS=$(SDLCONFIG_MACOSXCFLAGS)
128 SDLCONFIG_LIBS=$(SDLCONFIG_MACOSXLIBS)
129 SDLCONFIG_STATICLIBS=$(SDLCONFIG_MACOSXSTATICLIBS)
132 EXE_SDL=$(EXE_UNIXSDL)
133 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
134 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
136 ifeq ($(word 2, $(filter -arch, $(CC))), -arch)
144 DP_LINK_CRYPTO?=dlopen
145 DP_LINK_CRYPTO_RIJNDAEL?=dlopen
148 # on OS X, we don't build the CL by default because it uses deprecated
149 # and not-implemented-in-64bit Carbon
150 TARGETS_DEBUG=sv-debug sdl-debug
151 TARGETS_PROFILE=sv-profile sdl-profile
152 TARGETS_RELEASE=sv-release sdl-release
153 TARGETS_RELEASE_PROFILE=sv-release-profile sdl-release-profile
154 TARGETS_NEXUIZ=sv-nexuiz sdl-nexuiz
157 # SunOS configuration (Solaris)
158 ifeq ($(DP_MAKE_TARGET), sunos)
162 CFLAGS_EXTRA=$(CFLAGS_SUNOS)
164 LDFLAGS_SV=$(LDFLAGS_SUNOSSV)
165 LDFLAGS_SDL=$(LDFLAGS_SUNOSSDL)
167 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
168 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
169 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
172 EXE_SDL=$(EXE_UNIXSDL)
173 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
174 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
180 DP_LINK_CRYPTO?=dlopen
181 DP_LINK_CRYPTO_RIJNDAEL?=dlopen
186 ifeq ($(DP_MAKE_TARGET), bsd)
191 LDFLAGS_SV=$(LDFLAGS_BSDSV)
192 LDFLAGS_SDL=$(LDFLAGS_BSDSDL)
194 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
195 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
196 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
199 EXE_SDL=$(EXE_UNIXSDL)
200 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
201 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
207 DP_LINK_CRYPTO?=dlopen
208 DP_LINK_CRYPTO_RIJNDAEL?=dlopen
212 # Win32 configuration
213 ifeq ($(WIN32RELEASE), 1)
214 # TARGET=i686-pc-mingw32
216 # WINDRES=$(TARGET)-windres
217 CPUOPTIMIZATIONS=-march=pentium3 -mfpmath=sse -fno-math-errno -fno-rounding-math -fno-signaling-nans -fno-trapping-math
218 # CPUOPTIMIZATIONS+=-DUSE_WSPIAPI_H -DSUPPORTIPV6
219 LDFLAGS_WINCOMMON=-Wl,--large-address-aware
224 ifeq ($(WIN64RELEASE), 1)
225 # TARGET=x86_64-pc-mingw32
227 # WINDRES=$(TARGET)-windres
230 CFLAGS_WARNINGS=-Wall -Winline -Werror=vla -Werror=c++-compat -Wwrite-strings -Wshadow -Wold-style-definition -Wstrict-prototypes -Wsign-compare -Wdeclaration-after-statement -Wmissing-prototypes
233 ifeq ($(DP_MAKE_TARGET), mingw)
234 OBJ_ICON=darkplaces.o
235 OBJ_ICON_NEXUIZ=nexuiz.o
237 LDFLAGS_SV=$(LDFLAGS_WINSV)
238 LDFLAGS_SDL=$(LDFLAGS_WINSDL)
240 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS)
241 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS)
242 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS)
245 EXE_SDL=$(EXE_WINSDL)
246 EXE_SVNEXUIZ=$(EXE_WINSVNEXUIZ)
247 EXE_SDLNEXUIZ=$(EXE_WINSDLNEXUIZ)
253 DP_LINK_CRYPTO?=dlopen
254 DP_LINK_CRYPTO_RIJNDAEL?=dlopen
259 ##### Library linking #####
261 ifeq ($(DP_LINK_SDL), shared)
262 SDL_LIBS=$(SDLCONFIG_LIBS)
263 else ifeq ($(DP_LINK_SDL), static)
264 SDL_LIBS=$(SDLCONFIG_STATICLIBS)
265 else ifeq ($(DP_LINK_SDL), dlopen)
266 $(error libSDL2 can only be used with shared or static linking)
270 ifeq ($(DP_LINK_ZLIB), shared)
271 CFLAGS_LIBZ=-DLINK_TO_ZLIB
273 else ifeq ($(DP_LINK_ZLIB), static)
274 CFLAGS_LIBZ=-DLINK_TO_ZLIB
276 else ifeq ($(DP_LINK_ZLIB), dlopen)
282 ifeq ($(DP_LINK_JPEG), shared)
283 CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG
285 else ifeq ($(DP_LINK_JPEG), static)
286 CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG
287 LIB_JPEG=-l:libjpeg.a
288 else ifeq ($(DP_LINK_JPEG), dlopen)
294 ifeq ($(DP_LINK_ODE), shared)
295 ODE_CONFIG?=ode-config
296 LIB_ODE=`$(ODE_CONFIG) --libs`
297 CFLAGS_ODE=`$(ODE_CONFIG) --cflags` -DUSEODE -DLINK_TO_LIBODE
298 else ifeq ($(DP_LINK_ODE), static)
299 # This is the configuration from Xonotic
300 ODE_CONFIG?=ode-config
301 LIB_ODE=-l:libode.a -lstdc++ -pthread
302 CFLAGS_ODE=-DUSEODE -DLINK_TO_LIBODE -DdDOUBLE
303 else ifeq ($(DP_LINK_ODE), dlopen)
309 ifeq ($(DP_LINK_CRYPTO), shared)
310 LIB_CRYPTO=-ld0_blind_id
311 CFLAGS_CRYPTO=-DLINK_TO_CRYPTO
312 else ifeq ($(DP_LINK_CRYPTO), static)
313 LIB_CRYPTO=-l:libd0_blind_id.a -lgmp
314 CFLAGS_CRYPTO=-DLINK_TO_CRYPTO
315 else ifeq ($(DP_LINK_CRYPTO), static_inc_gmp)
316 LIB_CRYPTO=-l:libd0_blind_id.a -l:libgmp.a
317 CFLAGS_CRYPTO=-DLINK_TO_CRYPTO
318 else ifeq ($(DP_LINK_CRYPTO), dlopen)
324 ifeq ($(DP_LINK_CRYPTO_RIJNDAEL), shared)
325 LIB_CRYPTO_RIJNDAEL=-ld0_rijndael
326 CFLAGS_CRYPTO_RIJNDAEL=-DLINK_TO_CRYPTO_RIJNDAEL
327 else ifeq ($(DP_LINK_CRYPTO_RIJNDAEL), static)
328 LIB_CRYPTO_RIJNDAEL=-l:libd0_rijndael.a
329 CFLAGS_CRYPTO_RIJNDAEL=-DLINK_TO_CRYPTO_RIJNDAEL
330 else ifeq ($(DP_LINK_CRYPTO_RIJNDAEL), dlopen)
332 CFLAGS_CRYPTO_RIJNDAEL=
336 ifeq ($(DP_LINK_XMP), shared)
337 OBJ_SND_XMP=snd_xmp.o
339 CFLAGS_SND_XMP=-DUSEXMP -DLINK_TO_LIBXMP
340 else ifeq ($(DP_LINK_XMP), static)
341 OBJ_SND_XMP=snd_xmp.o
342 LIB_SND_XMP=-l:libxmp.a
343 CFLAGS_SND_XMP=-DUSEXMP -DLINK_TO_LIBXMP
344 else ifeq ($(DP_LINK_XMP), dlopen)
345 OBJ_SND_XMP=snd_xmp.o
347 CFLAGS_SND_XMP=-DUSEXMP
351 ##### Extra CFLAGS #####
357 CFLAGS_FS=-DDP_FS_BASEDIR=\"$(DP_FS_BASEDIR)\"
363 ifneq ($(DP_MAKE_TARGET), mingw)
364 ifdef DP_PRELOAD_DEPENDENCIES
365 # DP_PRELOAD_DEPENDENCIES: when set, link against the libraries needed using -l
366 # dynamically so they won't get loaded at runtime using dlopen
367 LDFLAGS_CL+=$(LDFLAGS_UNIXCL_PRELOAD)
368 LDFLAGS_SV+=$(LDFLAGS_UNIXSV_PRELOAD)
369 LDFLAGS_SDL+=$(LDFLAGS_UNIXSDL_PRELOAD)
370 CFLAGS_PRELOAD=$(CFLAGS_UNIX_PRELOAD)
375 # Systems without IPv6 support should uncomment this:
376 #CFLAGS_NET+=-DNOSUPPORTIPV6
378 ##### GNU Make specific definitions #####
380 DO_LD=$(CC) -o ../../../$@ $^ $(LDFLAGS)
383 ##### Definitions shared by all makefiles #####
387 ##### Dependency files #####
391 # hack to deal with no-longer-needed .h files
394 @echo "NOTE: file $@ mentioned in dependencies missing, continuing..."
395 @echo "HINT: consider 'make clean'"