Add more debugging prints in Draw_CachePic, most of these are for edge cases.
[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 cl-debug sdl-debug
72 TARGETS_PROFILE=sv-profile cl-profile sdl-profile
73 TARGETS_RELEASE=sv-release cl-release sdl-release
74 TARGETS_RELEASE_PROFILE=sv-release-profile cl-release-profile sdl-release-profile
75 TARGETS_NEXUIZ=sv-nexuiz cl-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_ZLIB?=shared
105         DP_LINK_JPEG?=shared
106         DP_LINK_ODE?=dlopen
107         DP_LINK_CRYPTO?=dlopen
108         DP_LINK_CRYPTO_RIJNDAEL?=dlopen
109 endif
110
111 # Mac OS X configuration
112 ifeq ($(DP_MAKE_TARGET), macosx)
113         OBJ_ICON=
114         OBJ_ICON_NEXUIZ=
115
116         LDFLAGS_SV=$(LDFLAGS_MACOSXSV)
117         LDFLAGS_SDL=$(LDFLAGS_MACOSXSDL)
118
119         SDLCONFIG_CFLAGS=$(SDLCONFIG_MACOSXCFLAGS)
120         SDLCONFIG_LIBS=$(SDLCONFIG_MACOSXLIBS)
121         SDLCONFIG_STATICLIBS=$(SDLCONFIG_MACOSXSTATICLIBS)
122
123         EXE_SV=$(EXE_UNIXSV)
124         EXE_SDL=$(EXE_UNIXSDL)
125         EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
126         EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
127
128         ifeq ($(word 2, $(filter -arch, $(CC))), -arch)
129                 CFLAGS_MAKEDEP=
130         endif
131
132         DP_LINK_ZLIB?=shared
133         DP_LINK_JPEG?=dlopen
134         DP_LINK_ODE?=dlopen
135         DP_LINK_CRYPTO?=dlopen
136         DP_LINK_CRYPTO_RIJNDAEL?=dlopen
137
138         # on OS X, we don't build the CL by default because it uses deprecated
139         # and not-implemented-in-64bit Carbon
140         TARGETS_DEBUG=sv-debug sdl-debug
141         TARGETS_PROFILE=sv-profile sdl-profile
142         TARGETS_RELEASE=sv-release sdl-release
143         TARGETS_RELEASE_PROFILE=sv-release-profile sdl-release-profile
144         TARGETS_NEXUIZ=sv-nexuiz sdl-nexuiz
145 endif
146
147 # SunOS configuration (Solaris)
148 ifeq ($(DP_MAKE_TARGET), sunos)
149         OBJ_ICON=
150         OBJ_ICON_NEXUIZ=
151
152         CFLAGS_EXTRA=$(CFLAGS_SUNOS)
153
154         LDFLAGS_SV=$(LDFLAGS_SUNOSSV)
155         LDFLAGS_SDL=$(LDFLAGS_SUNOSSDL)
156
157         SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
158         SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
159         SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
160
161         EXE_SV=$(EXE_UNIXSV)
162         EXE_SDL=$(EXE_UNIXSDL)
163         EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
164         EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
165
166         DP_LINK_ZLIB?=shared
167         DP_LINK_JPEG?=shared
168         DP_LINK_ODE?=dlopen
169         DP_LINK_CRYPTO?=dlopen
170         DP_LINK_CRYPTO_RIJNDAEL?=dlopen
171 endif
172
173 # BSD configuration
174 ifeq ($(DP_MAKE_TARGET), bsd)
175
176         OBJ_ICON=
177         OBJ_ICON_NEXUIZ=
178
179         LDFLAGS_SV=$(LDFLAGS_BSDSV)
180         LDFLAGS_SDL=$(LDFLAGS_BSDSDL)
181
182         SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS) $(SDLCONFIG_UNIXCFLAGS_X11)
183         SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS) $(SDLCONFIG_UNIXLIBS_X11)
184         SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS) $(SDLCONFIG_UNIXSTATICLIBS_X11)
185
186         EXE_SV=$(EXE_UNIXSV)
187         EXE_SDL=$(EXE_UNIXSDL)
188         EXE_SVNEXUIZ=$(EXE_UNIXSVNEXUIZ)
189         EXE_SDLNEXUIZ=$(EXE_UNIXSDLNEXUIZ)
190
191         DP_LINK_ZLIB?=shared
192         DP_LINK_JPEG?=shared
193         DP_LINK_ODE?=dlopen
194         DP_LINK_CRYPTO?=dlopen
195         DP_LINK_CRYPTO_RIJNDAEL?=dlopen
196 endif
197
198 # Win32 configuration
199 ifeq ($(WIN32RELEASE), 1)
200 #       TARGET=i686-pc-mingw32
201 #       CC=$(TARGET)-g++
202 #       WINDRES=$(TARGET)-windres
203         CPUOPTIMIZATIONS=-march=pentium3 -mfpmath=sse -fno-math-errno -ffinite-math-only -fno-rounding-math -fno-signaling-nans -fno-trapping-math
204 #       CPUOPTIMIZATIONS+=-DUSE_WSPIAPI_H -DSUPPORTIPV6
205         LDFLAGS_WINCOMMON=-Wl,--large-address-aware
206 else
207         LDFLAGS_WINCOMMON=
208 endif
209
210 ifeq ($(WIN64RELEASE), 1)
211 #       TARGET=x86_64-pc-mingw32
212 #       CC=$(TARGET)-g++
213 #       WINDRES=$(TARGET)-windres
214 endif
215
216 CFLAGS_D3D=
217 CFLAGS_WARNINGS=-Wall -Wold-style-definition -Wstrict-prototypes -Wsign-compare -Wdeclaration-after-statement -Wmissing-prototypes
218 LDFLAGS_D3D=
219
220
221 ifeq ($(DP_MAKE_TARGET), mingw)
222         OBJ_ICON=darkplaces.o
223         OBJ_ICON_NEXUIZ=nexuiz.o
224
225         LDFLAGS_SV=$(LDFLAGS_WINSV)
226         LDFLAGS_SDL=$(LDFLAGS_WINSDL)
227
228         SDLCONFIG_CFLAGS=$(SDLCONFIG_UNIXCFLAGS)
229         SDLCONFIG_LIBS=$(SDLCONFIG_UNIXLIBS)
230         SDLCONFIG_STATICLIBS=$(SDLCONFIG_UNIXSTATICLIBS)
231
232         EXE_SV=$(EXE_WINSV)
233         EXE_SDL=$(EXE_WINSDL)
234         EXE_SVNEXUIZ=$(EXE_WINSVNEXUIZ)
235         EXE_SDLNEXUIZ=$(EXE_WINSDLNEXUIZ)
236
237         DP_LINK_ZLIB?=dlopen
238         DP_LINK_JPEG?=shared
239         DP_LINK_ODE?=dlopen
240         DP_LINK_CRYPTO?=dlopen
241         DP_LINK_CRYPTO_RIJNDAEL?=dlopen
242 endif
243
244 # set these to "" if you want to use dynamic loading instead
245 # zlib
246 ifeq ($(DP_LINK_ZLIB), shared)
247         CFLAGS_LIBZ=-DLINK_TO_ZLIB
248         LIB_Z=-lz
249 endif
250 ifeq ($(DP_LINK_ZLIB), dlopen)
251         CFLAGS_LIBZ=
252         LIB_Z=
253 endif
254
255 # jpeg
256 ifeq ($(DP_LINK_JPEG), shared)
257         CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG
258         LIB_JPEG=-ljpeg
259 endif
260 ifeq ($(DP_LINK_JPEG), dlopen)
261         CFLAGS_LIBJPEG=
262         LIB_JPEG=
263 endif
264
265 # ode
266 ifeq ($(DP_LINK_ODE), shared)
267         ODE_CONFIG?=ode-config
268         LIB_ODE=`$(ODE_CONFIG) --libs`
269         CFLAGS_ODE=`$(ODE_CONFIG) --cflags` -DUSEODE -DLINK_TO_LIBODE
270 endif
271 ifeq ($(DP_LINK_ODE), dlopen)
272         LIB_ODE=
273         CFLAGS_ODE=-DUSEODE
274 endif
275
276 # d0_blind_id
277 ifeq ($(DP_LINK_CRYPTO), shared)
278         LIB_CRYPTO=-ld0_blind_id
279         CFLAGS_CRYPTO=-DLINK_TO_CRYPTO
280 endif
281 ifeq ($(DP_LINK_CRYPTO), dlopen)
282         LIB_CRYPTO=
283         CFLAGS_CRYPTO=
284 endif
285 ifeq ($(DP_LINK_CRYPTO_RIJNDAEL), shared)
286         LIB_CRYPTO_RIJNDAEL=-ld0_rijndael
287         CFLAGS_CRYPTO_RIJNDAEL=-DLINK_TO_CRYPTO_RIJNDAEL
288 endif
289 ifeq ($(DP_LINK_CRYPTO_RIJNDAEL), dlopen)
290         LIB_CRYPTO_RIJNDAEL=
291         CFLAGS_CRYPTO_RIJNDAEL=
292 endif
293
294 ##### Extra CFLAGS #####
295
296 CFLAGS_MAKEDEP?=-MMD
297 ifdef DP_FS_BASEDIR
298         CFLAGS_FS=-DDP_FS_BASEDIR=\"$(DP_FS_BASEDIR)\"
299 else
300         CFLAGS_FS=
301 endif
302
303 CFLAGS_PRELOAD=
304 ifneq ($(DP_MAKE_TARGET), mingw)
305 ifdef DP_PRELOAD_DEPENDENCIES
306 # DP_PRELOAD_DEPENDENCIES: when set, link against the libraries needed using -l
307 # dynamically so they won't get loaded at runtime using dlopen
308         LDFLAGS_CL+=$(LDFLAGS_UNIXCL_PRELOAD)
309         LDFLAGS_SV+=$(LDFLAGS_UNIXSV_PRELOAD)
310         LDFLAGS_SDL+=$(LDFLAGS_UNIXSDL_PRELOAD)
311         CFLAGS_PRELOAD=$(CFLAGS_UNIX_PRELOAD)
312 endif
313 endif
314
315 CFLAGS_NET=
316 # Systems without IPv6 support should uncomment this:
317 #CFLAGS_NET+=-DNOSUPPORTIPV6
318
319 ##### GNU Make specific definitions #####
320
321 DO_LD=$(CC) -o ../../../$@ $^ $(LDFLAGS)
322
323
324 ##### Definitions shared by all makefiles #####
325 include makefile.inc
326
327
328 ##### Dependency files #####
329
330 -include *.d
331
332 # hack to deal with no-longer-needed .h files
333 %.h:
334         @echo
335         @echo "NOTE: file $@ mentioned in dependencies missing, continuing..."
336         @echo "HINT: consider 'make clean'"
337         @echo