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)
70 TARGETS_DEBUG=sv-debug sdl-debug
71 TARGETS_PROFILE=sv-profile sdl-profile
72 TARGETS_RELEASE=sv-release sdl-release
73 TARGETS_RELEASE_PROFILE=sv-release-profile sdl-release-profile
74 TARGETS_NEXUIZ=sv-nexuiz sdl-nexuiz
77 ###### Optional features #####
78 DP_VIDEO_CAPTURE?=enabled
79 ifeq ($(DP_VIDEO_CAPTURE), enabled)
80 CFLAGS_VIDEO_CAPTURE=-DCONFIG_VIDEO_CAPTURE
81 OBJ_VIDEO_CAPTURE=cap_avi.o cap_ogg.o
88 ifeq ($(DP_MAKE_TARGET), linux)
92 LDFLAGS_SV=$(LDFLAGS_LINUXSV)
93 LDFLAGS_SDL=$(LDFLAGS_LINUXSDL)
95 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
96 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
97 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
100 EXE_SDL=$(EXE_UNIXSDL)
101 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
102 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
108 DP_LINK_CRYPTO?=dlopen
109 DP_LINK_CRYPTO_RIJNDAEL?=dlopen
113 # Mac OS X configuration
114 ifeq ($(DP_MAKE_TARGET), macosx)
118 LDFLAGS_SV=$(LDFLAGS_MACOSXSV)
119 LDFLAGS_SDL=$(LDFLAGS_MACOSXSDL)
121 SDLCONFIG_CFLAGS=$(SDLCONFIG_MACOSXCFLAGS)
122 SDLCONFIG_LIBS=$(SDLCONFIG_MACOSXLIBS)
123 SDLCONFIG_STATICLIBS=$(SDLCONFIG_MACOSXSTATICLIBS)
126 EXE_SDL=$(EXE_UNIXSDL)
127 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
128 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
130 ifeq ($(word 2, $(filter -arch, $(CC))), -arch)
138 DP_LINK_CRYPTO?=dlopen
139 DP_LINK_CRYPTO_RIJNDAEL?=dlopen
142 # on OS X, we don't build the CL by default because it uses deprecated
143 # and not-implemented-in-64bit Carbon
144 TARGETS_DEBUG=sv-debug sdl-debug
145 TARGETS_PROFILE=sv-profile sdl-profile
146 TARGETS_RELEASE=sv-release sdl-release
147 TARGETS_RELEASE_PROFILE=sv-release-profile sdl-release-profile
148 TARGETS_NEXUIZ=sv-nexuiz sdl-nexuiz
151 # SunOS configuration (Solaris)
152 ifeq ($(DP_MAKE_TARGET), sunos)
156 CFLAGS_EXTRA=$(CFLAGS_SUNOS)
158 LDFLAGS_SV=$(LDFLAGS_SUNOSSV)
159 LDFLAGS_SDL=$(LDFLAGS_SUNOSSDL)
161 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
162 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
163 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
166 EXE_SDL=$(EXE_UNIXSDL)
167 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
168 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
174 DP_LINK_CRYPTO?=dlopen
175 DP_LINK_CRYPTO_RIJNDAEL?=dlopen
180 ifeq ($(DP_MAKE_TARGET), bsd)
185 LDFLAGS_SV=$(LDFLAGS_BSDSV)
186 LDFLAGS_SDL=$(LDFLAGS_BSDSDL)
188 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
189 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
190 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
193 EXE_SDL=$(EXE_UNIXSDL)
194 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
195 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
201 DP_LINK_CRYPTO?=dlopen
202 DP_LINK_CRYPTO_RIJNDAEL?=dlopen
206 # Win32 configuration
207 ifeq ($(DP_MAKE_TARGET), mingw)
208 OBJ_ICON=darkplaces.o
209 OBJ_ICON_NEXUIZ=nexuiz.o
211 LDFLAGS_SV=$(LDFLAGS_WINSV)
212 LDFLAGS_SDL=$(LDFLAGS_WINSDL)
214 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS)
215 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS)
216 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS)
219 EXE_SDL=$(EXE_WINSDL)
220 EXE_SVNEXUIZ=$(EXE_WINSVNEXUIZ)
221 EXE_SDLNEXUIZ=$(EXE_WINSDLNEXUIZ)
227 DP_LINK_CRYPTO?=dlopen
228 DP_LINK_CRYPTO_RIJNDAEL?=dlopen
233 ##### Library linking #####
235 SDL_CONFIG?=sdl2-config
236 SDLCONFIG_UNIXCFLAGS?=`$(SDL_CONFIG) --cflags`
237 SDLCONFIG_UNIXCFLAGS_X11?=
238 SDLCONFIG_UNIXLIBS?=`$(SDL_CONFIG) --libs`
239 SDLCONFIG_UNIXLIBS_X11?=-lX11
240 SDLCONFIG_UNIXSTATICLIBS?=`$(SDL_CONFIG) --static-libs`
241 SDLCONFIG_UNIXSTATICLIBS_X11?=-lX11
242 SDLCONFIG_MACOSXCFLAGS=$(SDLCONFIG_UNIXCFLAGS)
243 SDLCONFIG_MACOSXLIBS=$(SDLCONFIG_UNIXLIBS)
244 SDLCONFIG_MACOSXSTATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS)
245 ifeq ($(DP_LINK_SDL), shared)
246 SDL_LIBS=$(SDLCONFIG_LIBS)
247 else ifeq ($(DP_LINK_SDL), static)
248 SDL_LIBS=$(SDLCONFIG_STATICLIBS)
249 else ifeq ($(DP_LINK_SDL), dlopen)
250 $(error libSDL2 can only be used with shared or static linking)
254 ifeq ($(DP_LINK_ZLIB), shared)
255 CFLAGS_LIBZ=-DLINK_TO_ZLIB
257 else ifeq ($(DP_LINK_ZLIB), static)
258 CFLAGS_LIBZ=-DLINK_TO_ZLIB
260 else ifeq ($(DP_LINK_ZLIB), dlopen)
266 ifeq ($(DP_LINK_JPEG), shared)
267 CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG
269 else ifeq ($(DP_LINK_JPEG), static)
270 CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG
271 LIB_JPEG=-l:libjpeg.a
272 else ifeq ($(DP_LINK_JPEG), dlopen)
278 ifeq ($(DP_LINK_ODE), shared)
279 ODE_CONFIG?=ode-config
280 LIB_ODE=`$(ODE_CONFIG) --libs`
281 CFLAGS_ODE=`$(ODE_CONFIG) --cflags` -DUSEODE -DLINK_TO_LIBODE
282 else ifeq ($(DP_LINK_ODE), static)
283 # This is the configuration from Xonotic
284 ODE_CONFIG?=ode-config
285 LIB_ODE=-l:libode.a -lstdc++ -pthread
286 CFLAGS_ODE=-DUSEODE -DLINK_TO_LIBODE -DdDOUBLE
287 else ifeq ($(DP_LINK_ODE), dlopen)
293 ifeq ($(DP_LINK_CRYPTO), shared)
294 LIB_CRYPTO=-ld0_blind_id
295 CFLAGS_CRYPTO=-DLINK_TO_CRYPTO
296 else ifeq ($(DP_LINK_CRYPTO), static)
297 LIB_CRYPTO=-l:libd0_blind_id.a -lgmp
298 CFLAGS_CRYPTO=-DLINK_TO_CRYPTO
299 else ifeq ($(DP_LINK_CRYPTO), static_inc_gmp)
300 LIB_CRYPTO=-l:libd0_blind_id.a -l:libgmp.a
301 CFLAGS_CRYPTO=-DLINK_TO_CRYPTO
302 else ifeq ($(DP_LINK_CRYPTO), dlopen)
308 ifeq ($(DP_LINK_CRYPTO_RIJNDAEL), shared)
309 LIB_CRYPTO_RIJNDAEL=-ld0_rijndael
310 CFLAGS_CRYPTO_RIJNDAEL=-DLINK_TO_CRYPTO_RIJNDAEL
311 else ifeq ($(DP_LINK_CRYPTO_RIJNDAEL), static)
312 LIB_CRYPTO_RIJNDAEL=-l:libd0_rijndael.a
313 CFLAGS_CRYPTO_RIJNDAEL=-DLINK_TO_CRYPTO_RIJNDAEL
314 else ifeq ($(DP_LINK_CRYPTO_RIJNDAEL), dlopen)
316 CFLAGS_CRYPTO_RIJNDAEL=
320 ifeq ($(DP_LINK_XMP), shared)
321 OBJ_SND_XMP=snd_xmp.o
323 CFLAGS_SND_XMP=-DUSEXMP -DLINK_TO_LIBXMP
324 else ifeq ($(DP_LINK_XMP), static)
325 OBJ_SND_XMP=snd_xmp.o
326 LIB_SND_XMP=-l:libxmp.a
327 CFLAGS_SND_XMP=-DUSEXMP -DLINK_TO_LIBXMP
328 else ifeq ($(DP_LINK_XMP), dlopen)
329 OBJ_SND_XMP=snd_xmp.o
331 CFLAGS_SND_XMP=-DUSEXMP
335 ##### Extra CFLAGS #####
337 CFLAGS_FS=-DDP_FS_BASEDIR=\"$(DP_FS_BASEDIR)\"
343 ifneq ($(DP_MAKE_TARGET), mingw)
344 ifdef DP_PRELOAD_DEPENDENCIES
345 # DP_PRELOAD_DEPENDENCIES: when set, link against the libraries needed using -l
346 # dynamically so they won't get loaded at runtime using dlopen
347 LDFLAGS_CL+=$(LDFLAGS_UNIXCL_PRELOAD)
348 LDFLAGS_SV+=$(LDFLAGS_UNIXSV_PRELOAD)
349 LDFLAGS_SDL+=$(LDFLAGS_UNIXSDL_PRELOAD)
350 CFLAGS_PRELOAD=$(CFLAGS_UNIX_PRELOAD)
355 # Systems without IPv6 support should uncomment this:
356 #CFLAGS_NET+=-DNOSUPPORTIPV6
359 ##### GNU Make specific definitions #####
361 DO_LD=$(CC) -o ../../../$@ $^ $(LDFLAGS)
364 ##### Definitions shared by all makefiles #####
368 ##### Dependency files #####
372 # hack to deal with no-longer-needed .h files
375 @echo "NOTE: file $@ mentioned in dependencies missing, continuing..."
376 @echo "HINT: consider 'make clean'"