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 not on compiling for Win32, we need additional information
30 ifneq ($(DP_MAKE_TARGET), mingw)
31 DP_ARCH:=$(shell uname)
32 DP_MACHINE:=$(shell uname -m)
46 CMD_MKDIR=$(CMD_UNIXMKDIR)
49 # 64bits AMD CPUs use another lib directory
50 ifeq ($(DP_MACHINE),x86_64)
51 UNIX_X11LIBPATH:=/usr/X11R6/lib64
53 UNIX_X11LIBPATH:=/usr/X11R6/lib
57 TARGETS_DEBUG=sv-debug cl-debug sdl-debug
58 TARGETS_PROFILE=sv-profile cl-profile sdl-profile
59 TARGETS_RELEASE=sv-release cl-release sdl-release
60 TARGETS_RELEASE_PROFILE=sv-release-profile cl-release-profile sdl-release-profile
61 TARGETS_NEXUIZ=sv-nexuiz cl-nexuiz sdl-nexuiz
64 ifeq ($(DP_MAKE_TARGET), linux)
72 LDFLAGS_CL=$(LDFLAGS_LINUXCL)
73 LDFLAGS_SV=$(LDFLAGS_LINUXSV)
74 LDFLAGS_SDL=$(LDFLAGS_LINUXSDL)
76 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
77 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
78 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
82 EXE_SDL=$(EXE_UNIXSDL)
83 EXE_CLNEXUIZ=$(EXE_UNIXCLNEXUIZ)
84 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
85 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
90 # Mac OS X configuration
91 ifeq ($(DP_MAKE_TARGET), macosx)
92 DEFAULT_SNDAPI=COREAUDIO
93 OBJ_CD=$(OBJ_MACOSXCD)
99 LDFLAGS_CL=$(LDFLAGS_MACOSXCL)
100 LDFLAGS_SV=$(LDFLAGS_MACOSXSV)
101 LDFLAGS_SDL=$(LDFLAGS_MACOSXSDL)
103 SDLCONFIG_CFLAGS=$(SDLCONFIG_MACOSXCFLAGS)
104 SDLCONFIG_LIBS=$(SDLCONFIG_MACOSXLIBS)
105 SDLCONFIG_STATICLIBS=$(SDLCONFIG_MACOSXSTATICLIBS)
107 EXE_CL=$(EXE_MACOSXCL)
109 EXE_SDL=$(EXE_UNIXSDL)
110 EXE_CLNEXUIZ=$(EXE_MACOSXCLNEXUIZ)
111 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
112 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
114 ifeq ($(word 2, $(filter -arch, $(CC))), -arch)
120 # on OS X, we don't build the CL by default because it uses deprecated
121 # and not-implemented-in-64bit Carbon
122 TARGETS_DEBUG=sv-debug sdl-debug
123 TARGETS_PROFILE=sv-profile sdl-profile
124 TARGETS_RELEASE=sv-release sdl-release
125 TARGETS_RELEASE_PROFILE=sv-release-profile sdl-release-profile
126 TARGETS_NEXUIZ=sv-nexuiz sdl-nexuiz
129 # SunOS configuration (Solaris)
130 ifeq ($(DP_MAKE_TARGET), sunos)
132 OBJ_CD=$(OBJ_SUNOSCD)
138 CFLAGS_EXTRA=$(CFLAGS_SUNOS)
140 LDFLAGS_CL=$(LDFLAGS_SUNOSCL)
141 LDFLAGS_SV=$(LDFLAGS_SUNOSSV)
142 LDFLAGS_SDL=$(LDFLAGS_SUNOSSDL)
144 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
145 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
146 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
150 EXE_SDL=$(EXE_UNIXSDL)
151 EXE_CLNEXUIZ=$(EXE_UNIXCLNEXUIZ)
152 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
153 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
159 ifeq ($(DP_MAKE_TARGET), bsd)
160 ifeq ($(DP_ARCH),FreeBSD)
171 LDFLAGS_CL=$(LDFLAGS_BSDCL)
172 LDFLAGS_SV=$(LDFLAGS_BSDSV)
173 LDFLAGS_SDL=$(LDFLAGS_BSDSDL)
175 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
176 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
177 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
181 EXE_SDL=$(EXE_UNIXSDL)
182 EXE_CLNEXUIZ=$(EXE_UNIXCLNEXUIZ)
183 EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
184 EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
189 # Win32 configuration
190 ifeq ($(WIN32RELEASE), 1)
191 # TARGET=i686-pc-mingw32
193 # WINDRES=$(TARGET)-windres
194 CPUOPTIMIZATIONS=-march=i686 -fno-math-errno -ffinite-math-only -fno-rounding-math -fno-signaling-nans -fno-trapping-math
195 # CPUOPTIMIZATIONS+=-DUSE_WSPIAPI_H -DSUPPORTIPV6
196 LDFLAGS_WINCOMMON=-Wl,--large-address-aware
201 ifeq ($(WIN64RELEASE), 1)
202 # TARGET=x86_64-pc-mingw32
204 # WINDRES=$(TARGET)-windres
208 CFLAGS_D3D=-DSUPPORTD3D -DSUPPORTDIRECTX
209 CFLAGS_WARNINGS=-Wall
213 CFLAGS_WARNINGS=-Wall -Wold-style-definition -Wstrict-prototypes -Wsign-compare -Wdeclaration-after-statement -Wmissing-prototypes
218 ifeq ($(DP_MAKE_TARGET), mingw)
223 OBJ_ICON=darkplaces.o
224 OBJ_ICON_NEXUIZ=nexuiz.o
226 LDFLAGS_CL=$(LDFLAGS_WINCL)
227 LDFLAGS_SV=$(LDFLAGS_WINSV)
228 LDFLAGS_SDL=$(LDFLAGS_WINSDL)
230 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS)
231 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS)
232 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS)
236 EXE_SDL=$(EXE_WINSDL)
237 EXE_CLNEXUIZ=$(EXE_WINCLNEXUIZ)
238 EXE_SVNEXUIZ=$(EXE_WINSVNEXUIZ)
239 EXE_SDLNEXUIZ=$(EXE_WINSDLNEXUIZ)
244 # set these to "" if you want to use dynamic loading instead
246 ifeq ($(DP_LINK_LIBS), shared)
247 CFLAGS_LIBZ=-DLINK_TO_ZLIB
250 ifeq ($(DP_LINK_LIBS), dlopen)
256 ifeq ($(DP_LINK_LIBS), shared)
257 CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG
260 ifeq ($(DP_LINK_LIBS), dlopen)
266 ifeq ($(DP_LINK_LIBS), shared)
267 ODE_CONFIG?=ode-config
268 LIB_ODE=`$(ODE_CONFIG) --libs`
269 CFLAGS_ODE=`$(ODE_CONFIG) --cflags` -DUSEODE -DLINK_TO_LIBODE
271 ifeq ($(DP_LINK_LIBS), dlopen)
277 # most distros do not have d0_blind_id package, dlopen will used by default
278 # LIB_CRYPTO=-ld0_blind_id
279 # CFLAGS_CRYPTO=-DLINK_TO_CRYPTO
280 # LIB_CRYPTO_RIJNDAEL=-ld0_rijndael
281 # CFLAGS_CRYPTO_RIJNDAEL=-DLINK_TO_CRYPTO_RIJNDAEL
285 CFLAGS_CRYPTO_RIJNDAEL=
288 # now ogg is mostly used, modplug is required rarely, keep it dlopen by default
289 # LIB_SND_MODPLUG=-lmodplug
290 # CFLAGS_SND_MODPLUG=-DLINK_TO_LIBMODPLUG
294 ##### Sound configuration #####
297 DP_SOUND_API=$(DEFAULT_SNDAPI)
301 ifeq ($(DP_SOUND_API), NULL)
302 OBJ_SOUND=$(OBJ_SND_NULL)
303 LIB_SOUND=$(LIB_SND_NULL)
306 # OSS: Open Sound System
307 ifeq ($(DP_SOUND_API), OSS)
308 OBJ_SOUND=$(OBJ_SND_OSS)
309 LIB_SOUND=$(LIB_SND_OSS)
312 # ALSA: Advanced Linux Sound Architecture
313 ifeq ($(DP_SOUND_API), ALSA)
314 OBJ_SOUND=$(OBJ_SND_ALSA)
315 LIB_SOUND=$(LIB_SND_ALSA)
318 # COREAUDIO: Core Audio
319 ifeq ($(DP_SOUND_API), COREAUDIO)
320 OBJ_SOUND=$(OBJ_SND_COREAUDIO)
321 LIB_SOUND=$(LIB_SND_COREAUDIO)
324 # BSD: BSD / Sun audio API
325 ifeq ($(DP_SOUND_API), BSD)
326 OBJ_SOUND=$(OBJ_SND_BSD)
327 LIB_SOUND=$(LIB_SND_BSD)
330 # WIN: DirectX and Win32 WAVE output
331 ifeq ($(DP_SOUND_API), WIN)
332 OBJ_SOUND=$(OBJ_SND_WIN)
333 LIB_SOUND=$(LIB_SND_WIN)
336 ifeq ($(DP_SOUND_API),3DRAS)
337 OBJ_SOUND=$(OBJ_SND_3DRAS)
338 LIB_SOUND=$(LIB_SND_3DRAS)
341 ##### Extra CFLAGS #####
345 CFLAGS_FS=-DDP_FS_BASEDIR='\"$(DP_FS_BASEDIR)\"'
351 ifneq ($(DP_MAKE_TARGET), mingw)
352 ifdef DP_PRELOAD_DEPENDENCIES
353 # DP_PRELOAD_DEPENDENCIES: when set, link against the libraries needed using -l
354 # dynamically so they won't get loaded at runtime using dlopen
355 LDFLAGS_CL+=$(LDFLAGS_UNIXCL_PRELOAD)
356 LDFLAGS_SV+=$(LDFLAGS_UNIXSV_PRELOAD)
357 LDFLAGS_SDL+=$(LDFLAGS_UNIXSDL_PRELOAD)
358 CFLAGS_PRELOAD=$(CFLAGS_UNIX_PRELOAD)
362 ##### GNU Make specific definitions #####
364 DO_LD=$(CC) -o ../../../$@ $^ $(LDFLAGS)
367 ##### Definitions shared by all makefiles #####
371 ##### Dependency files #####
375 # hack to deal with no-longer-needed .h files
378 @echo "NOTE: file $@ mentioned in dependencies missing, continuing..."
379 @echo "HINT: consider 'make clean'"