added png support patch from [515] (had to rewrite most of it though)
[divverent/darkplaces.git] / makefile.inc
1 # Choose the compiler you want to use
2 CC=gcc
3
4 # athlon optimizations
5 #CPUOPTIMIZATIONS=-march=athlon
6 # athlon xp optimizations
7 #CPUOPTIMIZATIONS=-march=athlon-xp
8 # athlon 64 optimizations
9 #CPUOPTIMIZATIONS=-march=athlon64 -m32
10 # Pentium 3 optimizations
11 #CPUOPTIMIZATIONS=-march=pentium3
12 # Pentium 4 optimizations
13 #CPUOPTIMIZATIONS=-march=pentium4
14 # 686 (Pentium Pro/II) optimizations
15 #CPUOPTIMIZATIONS=-march=i686
16 # No specific CPU (386 compatible)
17 CPUOPTIMIZATIONS=
18
19
20 ###### Sound and audio CD #####
21
22 OBJ_SND_COMMON=snd_main.o snd_mem.o snd_mix.o snd_ogg.o snd_wav.o
23
24 # No sound
25 OBJ_SND_NULL=snd_null.o
26 LIB_SND_NULL=
27
28 # Open Sound System (Linux, FreeBSD and Solaris)
29 OBJ_SND_OSS=$(OBJ_SND_COMMON) snd_oss.o
30 LIB_SND_OSS=
31
32 # Advanced Linux Sound Architecture (Linux)
33 OBJ_SND_ALSA=$(OBJ_SND_COMMON) snd_alsa.o
34 LIB_SND_ALSA=-lasound
35
36 # Core Audio (Mac OS X)
37 OBJ_SND_COREAUDIO=$(OBJ_SND_COMMON) snd_coreaudio.c
38 LIB_SND_COREAUDIO=-framework CoreAudio
39
40 # BSD / Sun audio API (NetBSD and OpenBSD)
41 OBJ_SND_BSD=$(OBJ_SND_COMMON) snd_bsd.o
42 LIB_SND_BSD=
43
44 # DirectX and Win32 WAVE output (Win32)
45 OBJ_SND_WIN=$(OBJ_SND_COMMON) snd_win.o
46 LIB_SND_WIN=
47
48
49 # CD objects
50 OBJ_NOCD=cd_null.o
51
52
53 ###### Common objects and flags #####
54
55 # Common objects
56 OBJ_COMMON= \
57         cd_shared.o \
58         cgame.o \
59         cgamevm.o \
60         cl_collision.o \
61         cl_demo.o \
62         cl_input.o \
63         cl_main.o \
64         cl_parse.o \
65         cl_particles.o \
66         cl_screen.o \
67         cl_video.o \
68         cmd.o \
69         collision.o \
70         common.o \
71         console.o \
72         curves.o \
73         cvar.o \
74         dpvsimpledecode.o \
75         filematch.o \
76         fractalnoise.o \
77         fs.o \
78         gl_backend.o \
79         gl_draw.o \
80         gl_rmain.o \
81         gl_rsurf.o \
82         gl_textures.o \
83         host.o \
84         host_cmd.o \
85         image.o \
86         jpeg.o \
87         image_png.o \
88         keys.o \
89         lhnet.o \
90         mathlib.o \
91         matrixlib.o \
92         menu.o \
93         meshqueue.o \
94         model_alias.o \
95         model_brush.o \
96         model_shared.o \
97         model_sprite.o \
98         mvm_cmds.o \
99         netconn.o \
100         palette.o \
101         polygon.o \
102         portals.o \
103         protocol.o \
104         prvm_cmds.o \
105         prvm_edict.o \
106         prvm_exec.o \
107         r_crosshairs.o \
108         r_explosion.o \
109         r_lerpanim.o \
110         r_light.o \
111         r_lightning.o \
112         r_modules.o \
113         r_shadow.o \
114         r_sky.o \
115         r_sprites.o \
116         sbar.o \
117         sv_main.o \
118         sv_move.o \
119         sv_phys.o \
120         sv_user.o \
121         svvm_cmds.o \
122         sys_shared.o \
123         ui.o \
124         vid_shared.o \
125         view.o \
126         wad.o \
127         world.o \
128         zone.o
129
130 # note that builddate.c is very intentionally not compiled to a .o before
131 # being linked, because it should be recompiled every time an executable is
132 # built to give the executable a proper date string
133 OBJ_SV= builddate.c sys_linux.o vid_null.o $(OBJ_SND_NULL) $(OBJ_NOCD) $(OBJ_COMMON)
134 OBJ_SDL= builddate.c sys_sdl.o vid_sdl.o $(OBJ_SND_COMMON) snd_sdl.o cd_sdl.o $(OBJ_COMMON)
135
136
137 # Compilation
138 # CFLAGS_COMMON=-MD -Wall -Werror
139 CFLAGS_COMMON=-MD -Wall -Wsign-compare
140 CFLAGS_DEBUG=-ggdb
141 CFLAGS_PROFILE=-g -pg -ggdb
142 CFLAGS_RELEASE=
143
144 OPTIM_DEBUG=$(CPUOPTIMIZATIONS)
145 OPTIM_RELEASE=-O2 -fno-strict-aliasing -ffast-math -funroll-loops $(CPUOPTIMIZATIONS)
146
147 DO_CC=$(CC) $(CFLAGS) -c $< -o $@
148
149
150 # Link
151 LDFLAGS_DEBUG=-g -ggdb $(OPTIM_DEBUG)
152 LDFLAGS_PROFILE=-g -pg $(OPTIM_RELEASE)
153 LDFLAGS_RELEASE=$(OPTIM_RELEASE)
154
155
156 ##### UNIX specific variables #####
157
158 OBJ_GLX= builddate.c sys_linux.o vid_glx.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
159
160 LDFLAGS_UNIXCOMMON=-lm
161 #LDFLAGS_UNIXCL=-L/usr/X11R6/lib -lX11 -lXext -lXxf86dga -lXxf86vm $(LIB_SOUND)
162 ifeq ($(DP_MAKE_TARGET), sunos)
163         LDFLAGS_UNIXCL=-R$(UNIX_X11LIBPATH) -L$(UNIX_X11LIBPATH) -lX11 -lXext -lXxf86vm $(LIB_SOUND)
164 else
165         LDFLAGS_UNIXCL=-L$(UNIX_X11LIBPATH) -lX11 -lXext -lXxf86dga -lXxf86vm $(LIB_SOUND)
166 endif
167
168 LDFLAGS_UNIXSDL=`sdl-config --libs`
169 EXE_UNIXCL=darkplaces-glx
170 EXE_UNIXSV=darkplaces-dedicated
171 EXE_UNIXSDL=darkplaces-sdl
172
173 CMD_UNIXRM=rm -rf
174
175
176 ##### Linux specific variables #####
177
178 # If you want CD sound in Linux
179 OBJ_LINUXCD=cd_linux.o
180 # If you want no CD audio
181 #OBJ_LINUXCD=$(OBJ_NOCD)
182
183 # Link
184 LDFLAGS_LINUXCL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXCL)
185 LDFLAGS_LINUXSV=$(LDFLAGS_UNIXCOMMON) -ldl
186 LDFLAGS_LINUXSDL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXSDL)
187
188
189 ##### Mac OS X specific variables #####
190
191 # No CD support available
192 OBJ_MACOSXCD=$(OBJ_NOCD)
193
194 # Link
195 LDFLAGS_MACOSXCL=$(LDFLAGS_UNIXCOMMON) -ldl -framework Carbon $(LIB_SOUND)
196 LDFLAGS_MACOSXSV=$(LDFLAGS_UNIXCOMMON) -ldl
197 LDFLAGS_MACOSXSDL=$(LDFLAGS_UNIXCOMMON) -ldl `sdl-config --static-libs`
198
199 OBJ_AGL= builddate.c sys_linux.o vid_agl.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
200
201 EXE_MACOSXCL=darkplaces-agl
202
203
204 ##### SunOS specific variables #####
205
206 # No CD support available
207 OBJ_SUNOSCD=$(OBJ_NOCD)
208
209 CFLAGS_SUNOS=-I/usr/lib/oss/include -DBSD_COMP -DSUNOS
210
211 # Link
212 LDFLAGS_SUNOSCL=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl $(LDFLAGS_UNIXCL)
213 LDFLAGS_SUNOSSV=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl
214 LDFLAGS_SUNOSSDL=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl $(LDFLAGS_UNIXSDL)
215
216
217 ##### BSD specific variables #####
218
219 #if you want CD sound in BSD
220 OBJ_BSDCD=cd_bsd.o
221 #if you want no CD audio
222 #OBJ_BSDCD=$(OBJ_NOCD)
223
224 # Link
225 LDFLAGS_BSDCL=$(LDFLAGS_UNIXCOMMON) -lutil $(LDFLAGS_UNIXCL)
226 LDFLAGS_BSDSV=$(LDFLAGS_UNIXCOMMON)
227 LDFLAGS_BSDSDL=$(LDFLAGS_UNIXCOMMON) $(LDFLAGS_UNIXSDL)
228
229
230 ##### Win32 specific variables #####
231
232 #if you want CD sound in Win32
233 OBJ_WINCD=cd_win.o
234 #if you want no CD audio
235 #OBJ_WINCD=$(OBJ_NOCD)
236
237 OBJ_WGL= builddate.c darkplaces.o sys_win.o vid_wgl.o conproc.o $(OBJ_SND_WIN) $(OBJ_WINCD) $(OBJ_COMMON)
238
239 # Link
240 LDFLAGS_WINCOMMON=-lwinmm -lwsock32
241 LDFLAGS_WINCL=$(LDFLAGS_WINCOMMON) -mwindows -luser32 -lgdi32 -ldxguid -ldinput -lcomctl32
242 LDFLAGS_WINSV=$(LDFLAGS_WINCOMMON) -mconsole
243 LDFLAGS_WINSDL=$(LDFLAGS_WINCOMMON) `sdl-config --libs`
244 EXE_WINCL=darkplaces.exe
245 EXE_WINSV=darkplaces-dedicated.exe
246 EXE_WINSDL=darkplaces-sdl.exe
247
248
249 ##### Commands #####
250
251 .PHONY : clean help \
252          debug profile release \
253          cl-debug cl-profile cl-release \
254          sv-debug sv-profile sv-release \
255          sdl-debug sdl-profile sdl-release
256
257 help:
258         @echo
259         @echo "===== Choose one ====="
260         @echo "* $(MAKE) clean       : delete all files produced by the build"
261         @echo "* $(MAKE) help        : this help"
262         @echo "* $(MAKE) debug       : make client and server binaries (debug versions)"
263         @echo "* $(MAKE) profile     : make client and server binaries (profile versions)"
264         @echo "* $(MAKE) release     : make client and server binaries (release versions)"
265         @echo "* $(MAKE) cl-debug    : make client (debug version)"
266         @echo "* $(MAKE) cl-profile  : make client (profile version)"
267         @echo "* $(MAKE) cl-release  : make client (release version)"
268         @echo "* $(MAKE) sv-debug    : make dedicated server (debug version)"
269         @echo "* $(MAKE) sv-profile  : make dedicated server (profile version)"
270         @echo "* $(MAKE) sv-release  : make dedicated server (release version)"
271         @echo "* $(MAKE) sdl-debug   : make SDL client (debug version)"
272         @echo "* $(MAKE) sdl-profile : make SDL client (profile version)"
273         @echo "* $(MAKE) sdl-release : make SDL client (release version)"
274         @echo
275
276 debug :
277         $(MAKE) sv-debug cl-debug sdl-debug
278
279 profile :
280         $(MAKE) sv-profile cl-profile sdl-profile
281
282 release :
283         $(MAKE) sv-release cl-release sdl-release
284
285 cl-debug :
286         $(MAKE) bin-debug \
287                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
288                 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
289
290 cl-profile :
291         $(MAKE) bin-profile \
292                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
293                 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
294
295 cl-release :
296         $(MAKE) bin-release \
297                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
298                 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
299
300 sv-debug :
301         $(MAKE) bin-debug \
302                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
303                 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
304
305 sv-profile :
306         $(MAKE) bin-profile \
307                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
308                 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
309
310 sv-release :
311         $(MAKE) bin-release \
312                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
313                 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
314
315 sdl-debug :
316         $(MAKE) bin-debug \
317                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
318                 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
319
320 sdl-profile :
321         $(MAKE) bin-profile \
322                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
323                 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
324
325 sdl-release :
326         $(MAKE) bin-release \
327                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
328                 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
329
330 bin-debug :
331         @echo
332         @echo "========== $(EXE) (debug) =========="
333         $(MAKE) $(EXE) \
334                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
335                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
336                 LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)"
337
338 bin-profile :
339         @echo
340         @echo "========== $(EXE) (profile) =========="
341         $(MAKE) $(EXE) \
342                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
343                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
344                 LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)"
345
346 bin-release :
347         @echo
348         @echo "========== $(EXE) (release) =========="
349         $(MAKE) $(EXE) \
350                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
351                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
352                 LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)"
353         strip $(EXE)
354
355 vid_glx.o: vid_glx.c
356         $(DO_CC) -I/usr/X11R6/include
357
358 vid_sdl.o: vid_sdl.c
359         $(DO_CC) `sdl-config --cflags`
360
361 sys_sdl.o: sys_sdl.c
362         $(DO_CC) `sdl-config --cflags`
363
364 snd_sdl.o: snd_sdl.c
365         $(DO_CC) `sdl-config --cflags`
366
367 cd_sdl.o: cd_sdl.c
368         $(DO_CC) `sdl-config --cflags`
369
370 darkplaces.o: %.o : %.rc
371         windres -o $@ $<
372
373 .c.o:
374         $(DO_CC)
375
376 $(EXE_CL): $(OBJ_CL)
377         $(DO_LD)
378
379 $(EXE_SV): $(OBJ_SV)
380         $(DO_LD)
381
382 $(EXE_SDL): $(OBJ_SDL)
383         $(DO_LD)
384
385 clean:
386         -$(CMD_RM) $(EXE_CL)
387         -$(CMD_RM) $(EXE_SV)
388         -$(CMD_RM) $(EXE_SDL)
389         -$(CMD_RM) *.o
390         -$(CMD_RM) *.d