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)
33 DP_MACHINE:=$(shell uname -m)
34 ifeq ($(DP_MACHINE),x86_64)
37 ifeq ($(DP_MACHINE),i686)
40 ifeq ($(DP_MACHINE),i386)
44 endif # ifeq ($(DP_MACHINE),i386)
45 endif # ifeq ($(DP_MACHINE),i686)
46 endif # ifeq ($(DP_MACHINE),x86_64)
60 CMD_MKDIR=$(CMD_UNIXMKDIR)
63 # 64bits AMD CPUs use another lib directory
64 ifeq ($(DP_MACHINE),x86_64)
65 UNIX_X11LIBPATH:=/usr/X11R6/lib64
67 UNIX_X11LIBPATH:=/usr/X11R6/lib
71 TARGETS_DEBUG=sv-debug sdl-debug
72 TARGETS_PROFILE=sv-profile sdl-profile
73 TARGETS_RELEASE=sv-release sdl-release
74 TARGETS_RELEASE_PROFILE=sv-release-profile sdl-release-profile
75 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 ($(WIN32RELEASE), 1)
208 # TARGET=i686-pc-mingw32
210 # WINDRES=$(TARGET)-windres
211 CPUOPTIMIZATIONS=-march=pentium3 -mfpmath=sse -fno-math-errno -fno-rounding-math -fno-signaling-nans -fno-trapping-math
212 # CPUOPTIMIZATIONS+=-DUSE_WSPIAPI_H -DSUPPORTIPV6
213 LDFLAGS_WINCOMMON=-Wl,--large-address-aware
218 ifeq ($(WIN64RELEASE), 1)
219 # TARGET=x86_64-pc-mingw32
221 # WINDRES=$(TARGET)-windres
224 CFLAGS_WARNINGS=-Wall -Winline -Werror=c++-compat -Wwrite-strings -Wshadow -Wold-style-definition -Wstrict-prototypes -Wsign-compare -Wdeclaration-after-statement -Wmissing-prototypes
227 ifeq ($(DP_MAKE_TARGET), mingw)
228 OBJ_ICON=darkplaces.o
229 OBJ_ICON_NEXUIZ=nexuiz.o
231 LDFLAGS_SV=$(LDFLAGS_WINSV)
232 LDFLAGS_SDL=$(LDFLAGS_WINSDL)
234 SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS)
235 SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS)
236 SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS)
239 EXE_SDL=$(EXE_WINSDL)
240 EXE_SVNEXUIZ=$(EXE_WINSVNEXUIZ)
241 EXE_SDLNEXUIZ=$(EXE_WINSDLNEXUIZ)
247 DP_LINK_CRYPTO?=dlopen
248 DP_LINK_CRYPTO_RIJNDAEL?=dlopen
252 # set these to "" if you want to use dynamic loading instead
254 ifeq ($(DP_LINK_SDL), shared)
255 SDL_LIBS=$(SDLCONFIG_LIBS)
257 ifeq ($(DP_LINK_SDL), static)
258 SDL_LIBS=$(SDLCONFIG_STATICLIBS)
261 ifeq ($(DP_LINK_ZLIB), shared)
262 CFLAGS_LIBZ=-DLINK_TO_ZLIB
265 ifeq ($(DP_LINK_ZLIB), dlopen)
271 ifeq ($(DP_LINK_JPEG), shared)
272 CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG
275 ifeq ($(DP_LINK_JPEG), dlopen)
281 ifeq ($(DP_LINK_ODE), shared)
282 ODE_CONFIG?=ode-config
283 LIB_ODE=`$(ODE_CONFIG) --libs`
284 CFLAGS_ODE=`$(ODE_CONFIG) --cflags` -DUSEODE -DLINK_TO_LIBODE
286 ifeq ($(DP_LINK_ODE), dlopen)
292 ifeq ($(DP_LINK_CRYPTO), shared)
293 LIB_CRYPTO=-ld0_blind_id
294 CFLAGS_CRYPTO=-DLINK_TO_CRYPTO
296 ifeq ($(DP_LINK_CRYPTO), dlopen)
300 ifeq ($(DP_LINK_CRYPTO_RIJNDAEL), shared)
301 LIB_CRYPTO_RIJNDAEL=-ld0_rijndael
302 CFLAGS_CRYPTO_RIJNDAEL=-DLINK_TO_CRYPTO_RIJNDAEL
304 ifeq ($(DP_LINK_CRYPTO_RIJNDAEL), dlopen)
306 CFLAGS_CRYPTO_RIJNDAEL=
310 ifeq ($(DP_LINK_XMP), shared)
311 OBJ_SND_XMP=snd_xmp.o
313 CFLAGS_SND_XMP=-DUSEXMP -DLINK_TO_LIBXMP
315 ifeq ($(DP_LINK_XMP), dlopen)
316 OBJ_SND_XMP=snd_xmp.o
318 CFLAGS_SND_XMP=-DUSEXMP
322 ##### Extra CFLAGS #####
328 CFLAGS_FS=-DDP_FS_BASEDIR=\"$(DP_FS_BASEDIR)\"
334 ifneq ($(DP_MAKE_TARGET), mingw)
335 ifdef DP_PRELOAD_DEPENDENCIES
336 # DP_PRELOAD_DEPENDENCIES: when set, link against the libraries needed using -l
337 # dynamically so they won't get loaded at runtime using dlopen
338 LDFLAGS_CL+=$(LDFLAGS_UNIXCL_PRELOAD)
339 LDFLAGS_SV+=$(LDFLAGS_UNIXSV_PRELOAD)
340 LDFLAGS_SDL+=$(LDFLAGS_UNIXSDL_PRELOAD)
341 CFLAGS_PRELOAD=$(CFLAGS_UNIX_PRELOAD)
346 # Systems without IPv6 support should uncomment this:
347 #CFLAGS_NET+=-DNOSUPPORTIPV6
349 ##### GNU Make specific definitions #####
351 DO_LD=$(CC) -o ../../../$@ $^ $(LDFLAGS)
354 ##### Definitions shared by all makefiles #####
358 ##### Dependency files #####
362 # hack to deal with no-longer-needed .h files
365 @echo "NOTE: file $@ mentioned in dependencies missing, continuing..."
366 @echo "HINT: consider 'make clean'"