csqc patch from [515], seems to work with [515]'s dpcsqc test mod, needs a lot of...
[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         clvm_cmds.o \
69         cmd.o \
70         collision.o \
71         common.o \
72         console.o \
73         csprogs.o \
74         curves.o \
75         cvar.o \
76         dpvsimpledecode.o \
77         filematch.o \
78         fractalnoise.o \
79         fs.o \
80         gl_backend.o \
81         gl_draw.o \
82         gl_rmain.o \
83         gl_rsurf.o \
84         gl_textures.o \
85         host.o \
86         host_cmd.o \
87         image.o \
88         image_png.o \
89         jpeg.o \
90         keys.o \
91         lhnet.o \
92         mathlib.o \
93         matrixlib.o \
94         menu.o \
95         meshqueue.o \
96         model_alias.o \
97         model_brush.o \
98         model_shared.o \
99         model_sprite.o \
100         mvm_cmds.o \
101         netconn.o \
102         palette.o \
103         polygon.o \
104         portals.o \
105         protocol.o \
106         prvm_cmds.o \
107         prvm_edict.o \
108         prvm_exec.o \
109         r_crosshairs.o \
110         r_explosion.o \
111         r_lerpanim.o \
112         r_light.o \
113         r_lightning.o \
114         r_modules.o \
115         r_shadow.o \
116         r_sky.o \
117         r_sprites.o \
118         sbar.o \
119         sv_main.o \
120         sv_move.o \
121         sv_phys.o \
122         sv_user.o \
123         svvm_cmds.o \
124         sys_shared.o \
125         ui.o \
126         vid_shared.o \
127         view.o \
128         wad.o \
129         world.o \
130         world_cs.o \
131         zone.o
132
133 # note that builddate.c is very intentionally not compiled to a .o before
134 # being linked, because it should be recompiled every time an executable is
135 # built to give the executable a proper date string
136 OBJ_SV= builddate.c sys_linux.o vid_null.o $(OBJ_SND_NULL) $(OBJ_NOCD) $(OBJ_COMMON)
137 OBJ_SDL= builddate.c sys_sdl.o vid_sdl.o $(OBJ_SND_COMMON) snd_sdl.o cd_sdl.o $(OBJ_COMMON)
138
139
140 # Compilation
141 # CFLAGS_COMMON=-MD -Wall -Werror
142 CFLAGS_COMMON=-MD -Wall -Wsign-compare
143 CFLAGS_DEBUG=-ggdb
144 CFLAGS_PROFILE=-g -pg -ggdb
145 CFLAGS_RELEASE=
146
147 OPTIM_DEBUG=$(CPUOPTIMIZATIONS)
148 OPTIM_RELEASE=-O2 -fno-strict-aliasing -ffast-math -funroll-loops $(CPUOPTIMIZATIONS)
149
150 DO_CC=$(CC) $(CFLAGS) -c $< -o $@
151
152
153 # Link
154 LDFLAGS_DEBUG=-g -ggdb $(OPTIM_DEBUG)
155 LDFLAGS_PROFILE=-g -pg $(OPTIM_RELEASE)
156 LDFLAGS_RELEASE=$(OPTIM_RELEASE)
157
158
159 ##### UNIX specific variables #####
160
161 OBJ_GLX= builddate.c sys_linux.o vid_glx.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
162
163 LDFLAGS_UNIXCOMMON=-lm
164 #LDFLAGS_UNIXCL=-L/usr/X11R6/lib -lX11 -lXext -lXxf86dga -lXxf86vm $(LIB_SOUND)
165 ifeq ($(DP_MAKE_TARGET), sunos)
166         LDFLAGS_UNIXCL=-R$(UNIX_X11LIBPATH) -L$(UNIX_X11LIBPATH) -lX11 -lXext -lXxf86vm $(LIB_SOUND)
167 else
168         LDFLAGS_UNIXCL=-L$(UNIX_X11LIBPATH) -lX11 -lXext -lXxf86dga -lXxf86vm $(LIB_SOUND)
169 endif
170
171 LDFLAGS_UNIXSDL=`sdl-config --libs`
172 EXE_UNIXCL=darkplaces-glx
173 EXE_UNIXSV=darkplaces-dedicated
174 EXE_UNIXSDL=darkplaces-sdl
175
176 CMD_UNIXRM=rm -rf
177
178
179 ##### Linux specific variables #####
180
181 # If you want CD sound in Linux
182 OBJ_LINUXCD=cd_linux.o
183 # If you want no CD audio
184 #OBJ_LINUXCD=$(OBJ_NOCD)
185
186 # Link
187 LDFLAGS_LINUXCL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXCL)
188 LDFLAGS_LINUXSV=$(LDFLAGS_UNIXCOMMON) -ldl
189 LDFLAGS_LINUXSDL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXSDL)
190
191
192 ##### Mac OS X specific variables #####
193
194 # No CD support available
195 OBJ_MACOSXCD=$(OBJ_NOCD)
196
197 # Link
198 LDFLAGS_MACOSXCL=$(LDFLAGS_UNIXCOMMON) -ldl -framework Carbon $(LIB_SOUND)
199 LDFLAGS_MACOSXSV=$(LDFLAGS_UNIXCOMMON) -ldl
200 LDFLAGS_MACOSXSDL=$(LDFLAGS_UNIXCOMMON) -ldl `sdl-config --static-libs`
201
202 OBJ_AGL= builddate.c sys_linux.o vid_agl.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
203
204 EXE_MACOSXCL=darkplaces-agl
205
206
207 ##### SunOS specific variables #####
208
209 # No CD support available
210 OBJ_SUNOSCD=$(OBJ_NOCD)
211
212 CFLAGS_SUNOS=-I/usr/lib/oss/include -DBSD_COMP -DSUNOS
213
214 # Link
215 LDFLAGS_SUNOSCL=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl $(LDFLAGS_UNIXCL)
216 LDFLAGS_SUNOSSV=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl
217 LDFLAGS_SUNOSSDL=$(LDFLAGS_UNIXCOMMON) -ldl -lsocket -lnsl $(LDFLAGS_UNIXSDL)
218
219
220 ##### BSD specific variables #####
221
222 #if you want CD sound in BSD
223 OBJ_BSDCD=cd_bsd.o
224 #if you want no CD audio
225 #OBJ_BSDCD=$(OBJ_NOCD)
226
227 # Link
228 LDFLAGS_BSDCL=$(LDFLAGS_UNIXCOMMON) -lutil $(LDFLAGS_UNIXCL)
229 LDFLAGS_BSDSV=$(LDFLAGS_UNIXCOMMON)
230 LDFLAGS_BSDSDL=$(LDFLAGS_UNIXCOMMON) $(LDFLAGS_UNIXSDL)
231
232
233 ##### Win32 specific variables #####
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) sv-debug cl-debug sdl-debug
281
282 profile :
283         $(MAKE) sv-profile cl-profile sdl-profile
284
285 release :
286         $(MAKE) sv-release cl-release sdl-release
287
288 cl-debug :
289         $(MAKE) bin-debug \
290                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
291                 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
292
293 cl-profile :
294         $(MAKE) bin-profile \
295                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
296                 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
297
298 cl-release :
299         $(MAKE) bin-release \
300                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
301                 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
302
303 sv-debug :
304         $(MAKE) bin-debug \
305                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
306                 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
307
308 sv-profile :
309         $(MAKE) bin-profile \
310                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
311                 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
312
313 sv-release :
314         $(MAKE) bin-release \
315                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
316                 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
317
318 sdl-debug :
319         $(MAKE) bin-debug \
320                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
321                 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
322
323 sdl-profile :
324         $(MAKE) bin-profile \
325                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
326                 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
327
328 sdl-release :
329         $(MAKE) bin-release \
330                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
331                 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
332
333 bin-debug :
334         @echo
335         @echo "========== $(EXE) (debug) =========="
336         $(MAKE) $(EXE) \
337                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
338                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
339                 LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)"
340
341 bin-profile :
342         @echo
343         @echo "========== $(EXE) (profile) =========="
344         $(MAKE) $(EXE) \
345                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
346                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
347                 LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)"
348
349 bin-release :
350         @echo
351         @echo "========== $(EXE) (release) =========="
352         $(MAKE) $(EXE) \
353                 DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \
354                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
355                 LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)"
356         strip $(EXE)
357
358 vid_glx.o: vid_glx.c
359         $(DO_CC) -I/usr/X11R6/include
360
361 vid_sdl.o: vid_sdl.c
362         $(DO_CC) `sdl-config --cflags`
363
364 sys_sdl.o: sys_sdl.c
365         $(DO_CC) `sdl-config --cflags`
366
367 snd_sdl.o: snd_sdl.c
368         $(DO_CC) `sdl-config --cflags`
369
370 cd_sdl.o: cd_sdl.c
371         $(DO_CC) `sdl-config --cflags`
372
373 darkplaces.o: %.o : %.rc
374         windres -o $@ $<
375
376 .c.o:
377         $(DO_CC)
378
379 $(EXE_CL): $(OBJ_CL)
380         $(DO_LD)
381
382 $(EXE_SV): $(OBJ_SV)
383         $(DO_LD)
384
385 $(EXE_SDL): $(OBJ_SDL)
386         $(DO_LD)
387
388 clean:
389         -$(CMD_RM) $(EXE_CL)
390         -$(CMD_RM) $(EXE_SV)
391         -$(CMD_RM) $(EXE_SDL)
392         -$(CMD_RM) *.o
393         -$(CMD_RM) *.d