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