1# GNU Makefile for Quake II and modifications.
2#
3# Usage: just type "make".
4#
5# Configuration: the BUILD_* variables indicate the building of a component,
6# and the WITH_* variables set options for these components. The "TYPE"
7# variable indicates the type of build to do (release, debug and profile).
8#
9# Written by Alejandro Pulver for QuDos.
10#
11
12# Targets for building.
13
14# FIXME: do not build dependencies when not building (define a variable and
15# check for it before including files).
16
17# OS type and architecture detection
18ARCH:=		$(shell uname -m | sed -e 's/i.86/i386/')
19OSTYPE:=	$(shell uname -s)
20
21# Client and Renderers
22BUILD_QUAKE2?=YES	# Build client (OSS sound, cdrom ioctls for cd audio).
23BUILD_DEDICATED?=NO	# Build dedicated server.
24BUILD_GLX?=YES		# Build OpenGL renderer.
25BUILD_SDLGL?=YES	# Build SDL OpenGL renderer.
26ifeq ($(OSTYPE),Linux)
27BUILD_ALSA_SND?=YES     # Enable support for ALSA (default sound on 2.6 Linux).
28endif
29BUILD_ARTS_SND?=NO      # Enable support for libaRts (KDE sound system) sound.
30BUILD_OSS_SND?=YES      # Enable support for OSS (default) sound.
31BUILD_SDL_SND?=YES      # Enable support for SDL sound.
32
33# Mods
34BUILD_GAME?=YES		# Build original game modification (game$(ARCH).so).
35BUILD_3ZB2?=NO		# Build 3zb2 (bots) modification.
36BUILD_CTF?=NO		# Build CTF (Capture The Flag) modification.
37BUILD_JABOT?=NO		# Build JABot (bots) modification.
38BUILD_ROGUE?=NO		# Build Rogue modification.
39BUILD_XATRIX?=NO	# Build Xatrix modification.
40BUILD_ZAERO?=NO		# Build Zaero modification.
41
42# Configurable options.
43WITH_BOTS?=YES		# Enable Ace Bot support in modifications (Quake2, Rogue, Xatrix and Zaero).
44WITH_DATADIR?=NO	# Read from $(DATADIR) and write to "~/.quake2".
45WITH_DGA_MOUSE?=NO	# Enable DGA mouse extension.
46WITH_GAME_MOD?=YES	# Enable custom addons in the main modification (Quake2, Rogue, Xatrix and Zaero).
47WITH_IPV6?=NO		# Enable IPv6 support. Tested on FreeBSD.
48WITH_JOYSTICK?=NO	# Enable joystick support.
49WITH_LIBDIR?=NO		# Read data and renderers from $(LIBDIR).
50WITH_QMAX?=YES		# Enable fancier OpenGL graphics.
51WITH_REDBLUE?=NO	# Enable red-blue 3d glasses renderer.
52WITH_RETEXTURE?=YES	# Enable retextured graphics support.
53WITH_X86_ASM?=NO	# Enable x86 assembly code (only for i386).
54WITH_XMMS?=YES		# Enable XMMS support (thanks AprQ2).
55
56# General variables.
57LOCALBASE?=	/usr/local
58X11BASE?=	/usr/X11R6
59PREFIX?=	$(LOCALBASE)
60
61DATADIR?=	$(LOCALBASE)/share/quake2
62LIBDIR?=	$(LOCALBASE)/lib/QuDos
63
64CC?=		gcc
65TYPE?=		release
66
67OGG_LDFLAGS=	-lvorbisfile -lvorbis -logg
68
69SDL_CONFIG?=	sdl-config
70SDL_CFLAGS=	$(shell $(SDL_CONFIG) --cflags)
71SDL_LDFLAGS=	$(shell $(SDL_CONFIG) --libs)
72
73ifeq ($(OSTYPE),Linux)
74ALSA_LDFLAGS=	-lasound
75endif
76
77ARTS_CFLAGS=	$(shell artsc-config --cflags)
78ARTS_LDFLAGS=	$(shell artsc-config --libs)
79
80SHLIB_EXT=	so
81SHLIB_CFLAGS=	-fPIC
82SHLIB_LDFLAGS=	-shared
83
84# QuDos variables.
85VERSION=	QuDos v0.40.1
86VERSION_BZ2=	v0.40.1
87SRC_DIR=	src
88MOD_DIR=	mods
89OBJ_DIR=	QuDos-build
90BIN_DIR=	quake2
91
92GAME_NAME=	game.$(SHLIB_EXT)
93
94ifeq ($(OSTYPE),Linux)
95  ifeq ($(ARCH),i386)
96GAME_NAME=	game$(ARCH).$(SHLIB_EXT)
97  endif
98endif
99
100# Compilation flags.
101CFLAGS+=	-I/usr/include -I$(LOCALBASE)/include -I$(X11BASE)/include \
102		-DGAME_NAME='"$(GAME_NAME)"' -DQUDOS_VERSION='"$(VERSION)"'
103
104WARNS=	-Wshadow -Wpointer-arith -Wcast-align -Waggregate-return -Wstrict-prototypes -Wredundant-decls -Wnested-externs
105
106ifeq ($(TYPE),debug)
107CFLAGS+=	-Wall -Werror -g -ggdb -DDEBUGGING # $(WARNS)
108else
109  ifeq ($(TYPE),profile)
110CFLAGS+=	-pg
111  else
112CFLAGS+=	-fcommon -ffast-math -funroll-loops -fomit-frame-pointer
113    ifeq ($(ARCH),i386)
114CFLAGS+=	-falign-functions=2 \
115		-fno-strict-aliasing
116    endif
117  endif
118endif
119
120# Linker flags.
121LDFLAGS+=	-L/usr/lib -L$(LOCALBASE)/lib -L$(X11BASE)/lib -lm
122
123ifeq ($(OSTYPE),Linux)
124LDFLAGS+=	-ldl
125endif
126
127REF_LDFLAGS=	-L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lGLU -ljpeg -lpng
128
129ifeq ($(strip $(WITH_DGA_MOUSE)),YES)
130REF_LDFLAGS+= -lXxf86dga
131endif
132
133# Sources and object code files list.
134QuDos_cl_SRCS=	client/cl_cin.c \
135		client/cl_ents.c \
136		client/cl_fx.c \
137		client/cl_input.c \
138		client/cl_inv.c \
139		client/cl_locs.c \
140		client/cl_main.c \
141		client/cl_newfx.c \
142		client/cl_parse.c \
143		client/cl_pred.c \
144		client/cl_scrn.c \
145		client/cl_tent.c \
146		client/cl_view.c \
147		client/console.c \
148		client/keys.c \
149		client/menu.c \
150		client/qmenu.c \
151		client/snd_dma.c \
152		client/snd_mem.c \
153		client/snd_mix.c \
154		client/snd_ogg.c \
155		client/snd_xmms.c \
156		\
157		game/m_flash.c \
158		\
159		unix/vid_menu.c \
160		unix/vid_so.c
161
162QuDos_com_SRCS=	game/q_shared.c \
163		\
164		qcommon/cmd.c \
165		qcommon/cmodel.c \
166		qcommon/common.c \
167		qcommon/crc.c \
168		qcommon/cvar.c \
169		qcommon/files.c \
170		qcommon/md4.c \
171		qcommon/net_chan.c \
172		qcommon/pmove.c \
173		qcommon/unzip/ioapi.c \
174		qcommon/unzip/unzip.c \
175		qcommon/wildcard.c \
176		\
177		server/sv_ccmds.c \
178		server/sv_ents.c \
179		server/sv_game.c \
180		server/sv_init.c \
181		server/sv_main.c \
182		server/sv_send.c \
183		server/sv_user.c \
184		server/sv_world.c \
185		\
186		unix/$(NET_API).c \
187		unix/qsh_unix.c \
188		unix/sys_unix.c
189
190QuDos_SRCS=	$(QuDos_com_SRCS) \
191		$(QuDos_cl_SRCS) \
192		unix/$(CD_API).c
193
194QuDos_BIN=	QuDos
195QuDos_OBJS=	$(QuDos_SRCS:%.c=%.o)
196QuDos_CFLAGS=	$(CFLAGS) -DQ2_BIN
197QuDos_LDFLAGS=	$(LDFLAGS) $(OGG_LDFLAGS) -lz
198
199QuDos_ded_SRCS=	$(QuDos_com_SRCS) \
200		null/cd_null.c \
201		null/cl_null.c
202
203QuDos_ded_BIN=	QuDos-ded
204QuDos_ded_OBJS=	$(QuDos_ded_SRCS:%.c=%.o)
205QuDos_ded_CFLAGS=	$(CFLAGS) -DDEDICATED_ONLY -DQ2DED_BIN
206QuDos_ded_LDFLAGS=	$(LDFLAGS) -lz
207
208ref_com_SRCS=	game/q_shared.c \
209		\
210		ref_gl/gl_blooms.c \
211		ref_gl/gl_decals.c \
212		ref_gl/gl_draw.c \
213		ref_gl/gl_flares.c \
214		ref_gl/gl_image.c \
215		ref_gl/gl_light.c \
216		ref_gl/gl_md3.c \
217		ref_gl/gl_mesh.c \
218		ref_gl/gl_model.c \
219		ref_gl/gl_refl.c \
220		ref_gl/gl_rmain.c \
221		ref_gl/gl_rmisc.c \
222		ref_gl/gl_rsurf.c \
223		ref_gl/gl_vlights.c \
224		ref_gl/gl_warp.c \
225		\
226		unix/qgl_unix.c \
227		unix/qsh_unix.c \
228		unix/rw_unix.c
229
230ref_glx_SRCS=	$(ref_com_SRCS) \
231		unix/gl_glx.c
232
233ref_glx_BIN=	ref_q2glx.$(SHLIB_EXT)
234ref_glx_OBJS=	$(ref_glx_SRCS:%.c=%.o)
235ref_glx_CFLAGS=	$(CFLAGS) $(SHLIB_CFLAGS) -DREF_GL
236ref_glx_LDFLAGS=	$(SHLIB_LDFLAGS) $(LDFLAGS) $(REF_LDFLAGS)
237
238ref_sdlgl_SRCS=	$(ref_com_SRCS) \
239		unix/gl_sdl.c
240
241ref_sdlgl_BIN=	ref_q2sdlgl.$(SHLIB_EXT)
242ref_sdlgl_OBJS=	$(ref_sdlgl_SRCS:%.c=%.o)
243ref_sdlgl_CFLAGS=	$(CFLAGS) $(SDL_CFLAGS) $(SHLIB_CFLAGS) -DREF_SDLGL
244ref_sdlgl_LDFLAGS=	$(SHLIB_LDFLAGS) $(LDFLAGS) $(SDL_LDFLAGS) \
245			$(REF_LDFLAGS)
246
247ifeq ($(OSTYPE),Linux)
248snd_alsa_SRCS=	unix/snd_alsa.c
249
250snd_alsa_BIN=	snd_alsa.$(SHLIB_EXT)
251snd_alsa_OBJS=	$(snd_alsa_SRCS:%.c=%.o)
252snd_alsa_CFLAGS=	$(CFLAGS) $(ALSA_CFLAGS) $(SHLIB_CFLAGS)
253snd_alsa_LDFLAGS=	$(SHLIB_LDFLAGS) $(LDFLAGS) $(ALSA_LDFLAGS)
254endif
255
256snd_arts_SRCS=	unix/snd_arts.c
257
258snd_arts_BIN=	snd_arts.$(SHLIB_EXT)
259snd_arts_OBJS=	$(snd_arts_SRCS:%.c=%.o)
260snd_arts_CFLAGS=	$(CFLAGS) $(ARTS_CFLAGS) $(SHLIB_CFLAGS)
261snd_arts_LDFLAGS=	$(SHLIB_LDFLAGS) $(LDFLAGS) $(ARTS_LDFLAGS)
262
263snd_oss_SRCS=	unix/snd_oss.c
264
265snd_oss_BIN=	snd_oss.$(SHLIB_EXT)
266snd_oss_OBJS=	$(snd_oss_SRCS:%.c=%.o)
267snd_oss_CFLAGS=		$(CFLAGS) $(SHLIB_CFLAGS)
268snd_oss_LDFLAGS=	$(SHLIB_LDFLAGS) $(LDFLAGS)
269
270snd_sdl_SRCS=	unix/snd_sdl.c
271
272snd_sdl_BIN=	snd_sdl.$(SHLIB_EXT)
273snd_sdl_OBJS=	$(snd_sdl_SRCS:%.c=%.o)
274snd_sdl_CFLAGS=		$(CFLAGS) $(SDL_CFLAGS) $(SHLIB_CFLAGS)
275snd_sdl_LDFLAGS=	$(SHLIB_LDFLAGS) $(LDFLAGS) $(SDL_LDFLAGS)
276
277# Targets to build.
278ifeq ($(strip $(BUILD_3ZB2)),YES)
279TARGETS_GAME+=	$(MOD_DIR)/3zb2
280endif
281
282ifeq ($(strip $(BUILD_CTF)),YES)
283TARGETS_GAME+=	$(MOD_DIR)/ctf
284endif
285
286ifeq ($(strip $(BUILD_DEDICATED)),YES)
287TARGETS+=	QuDos_ded
288endif
289
290ifeq ($(strip $(BUILD_GAME)),YES)
291TARGETS_GAME+=	game
292endif
293
294ifeq ($(strip $(BUILD_GLX)),YES)
295TARGETS+=	ref_glx
296endif
297
298ifeq ($(strip $(BUILD_JABOT)),YES)
299TARGETS_GAME+=	$(MOD_DIR)/jabot
300endif
301
302ifeq ($(strip $(BUILD_QUAKE2)),YES)
303TARGETS+=	QuDos
304endif
305
306ifeq ($(strip $(BUILD_ROGUE)),YES)
307TARGETS_GAME+=	$(MOD_DIR)/rogue
308endif
309
310ifeq ($(strip $(BUILD_SDLGL)),YES)
311TARGETS+=	ref_sdlgl
312endif
313
314ifeq ($(strip $(BUILD_XATRIX)),YES)
315TARGETS_GAME+=	$(MOD_DIR)/xatrix
316endif
317
318ifeq ($(strip $(BUILD_ZAERO)),YES)
319TARGETS_GAME+=	$(MOD_DIR)/zaero
320endif
321
322ifeq ($(OSTYPE),Linux)
323 ifeq ($(strip $(BUILD_ALSA_SND)),YES)
324  TARGETS+=	snd_alsa
325 endif
326endif
327
328ifeq ($(strip $(BUILD_ARTS_SND)),YES)
329TARGETS+=	snd_arts
330endif
331
332ifeq ($(strip $(BUILD_OSS_SND)),YES)
333TARGETS+=	snd_oss
334endif
335
336ifeq ($(strip $(BUILD_SDL_SND)),YES)
337TARGETS+=	snd_sdl
338endif
339
340# System dependent options.
341ifeq ($(OSTYPE),FreeBSD)
342CD_API=		cd_freebsd
343else
344  ifeq ($(OSTYPE),Linux)
345CD_API=		cd_linux
346  else
347CD_API=		cd_null
348  endif
349endif
350ifeq ($(OSTYPE),DragonFly)
351CD_API=		cd_freebsd
352endif
353
354# Option detection and handling.
355ifeq ($(OSTYPE),Linux)
356 ifeq ($(strip $(BUILD_ALSA_SND)),YES)
357 SOUND_API=	snd_alsa
358 endif
359endif
360
361ifeq ($(strip $(BUILD_ARTS_SND)),YES)
362SOUND_API=	snd_arts
363endif
364
365ifeq ($(strip $(BUILD_SDL_SND)),YES)
366SOUND_API=	snd_sdl
367endif
368
369ifeq ($(strip $(BUILD_OSS_SND)),YES)
370SOUND_API=	snd_oss
371endif
372
373ifeq ($(strip $(WITH_BOTS)),YES)
374CFLAGS+=	-DWITH_ACEBOT
375endif
376
377ifeq ($(strip $(WITH_DATADIR)),YES)
378CFLAGS+=	-DDATADIR='"$(DATADIR)"'
379endif
380
381ifeq ($(strip $(WITH_DGA_MOUSE)),YES)
382CFLAGS+=	-DUSE_XF86_DGA
383endif
384
385ifeq ($(strip $(WITH_GAME_MOD)),YES)
386CFLAGS+=	-DGAME_MOD
387endif
388
389ifeq ($(strip $(WITH_IPV6)),YES)
390CFLAGS+=	-DHAVE_IPV6
391NET_API=	net_udp6
392  ifeq ($(OSTYPE),FreeBSD)
393CFLAGS+=	-DHAVE_SIN6_LEN
394  endif
395else
396NET_API=	net_udp
397endif
398
399ifeq ($(strip $(WITH_JOYSTICK)),YES)
400CFLAGS+=	-DJoystick
401ref_com_SRCS+=	unix/joystick.c
402endif
403
404ifeq ($(strip $(WITH_LIBDIR)),YES)
405CFLAGS+=	-DLIBDIR='"$(LIBDIR)"'
406endif
407
408ifeq ($(strip $(WITH_QMAX)),YES)
409CFLAGS+=	-DQMAX
410endif
411
412ifeq ($(strip $(WITH_REDBLUE)),YES)
413CFLAGS+=	-DREDBLUE
414endif
415
416ifeq ($(strip $(WITH_RETEXTURE)),YES)
417CFLAGS+=	-DRETEX
418endif
419
420ifeq ($(ARCH),i386)
421  ifeq ($(strip $(WITH_X86_ASM)),YES)
422QuDos_OBJS+=	snd_mixa.o
423  else
424CFLAGS+=	-DC_ONLY
425  endif
426endif
427
428ifeq ($(strip $(WITH_XMMS)),YES)
429CFLAGS+=	-DWITH_XMMS `glib-config --cflags`
430endif
431
432# Targets for building.
433.PHONY: clean distclean distclean_full bin_clean obj_clean src_clean
434
435DEPEND_TARGETS=	$(patsubst %,$(OBJ_DIR)/%/.depend,$(TARGETS)) \
436		$(patsubst %,$(OBJ_DIR)/%/.depend,$(notdir $(TARGETS_GAME)))
437
438BUILD_TARGETS=	$(foreach target,$(TARGETS),$(patsubst %,$(BIN_DIR)/%,$($(target)_BIN))) \
439		$(foreach target,$(TARGETS_GAME),$(patsubst %,$(BIN_DIR)/%/$(GAME_NAME),$(notdir $(target))))
440
441all: build
442
443build: $(DEPEND_TARGETS) $(BUILD_TARGETS)
444
445install: build
446	@printf "Installing files to your home directory...\n"
447	@cp -rv $(BIN_DIR) ~
448	@cp -rv docs/gnu.txt docs/Ogg_readme.txt docs/QuDos.txt src/unix/QuDos.run ~/quake2
449ifeq ($(strip $(BUILD_DEDICATED)),YES)
450	@cp -rv src/unix/QuDos-dedicated.run ~/quake2
451endif
452	@printf "Done.\n"
453
454clean: obj_clean
455
456distclean: bin_clean obj_clean
457
458distclean_full: bin_clean obj_clean src_clean
459
460bin_clean:
461	@printf "Cleaning binaries... "
462	@rm -rf $(BIN_DIR)
463	@printf ".... Done.\n"
464
465obj_clean:
466	@printf "Cleaning object code files... "
467	@rm -rf $(OBJ_DIR)
468	@printf ".... Done.\n"
469
470src_clean:
471	@printf "Cleaning backup files generated by text editors... "
472	@find . -type f \( -name "*~" -or -name "*.orig" \) -delete
473	@rm -f tags
474	@printf ".... Done.\n"
475bz2:
476	@printf "Creating bzip2 compressed file ...\n"
477ifeq ($(strip $(WITH_QMAX)),YES)
478	@tar cjvf QuDosmaX-$(VERSION_BZ2).tar.bz2 quake2 docs/gnu.txt docs/Ogg_readme.txt docs/QuDos.txt
479else
480	@tar cjvf QuDos-$(VERSION_BZ2).tar.bz2 quake2 docs/gnu.txt docs/Ogg_readme.txt docs/QuDos.txt
481endif
482	@printf ".... Done.\n"
483
484# Auto-generate rules.
485$(OBJ_DIR)/QuDos/.depend: $(patsubst %,$(SRC_DIR)/%,$(QuDos_SRCS))
486	@mkdir -p $(OBJ_DIR)/QuDos $(BIN_DIR)
487	$(CC) -MM $(QuDos_CFLAGS) $^ | sed -e 's|^\(..*\.o\)|$(OBJ_DIR)/QuDos/\1|' | awk -f rules.awk -v rule='\t$$(CC) -c $$(QuDos_CFLAGS) -o $$@ $$<' > $@
488
489$(OBJ_DIR)/QuDos_ded/.depend: $(patsubst %,$(SRC_DIR)/%,$(QuDos_ded_SRCS))
490	@mkdir -p $(OBJ_DIR)/QuDos_ded $(BIN_DIR)
491	$(CC) -MM $(QuDos_ded_CFLAGS) $^ | sed -e 's|^\(..*\.o\)|$(OBJ_DIR)/QuDos_ded/\1|' | awk -f rules.awk -v rule='\t$$(CC) -c $$(QuDos_ded_CFLAGS) -o $$@ $$<' > $@
492
493$(OBJ_DIR)/ref_glx/.depend: $(patsubst %,$(SRC_DIR)/%,$(ref_glx_SRCS))
494	@mkdir -p $(OBJ_DIR)/ref_glx $(BIN_DIR)
495	$(CC) -MM $(ref_glx_CFLAGS) $^ | sed -e 's|^\(..*\.o\)|$(OBJ_DIR)/ref_glx/\1|' | awk -f rules.awk -v rule='\t$$(CC) -c $$(ref_glx_CFLAGS) -o $$@ $$<' > $@
496
497$(OBJ_DIR)/ref_sdlgl/.depend: $(patsubst %,$(SRC_DIR)/%,$(ref_sdlgl_SRCS))
498	@mkdir -p $(OBJ_DIR)/ref_sdlgl $(BIN_DIR)
499	$(CC) -MM $(ref_sdlgl_CFLAGS) $^ | sed -e 's|^\(..*\.o\)|$(OBJ_DIR)/ref_sdlgl/\1|' | awk -f rules.awk -v rule='\t$$(CC) -c $$(ref_sdlgl_CFLAGS) -o $$@ $$<' > $@
500
501ifeq ($(OSTYPE),Linux)
502$(OBJ_DIR)/snd_alsa/.depend: $(patsubst %,$(SRC_DIR)/%,$(snd_alsa_SRCS))
503	@mkdir -p $(OBJ_DIR)/snd_alsa $(BIN_DIR)
504	$(CC) -MM $(snd_alsa_CFLAGS) $^ | sed -e 's|^\(..*\.o\)|$(OBJ_DIR)/snd_alsa/\1|' | awk -f rules.awk -v rule='\t$$(CC) -c $$(snd_alsa_CFLAGS) -o $$@ $$<' > $@
505endif
506
507$(OBJ_DIR)/snd_arts/.depend: $(patsubst %,$(SRC_DIR)/%,$(snd_arts_SRCS))
508	@mkdir -p $(OBJ_DIR)/snd_arts $(BIN_DIR)
509	$(CC) -MM $(snd_arts_CFLAGS) $^ | sed -e 's|^\(..*\.o\)|$(OBJ_DIR)/snd_arts/\1|' | awk -f rules.awk -v rule='\t$$(CC) -c $$(snd_arts_CFLAGS) -o $$@ $$<' > $@
510
511$(OBJ_DIR)/snd_oss/.depend: $(patsubst %,$(SRC_DIR)/%,$(snd_oss_SRCS))
512	@mkdir -p $(OBJ_DIR)/snd_oss $(BIN_DIR)
513	$(CC) -MM $(snd_oss_CFLAGS) $^ | sed -e 's|^\(..*\.o\)|$(OBJ_DIR)/snd_oss/\1|' | awk -f rules.awk -v rule='\t$$(CC) -c $$(snd_oss_CFLAGS) -o $$@ $$<' > $@
514
515$(OBJ_DIR)/snd_sdl/.depend: $(patsubst %,$(SRC_DIR)/%,$(snd_sdl_SRCS))
516	@mkdir -p $(OBJ_DIR)/snd_sdl $(BIN_DIR)
517	$(CC) -MM $(snd_sdl_CFLAGS) $^ | sed -e 's|^\(..*\.o\)|$(OBJ_DIR)/snd_sdl/\1|' | awk -f rules.awk -v rule='\t$$(CC) -c $$(snd_sdl_CFLAGS) -o $$@ $$<' > $@
518
519# Object lists relative to $(OBJ_DIR) and without path.
520QuDos_OL=	$(patsubst %,$(OBJ_DIR)/QuDos/%,$(notdir $(QuDos_OBJS)))
521QuDos_ded_OL=	$(patsubst %,$(OBJ_DIR)/QuDos_ded/%,$(notdir $(QuDos_ded_OBJS)))
522ref_glx_OL=	$(patsubst %,$(OBJ_DIR)/ref_glx/%,$(notdir $(ref_glx_OBJS)))
523ref_sdlgl_OL=	$(patsubst %,$(OBJ_DIR)/ref_sdlgl/%,$(notdir $(ref_sdlgl_OBJS)))
524ifeq ($(OSTYPE),Linux)
525snd_alsa_OL=	$(patsubst %,$(OBJ_DIR)/snd_alsa/%,$(notdir $(snd_alsa_OBJS)))
526endif
527snd_arts_OL=	$(patsubst %,$(OBJ_DIR)/snd_arts/%,$(notdir $(snd_arts_OBJS)))
528snd_oss_OL=	$(patsubst %,$(OBJ_DIR)/snd_oss/%,$(notdir $(snd_oss_OBJS)))
529snd_sdl_OL=	$(patsubst %,$(OBJ_DIR)/snd_sdl/%,$(notdir $(snd_sdl_OBJS)))
530
531# Assembly rules.
532$(OBJ_DIR)/QuDos/snd_mixa.o: $(SRC_DIR)/unix/snd_mixa.s
533	$(CC) -c $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
534
535# Linking rules.
536$(BIN_DIR)/$(QuDos_BIN): $(QuDos_OL)
537	$(CC) -o $@ $^ $(QuDos_LDFLAGS)
538
539$(BIN_DIR)/$(QuDos_ded_BIN): $(QuDos_ded_OL)
540	$(CC) -o $@ $^ $(QuDos_ded_LDFLAGS)
541
542$(BIN_DIR)/$(ref_glx_BIN): $(ref_glx_OL)
543	$(CC) -o $@ $^ $(ref_glx_LDFLAGS)
544
545$(BIN_DIR)/$(ref_sdlgl_BIN): $(ref_sdlgl_OL)
546	$(CC) -o $@ $^ $(ref_sdlgl_LDFLAGS)
547
548ifeq ($(OSTYPE),Linux)
549$(BIN_DIR)/$(snd_alsa_BIN): $(snd_alsa_OL)
550	$(CC) -o $@ $^ $(snd_alsa_LDFLAGS)
551endif
552
553$(BIN_DIR)/$(snd_arts_BIN): $(snd_arts_OL)
554	$(CC) -o $@ $^ $(snd_arts_LDFLAGS)
555
556$(BIN_DIR)/$(snd_oss_BIN): $(snd_oss_OL)
557	$(CC) -o $@ $^ $(snd_oss_LDFLAGS)
558
559$(BIN_DIR)/$(snd_sdl_BIN): $(snd_sdl_OL)
560	$(CC) -o $@ $^ $(snd_sdl_LDFLAGS)
561
562# Include make modules (for mods).
563-include $(patsubst %,$(SRC_DIR)/%/module.mk,$(TARGETS_GAME))
564
565# Include dependencies.
566-include $(DEPEND_TARGETS)
567