ode: Disable by default. Minor memory savings in all edict_ts
[xonotic/darkplaces.git] / makefile
1 #####  DP_MAKE_TARGET autodetection and arch specific variables #####
2
3 ifndef DP_MAKE_TARGET
4
5 # Win32
6 ifdef WINDIR
7         DP_MAKE_TARGET=mingw
8 else
9
10 # UNIXes
11 DP_ARCH:=$(shell uname)
12 ifneq ($(filter %BSD,$(DP_ARCH)),)
13         DP_MAKE_TARGET=bsd
14 else
15 ifeq ($(DP_ARCH), Darwin)
16         DP_MAKE_TARGET=macosx
17 else
18 ifeq ($(DP_ARCH), SunOS)
19         DP_MAKE_TARGET=sunos
20 else
21         DP_MAKE_TARGET=linux
22
23 endif  # ifeq ($(DP_ARCH), SunOS)
24 endif  # ifeq ($(DP_ARCH), Darwin)
25 endif  # ifneq ($(filter %BSD,$(DP_ARCH)),)
26 endif  # ifdef windir
27 endif  # ifndef DP_MAKE_TARGET
28
29 # If we're targeting an x86 CPU we want to enable DP_SSE (CFLAGS_SSE and SSE2)
30 ifeq ($(DP_MAKE_TARGET), mingw)
31         DP_SSE:=1
32 else
33         DP_MACHINE:=$(shell uname -m)
34         ifeq ($(DP_MACHINE),x86_64)
35                 DP_SSE:=1
36         else
37         ifeq ($(DP_MACHINE),i686)
38                 DP_SSE:=1
39         else
40         ifeq ($(DP_MACHINE),i386)
41                 DP_SSE:=1
42         else
43                 DP_SSE:=0
44         endif # ifeq ($(DP_MACHINE),i386)
45         endif # ifeq ($(DP_MACHINE),i686)
46         endif # ifeq ($(DP_MACHINE),x86_64)
47 endif
48
49 # Makefile name
50 MAKEFILE=makefile
51
52 # Commands
53 ifdef windir
54         CMD_RM=del
55         CMD_CP=copy /y
56         CMD_MKDIR=mkdir
57 else
58         CMD_RM=$(CMD_UNIXRM)
59         CMD_CP=$(CMD_UNIXCP)
60         CMD_MKDIR=$(CMD_UNIXMKDIR)
61 endif
62
63 # 64bits AMD CPUs use another lib directory
64 ifeq ($(DP_MACHINE),x86_64)
65         UNIX_X11LIBPATH:=/usr/X11R6/lib64
66 else
67         UNIX_X11LIBPATH:=/usr/X11R6/lib
68 endif
69
70 # default targets
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
76
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
82 else
83         CFLAGS_VIDEO_CAPTURE=
84         OBJ_VIDEO_CAPTURE=
85 endif
86
87 # Linux configuration
88 ifeq ($(DP_MAKE_TARGET), linux)
89         OBJ_ICON=
90         OBJ_ICON_NEXUIZ=
91
92         LDFLAGS_SV=$(LDFLAGS_LINUXSV)
93         LDFLAGS_SDL=$(LDFLAGS_LINUXSDL)
94
95         SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
96         SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
97         SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
98
99         EXE_SV=$(EXE_UNIXSV)
100         EXE_SDL=$(EXE_UNIXSDL)
101         EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
102         EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
103
104         DP_LINK_SDL?=shared
105         DP_LINK_ZLIB?=shared
106         DP_LINK_JPEG?=shared
107         DP_LINK_ODE?=
108         DP_LINK_CRYPTO?=dlopen
109         DP_LINK_CRYPTO_RIJNDAEL?=dlopen
110         DP_LINK_XMP?=dlopen
111 endif
112
113 # Mac OS X configuration
114 ifeq ($(DP_MAKE_TARGET), macosx)
115         OBJ_ICON=
116         OBJ_ICON_NEXUIZ=
117
118         LDFLAGS_SV=$(LDFLAGS_MACOSXSV)
119         LDFLAGS_SDL=$(LDFLAGS_MACOSXSDL)
120
121         SDLCONFIG_CFLAGS=$(SDLCONFIG_MACOSXCFLAGS)
122         SDLCONFIG_LIBS=$(SDLCONFIG_MACOSXLIBS)
123         SDLCONFIG_STATICLIBS=$(SDLCONFIG_MACOSXSTATICLIBS)
124
125         EXE_SV=$(EXE_UNIXSV)
126         EXE_SDL=$(EXE_UNIXSDL)
127         EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
128         EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
129
130         ifeq ($(word 2, $(filter -arch, $(CC))), -arch)
131                 CFLAGS_MAKEDEP=
132         endif
133
134         DP_LINK_SDL?=shared
135         DP_LINK_ZLIB?=shared
136         DP_LINK_JPEG?=dlopen
137         DP_LINK_ODE?=
138         DP_LINK_CRYPTO?=dlopen
139         DP_LINK_CRYPTO_RIJNDAEL?=dlopen
140         DP_LINK_XMP?=dlopen
141
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
149 endif
150
151 # SunOS configuration (Solaris)
152 ifeq ($(DP_MAKE_TARGET), sunos)
153         OBJ_ICON=
154         OBJ_ICON_NEXUIZ=
155
156         CFLAGS_EXTRA=$(CFLAGS_SUNOS)
157
158         LDFLAGS_SV=$(LDFLAGS_SUNOSSV)
159         LDFLAGS_SDL=$(LDFLAGS_SUNOSSDL)
160
161         SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
162         SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
163         SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
164
165         EXE_SV=$(EXE_UNIXSV)
166         EXE_SDL=$(EXE_UNIXSDL)
167         EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
168         EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
169
170         DP_LINK_SDL?=shared
171         DP_LINK_ZLIB?=shared
172         DP_LINK_JPEG?=shared
173         DP_LINK_ODE?=
174         DP_LINK_CRYPTO?=dlopen
175         DP_LINK_CRYPTO_RIJNDAEL?=dlopen
176         DP_LINK_XMP?=dlopen
177 endif
178
179 # BSD configuration
180 ifeq ($(DP_MAKE_TARGET), bsd)
181
182         OBJ_ICON=
183         OBJ_ICON_NEXUIZ=
184
185         LDFLAGS_SV=$(LDFLAGS_BSDSV)
186         LDFLAGS_SDL=$(LDFLAGS_BSDSDL)
187
188         SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
189         SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
190         SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
191
192         EXE_SV=$(EXE_UNIXSV)
193         EXE_SDL=$(EXE_UNIXSDL)
194         EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
195         EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
196
197         DP_LINK_SDL?=shared
198         DP_LINK_ZLIB?=shared
199         DP_LINK_JPEG?=shared
200         DP_LINK_ODE?=
201         DP_LINK_CRYPTO?=dlopen
202         DP_LINK_CRYPTO_RIJNDAEL?=dlopen
203         DP_LINK_XMP?=dlopen
204 endif
205
206 # Win32 configuration
207 ifeq ($(WIN32RELEASE), 1)
208 #       TARGET=i686-pc-mingw32
209 #       CC=$(TARGET)-g++
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
214 else
215         LDFLAGS_WINCOMMON=
216 endif
217
218 ifeq ($(WIN64RELEASE), 1)
219 #       TARGET=x86_64-pc-mingw32
220 #       CC=$(TARGET)-g++
221 #       WINDRES=$(TARGET)-windres
222 endif
223
224 CFLAGS_WARNINGS=-Wall -Winline -Werror=c++-compat -Wwrite-strings -Wshadow -Wold-style-definition -Wstrict-prototypes -Wsign-compare -Wdeclaration-after-statement -Wmissing-prototypes
225
226
227 ifeq ($(DP_MAKE_TARGET), mingw)
228         OBJ_ICON=darkplaces.o
229         OBJ_ICON_NEXUIZ=nexuiz.o
230
231         LDFLAGS_SV=$(LDFLAGS_WINSV)
232         LDFLAGS_SDL=$(LDFLAGS_WINSDL)
233
234         SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS)
235         SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS)
236         SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS)
237
238         EXE_SV=$(EXE_WINSV)
239         EXE_SDL=$(EXE_WINSDL)
240         EXE_SVNEXUIZ=$(EXE_WINSVNEXUIZ)
241         EXE_SDLNEXUIZ=$(EXE_WINSDLNEXUIZ)
242
243         DP_LINK_SDL?=shared
244         DP_LINK_ZLIB?=dlopen
245         DP_LINK_JPEG?=shared
246         DP_LINK_ODE?=
247         DP_LINK_CRYPTO?=dlopen
248         DP_LINK_CRYPTO_RIJNDAEL?=dlopen
249         DP_LINK_XMP?=dlopen
250 endif
251
252 # set these to "" if you want to use dynamic loading instead
253 # zlib
254 ifeq ($(DP_LINK_SDL), shared)
255         SDL_LIBS=$(SDLCONFIG_LIBS)
256 endif
257 ifeq ($(DP_LINK_SDL), static)
258         SDL_LIBS=$(SDLCONFIG_STATICLIBS)
259 endif
260
261 ifeq ($(DP_LINK_ZLIB), shared)
262         CFLAGS_LIBZ=-DLINK_TO_ZLIB
263         LIB_Z=-lz
264 endif
265 ifeq ($(DP_LINK_ZLIB), dlopen)
266         CFLAGS_LIBZ=
267         LIB_Z=
268 endif
269
270 # jpeg
271 ifeq ($(DP_LINK_JPEG), shared)
272         CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG
273         LIB_JPEG=-ljpeg
274 endif
275 ifeq ($(DP_LINK_JPEG), dlopen)
276         CFLAGS_LIBJPEG=
277         LIB_JPEG=
278 endif
279
280 # ode
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
285 endif
286 ifeq ($(DP_LINK_ODE), dlopen)
287         LIB_ODE=
288         CFLAGS_ODE=-DUSEODE
289 endif
290
291 # d0_blind_id
292 ifeq ($(DP_LINK_CRYPTO), shared)
293         LIB_CRYPTO=-ld0_blind_id
294         CFLAGS_CRYPTO=-DLINK_TO_CRYPTO
295 endif
296 ifeq ($(DP_LINK_CRYPTO), dlopen)
297         LIB_CRYPTO=
298         CFLAGS_CRYPTO=
299 endif
300 ifeq ($(DP_LINK_CRYPTO_RIJNDAEL), shared)
301         LIB_CRYPTO_RIJNDAEL=-ld0_rijndael
302         CFLAGS_CRYPTO_RIJNDAEL=-DLINK_TO_CRYPTO_RIJNDAEL
303 endif
304 ifeq ($(DP_LINK_CRYPTO_RIJNDAEL), dlopen)
305         LIB_CRYPTO_RIJNDAEL=
306         CFLAGS_CRYPTO_RIJNDAEL=
307 endif
308
309 # xmp
310 ifeq ($(DP_LINK_XMP), shared)
311         OBJ_SND_XMP=snd_xmp.o
312         LIB_SND_XMP=-lxmp
313         CFLAGS_SND_XMP=-DUSEXMP -DLINK_TO_LIBXMP
314 endif
315 ifeq ($(DP_LINK_XMP), dlopen)
316         OBJ_SND_XMP=snd_xmp.o
317         LIB_SND_XMP=
318         CFLAGS_SND_XMP=-DUSEXMP
319 endif
320
321
322 ##### Extra CFLAGS #####
323 ifneq ($(CC), tcc)
324         CFLAGS_MAKEDEP?=-MMD
325 endif
326
327 ifdef DP_FS_BASEDIR
328         CFLAGS_FS=-DDP_FS_BASEDIR=\"$(DP_FS_BASEDIR)\"
329 else
330         CFLAGS_FS=
331 endif
332
333 CFLAGS_PRELOAD=
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)
342 endif
343 endif
344
345 CFLAGS_NET=
346 # Systems without IPv6 support should uncomment this:
347 #CFLAGS_NET+=-DNOSUPPORTIPV6
348
349 ##### GNU Make specific definitions #####
350
351 DO_LD=$(CC) -o ../../../$@ $^ $(LDFLAGS)
352
353
354 ##### Definitions shared by all makefiles #####
355 include makefile.inc
356
357
358 ##### Dependency files #####
359
360 -include *.d
361
362 # hack to deal with no-longer-needed .h files
363 %.h:
364         @echo
365         @echo "NOTE: file $@ mentioned in dependencies missing, continuing..."
366         @echo "HINT: consider 'make clean'"
367         @echo