]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - makefile.inc
now compiles on x86_64 successfully (still a crash regarding progs strings to fix...
[xonotic/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_UNIXCL=$(UNIX_X11LIBPATH) -lX11 -lXext -lXxf86dga -lXxf86vm $(LIB_SOUND)
138 LDFLAGS_UNIXSDL=`sdl-config --libs`
139 EXE_UNIXCL=darkplaces-glx
140 EXE_UNIXSV=darkplaces-dedicated
141 EXE_UNIXSDL=darkplaces-sdl
142
143 CMD_UNIXRM=rm -rf
144
145
146 ##### Linux specific variables #####
147
148 # Recommended for: anyone not using ALSA
149 OBJ_LINUXSOUND=$(OBJ_COMMONSOUND) snd_oss.o
150 LIB_LINUXSOUND=
151 # Recommended for: anyone using ALSA
152 #OBJ_LINUXSOUND=$(OBJ_COMMONSOUND) snd_alsa.o
153 #LIB_LINUXSOUND=-lasound
154 # Recommended for: anyone who can't use the above drivers
155 #OBJ_LINUXSOUND=$(OBJ_NOSOUND)
156 #LIB_LINUXSOUND=
157
158 # If you want CD sound in Linux
159 OBJ_LINUXCD=cd_linux.o
160 # If you want no CD audio
161 #OBJ_LINUXCD=$(OBJ_NOCD)
162
163 # Link
164 LDFLAGS_LINUXCL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXCL)
165 LDFLAGS_LINUXSV=$(LDFLAGS_UNIXCOMMON) -ldl
166 LDFLAGS_LINUXSDL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXSDL)
167
168
169 ##### BSD specific variables #####
170
171 OBJ_BSDSOUND=$(OBJ_COMMONSOUND) snd_bsd.o
172 #OBJ_BSDSOUND=$(OBJ_NOSOUND)
173 LIB_BSDSOUND=
174
175 #if you want CD sound in BSD
176 OBJ_BSDCD=cd_bsd.o
177 #if you want no CD audio
178 #OBJ_BSDCD=$(OBJ_NOCD)
179
180 # Link
181 LDFLAGS_BSDCL=$(LDFLAGS_UNIXCOMMON) -lutil $(LDFLAGS_UNIXCL)
182 LDFLAGS_BSDSV=$(LDFLAGS_UNIXCOMMON)
183 LDFLAGS_BSDSDL=$(LDFLAGS_UNIXCOMMON) $(LDFLAGS_UNIXSDL)
184
185
186 ##### Win32 specific variables #####
187
188 OBJ_WINSOUND=$(OBJ_COMMONSOUND) snd_win.o
189 #OBJ_WINSOUND=$(OBJ_NOSOUND)
190 LIB_WINSOUND=
191
192 #if you want CD sound in Win32
193 OBJ_WINCD=cd_win.o
194 #if you want no CD audio
195 #OBJ_WINCD=$(OBJ_NOCD)
196
197 OBJ_WGL= builddate.c darkplaces.o sys_win.o vid_wgl.o conproc.o $(OBJ_WINSOUND) $(OBJ_WINCD) $(OBJ_COMMON)
198
199 # Link
200 LDFLAGS_WINCOMMON=-lwinmm -lwsock32
201 LDFLAGS_WINCL=$(LDFLAGS_WINCOMMON) -mwindows -luser32 -lgdi32 -ldxguid -ldinput -lcomctl32
202 LDFLAGS_WINSV=$(LDFLAGS_WINCOMMON) -mconsole -lwinmm -lwsock32
203 LDFLAGS_WINSDL=$(LDFLAGS_WINCOMMON)  -mwindows -luser32 -lgdi32 -ldxguid -ldinput -lcomctl32
204 EXE_WINCL=darkplaces.exe
205 EXE_WINSV=darkplaces-dedicated.exe
206 EXE_WINSDL=darkplaces-sdl.exe
207
208
209 ##### Commands #####
210
211 .PHONY : clean help \
212          debug profile release \
213          cl-debug cl-profile cl-release \
214          sv-debug sv-profile sv-release \
215          sdl-debug sdl-profile sdl-release
216
217 help:
218         @echo
219         @echo "===== Choose one ====="
220         @echo "* $(MAKE) clean       : delete all files produced by the build"
221         @echo "* $(MAKE) help        : this help"
222         @echo "* $(MAKE) debug       : make client and server binaries (debug versions)"
223         @echo "* $(MAKE) profile     : make client and server binaries (profile versions)"
224         @echo "* $(MAKE) release     : make client and server binaries (release versions)"
225         @echo "* $(MAKE) cl-debug    : make client (debug version)"
226         @echo "* $(MAKE) cl-profile  : make client (profile version)"
227         @echo "* $(MAKE) cl-release  : make client (release version)"
228         @echo "* $(MAKE) sv-debug    : make dedicated server (debug version)"
229         @echo "* $(MAKE) sv-profile  : make dedicated server (profile version)"
230         @echo "* $(MAKE) sv-release  : make dedicated server (release version)"
231         @echo "* $(MAKE) sdl-debug   : make SDL client (debug version)"
232         @echo "* $(MAKE) sdl-profile : make SDL client (profile version)"
233         @echo "* $(MAKE) sdl-release : make SDL client (release version)"
234         @echo
235
236 debug :
237         $(MAKE) cl-debug sv-debug DP_MAKE_TARGET=$(DP_MAKE_TARGET)
238
239 profile :
240         $(MAKE) cl-profile sv-profile DP_MAKE_TARGET=$(DP_MAKE_TARGET)
241
242 release :
243         $(MAKE) cl-release sv-release DP_MAKE_TARGET=$(DP_MAKE_TARGET)
244
245 cl-debug :
246         $(MAKE) bin-debug DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
247                 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
248
249 cl-profile :
250         $(MAKE) bin-profile DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
251                 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
252
253 cl-release :
254         $(MAKE) bin-release DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
255                 EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
256
257 sv-debug :
258         $(MAKE) bin-debug DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
259                 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
260
261 sv-profile :
262         $(MAKE) bin-profile DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
263                 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
264
265 sv-release :
266         $(MAKE) bin-release DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
267                 EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
268
269 sdl-debug :
270         $(MAKE) bin-debug DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
271                 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
272
273 sdl-profile :
274         $(MAKE) bin-profile DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
275                 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
276
277 sdl-release :
278         $(MAKE) bin-release DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
279                 EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
280
281 bin-debug :
282         @echo
283         @echo "========== $(EXE) (debug) =========="
284         $(MAKE) $(EXE) DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
285                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
286                 LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)"
287
288 bin-profile :
289         @echo
290         @echo "========== $(EXE) (profile) =========="
291         $(MAKE) $(EXE) DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
292                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
293                 LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)"
294
295 bin-release :
296         @echo
297         @echo "========== $(EXE) (release) =========="
298         $(MAKE) $(EXE) DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
299                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
300                 LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)"
301         strip $(EXE)
302
303 vid_glx.o: vid_glx.c
304         $(DO_CC) -I/usr/X11R6/include
305
306 vid_sdl.o: vid_sdl.c
307         $(DO_CC) `sdl-config --cflags`
308
309 sys_sdl.o: sys_sdl.c
310         $(DO_CC) `sdl-config --cflags`
311
312 darkplaces.o: %.o : %.rc
313         windres -o $@ $<
314
315 .c.o:
316         $(DO_CC)
317
318 $(EXE_CL): $(OBJ_CL)
319         $(DO_LD)
320
321 $(EXE_SV): $(OBJ_SV)
322         $(DO_LD)
323
324 $(EXE_SDL): $(OBJ_SDL)
325         $(DO_LD)
326
327 clean:
328         -$(CMD_RM) $(EXE_CL)
329         -$(CMD_RM) $(EXE_SV)
330         -$(CMD_RM) $(EXE_SDL)
331         -$(CMD_RM) *.o
332         -$(CMD_RM) *.d