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