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