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