# Generated automatically from Makefile.in by configure.
########################################################################
#
# Quake general stuff
#

PROJECT_DIR  = ..
SRC_DIR      = .
QW_COMMON_DIR= $(PROJECT_DIR)/qw_common
COMMON_DIR   = $(PROJECT_DIR)/common
BIN_PREFIX   = qw-client

DESTDIR      =

prefix      = /usr/local
bindir      = ${exec_prefix}/games
mandir      = ${prefix}/man

BUILD_DIR    = ../targets/qw_client

LDFLAGS =   -lm
LIBS = -lm 
CC = gcc
INTEL_ARCH = no

ifneq ($(SRC_DIR),.)
SRC_DIR_INC = -I$(SRC_DIR)
endif

HAS_GGI    = no
HAS_SVGA   = no
HAS_GLIDE  = no
HAS_TDFXGL = no
HAS_OGL    = no
HAS_XIL    = no
HAS_X11    = yes
HAS_SDL    = no

MAKE_SURE_DIR = if test -d "$(BUILD_DIR)/$$DIR"; \
                then \
                   true; \
                else \
		   echo "Creating directory $(BUILD_DIR)/$$DIR"; \
		   mkdir -p $(BUILD_DIR)/$$DIR; \
                fi


########################################################################
#
# Client targets
#

ifeq ($(HAS_OGL),yes)
GLQUAKE   =$(BIN_PREFIX)-gl
endif

ifeq ($(HAS_TDFXGL),yes)
TDFXQUAKE= $(BIN_PREFIX)-3dfx
endif

ifeq ($(HAS_X11),yes)
X11QUAKE  = $(BIN_PREFIX)-x11
endif

ifeq ($(HAS_SVGA),yes)
SVGAQUAKE = $(BIN_PREFIX)-svga
endif

ifeq ($(HAS_GGI),yes)
GGIQUAKE = $(BIN_PREFIX)-ggi
endif

ifeq ($(HAS_SDL),yes)
SDLQUAKE = $(BIN_PREFIX)-sdl
endif

RELEASE = 
ifeq ($(RELEASE),yes)
OPTFLAGS = 
else
OPTFLAGS = -g
endif

targets       = $(GGIQUAKE) $(SVGAQUAKE) $(GLQUAKE) $(TDFXQUAKE) $(X11QUAKE) $(SDLQUAKE)
CLEAN_TARGETS = $(patsubst %,clean-%, $(targets))
.PHONY: $(targets) ($CLEAN_TARGETS)

x: Makefile
	@echo binaries: $(targets)
	@echo other targets: distclean 
	@echo all: makes all targets - $(targets)

all: $(targets)


########################################################################
#
# Source files
#

# **** Note - two apps may appear to share source, but they may just share
# source file *names*

ifeq ($(INTEL_ARCH),yes)
# Source file the Intel archictecture only
UQ_GENERAL_SRC         = worlda.s
UQ_SWREND_SRC_PLAT     = dosasm.s
CL_ADDITIONAL_GENERAL_SRC = sys_dosa.s math.s
SWREND_SRC_PLAT = d_copy.s d_draw.s d_draw16.s d_parta.s d_polysa.s d_scana.s \
	d_spr8.s d_varsa.s r_aclipa.s r_aliasa.s \
	r_drawa.s r_edgea.s r_varsa.s surf16.s surf8.s
CFLAGS += -Did386=1
else
# Source files for non-Intel platforms
SWREND_SRC_PLAT = nonintel.c
CFLAGS += -Did386=0
endif

#
# System specific source files
#
CD_AUDIO_SRC   = cd_wrapper.c

# sound
 
SND_STYLE      = OSS
SND_SRC = snd_null.c

ifeq ($(SND_STYLE),ALSA)
SND_SRC = snd_alsa.c alsa.c
endif
ifeq ($(SND_STYLE),OSS)
SND_SRC = snd_dma.c snd_oss.c
endif
ifeq ($(SND_STYLE),Solaris)
SND_SRC = snd_dma.c snd_sun.c
endif
ifeq ($(SND_STYLE),MME)
SND_SRC = snd_dma.c snd_mme.c
endif
ifeq ($(SND_STYLE),Windows)
SND_SRC = snd_dma.c snd_win.c
endif

SND_SRC        += snd_mem.c snd_mix.c snd_mixa.s

X11_VID_SRC    = vid_x.c
QW_X11_VID_SRC = vid_x.c

SYS_SRC        = sys_unix.c
QW_CL_SYS_SRC  = sys_linux.c
QW_SRV_SYS_SRC = sys_unix.c

#
# Networking source files
#
# XXX - Should not assume UNIX
NET_SRC        = net_bsd.c net_udp.c
QW_NET_SRC     = net_udp.c net_com.c mdfour.c
UQ_NET_SRC     = net_dgrm.c net_loop.c net_main.c net_vcr.c $(NET_SRC)

#
# Common source files
#
MISC_SRC       = common.c crc.c cvar.c cmd.c mathlib.c register_check.c wad.c zone.c

#
# Rendering source files
#

# OpenGL
GL_REND_SRC = gl_screen.c gl_model.c gl_draw.c gl_mesh.c gl_refrag.c \
              gl_rlight.c gl_rmain.c gl_rmisc.c gl_rsurf.c gl_warp.c nonintel.c
#              gl_rlight.c gl_rmain.c gl_rmisc.c gl_rsurf.c gl_test.c gl_warp.c
QW_GL_REND_SRC = gl_ngraph.c

# Software source
SW_REND_SRC = screen.c $(SWREND_SRC_PLAT) draw.c \
	d_edge.c d_fill.c d_init.c d_modech.c d_part.c d_polyse.c d_scan.c \
	d_sky.c d_sprite.c d_surf.c d_vars.c d_zpoint.c r_aclip.c r_alias.c \
	r_bsp.c r_draw.c r_edge.c r_efrag.c r_light.c r_main.c r_misc.c \
	r_sky.c r_sprite.c r_surf.c r_vars.c

#
# Client source files
#
CL_SRC    = cl_demo.c cl_input.c cl_main.c cl_parse.c cl_tent.c 
QW_CL_SRC = cl_cam.c cl_ents.c cl_pred.c 
CL_GUI_SRC= console.c sbar.c view.c keys.c menu.c

#
# Server source files
#
# Server-related source used by all
SRV_SRC     = sv_main.c sv_user.c sv_move.c sv_phys.c 
# Server-related source used just by QW server
QW_SRV_SRC  = sv_ccmds.c sv_ents.c sv_init.c sv_send.c sv_nchan.c world.c
# Server-related source used just by UQ
UQ_SRV_SRC  = host.c host_cmd.c $(SRV_SRC)
SRV_PR_SRC  = pr_cmds.c pr_edict.c pr_exec.c


QW_GENERAL_SRC = pmove.c pmovetst.c

# Source common to both UQ and QW-client
CL_COMMON_SRC = $(MISC_SRC) $(CL_GUI_SRC) $(CL_SRC) \
	$(CL_ADDITIONAL_GENERAL_SRC) $(SND_SRC) $(CD_AUDIO_SRC) r_part.c

########################################################################
#
# Directory specific stuff
#
DEFS = -DHAVE_CONFIG_H
CFLAGS += -g -O2 -Wall -DQUAKEWORLD $(OPTFLAGS) $(DEFS) -I. \
$(SRC_DIR_INC) -I$(QW_COMMON_DIR) -I$(COMMON_DIR)
ALL_X11_SRC  = $(GENERAL_SRC) $(SW_REND_SRC) $(QW_X11_VID_SRC) model.c
ALL_GL_SRC   = $(GENERAL_SRC) $(GL_REND_SRC) $(GL_VID_SRC) $(QW_GL_REND_SRC) 
ALL_TDFX_SRC = $(GENERAL_SRC) $(GL_REND_SRC) $(TDFX_VID_SRC) $(QW_GL_REND_SRC) 

GENERAL_SRC = $(CL_COMMON_SRC) \
	   $(QW_CL_SRC) $(QW_NET_SRC) net_chan.c skin.c \
	   $(QW_CL_SYS_SRC) \
	   $(QW_GENERAL_SRC)
# XXX - add dos/win specifc source

###########################################################################
#
# Compilation rules
#

###########################################################################
#
# qw-client-x11
#
ifneq ($(X11QUAKE),)

# Map the list of source files into a list of object files
OBJSquake-x11 = $(patsubst %,$(BUILD_DIR)/x11/%,$(addsuffix .o, $(basename $(ALL_X11_SRC) .c .s)))

X11_CFLAGS  = -DX11  -I/usr/X11R6/include
X11_LDFLAGS =  -L/usr/X11R6/lib -lX11 -lXext 

# This can be thought of as a macro that makes sure that the x11
# sub-directory is created
# XXX - can we avoid doing every compile?
MAKE_SURE_x11_DIR = @DIR=x11; $(MAKE_SURE_DIR)

$(BUILD_DIR)/x11/%.o: $(SRC_DIR)/%.c
	$(MAKE_SURE_x11_DIR)
	$(CC) $(CFLAGS) $(X11_CFLAGS) -o $@ -c $<

$(BUILD_DIR)/x11/%.o: $(SRC_DIR)/%.s
	$(MAKE_SURE_x11_DIR)
	$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<

$(BUILD_DIR)/x11/%.o: $(COMMON_DIR)/%.c
	$(MAKE_SURE_x11_DIR)
	$(CC) $(CFLAGS) $(X11_CFLAGS) -o $@ -c $<

ifneq ($(QW_COMMON_DIR),)
$(BUILD_DIR)/x11/%.o: $(QW_COMMON_DIR)/%.c
	$(MAKE_SURE_x11_DIR)
	$(CC) $(CFLAGS) $(X11_CFLAGS) -o $@ -c $<
endif

$(BUILD_DIR)/x11/%.o: $(COMMON_DIR)/%.s
	$(MAKE_SURE_x11_DIR)
	$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<

$(X11QUAKE): $(BUILD_DIR)/../$(X11QUAKE)

$(BUILD_DIR)/../$(X11QUAKE): $(OBJSquake-x11)
	$(CC) $(CFLAGS) $(OBJSquake-x11) $(X11_LDFLAGS) $(LDFLAGS) -o $(BUILD_DIR)/../$(X11QUAKE)
# XXX - Can this be automated?
clean-$(X11QUAKE):
	rm -f $(OBJSquake-x11)
endif

###########################################################################
#
# qw-client-svga
#
ifneq ($(SVGAQUAKE),)
ALL_SVGA_SRC = $(GENERAL_SRC) $(SW_REND_SRC) $(SVGA_VID_SRC) model.c
OBJSquake-svga= $(patsubst %,$(BUILD_DIR)/svga/%,$(addsuffix .o, $(basename $(ALL_SVGA_SRC) .c .s)))

SVGA_CFLAGS  = 
SVGA_LDFLAGS = 
SVGA_VID_SRC = vid_svgalib.c

# This can be thought of as a macro that makes sure that the x11
# sub-directory is created
# XXX - can we avoid doing every compile?
MAKE_SURE_svga_DIR = @DIR=svga; $(MAKE_SURE_DIR)

# Not sure why this -O is needed, but it is...
$(BUILD_DIR)/svga/vid_svgalib.o: $(COMMON_DIR)/vid_svgalib.c
	$(MAKE_SURE_svga_DIR)
	$(CC) -O $(CFLAGS) $(SVGA_CFLAGS) -o $@ -c $<

$(BUILD_DIR)/svga/%.o: $(SRC_DIR)/%.c
	$(MAKE_SURE_svga_DIR)
	$(CC) $(CFLAGS) $(SVGA_CFLAGS) -o $@ -c $<

$(BUILD_DIR)/svga/%.o: $(SRC_DIR)/%.s
	$(MAKE_SURE_svga_DIR)
	$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<

$(BUILD_DIR)/svga/%.o: $(COMMON_DIR)/%.c
	$(MAKE_SURE_svga_DIR)
	$(CC) $(CFLAGS) $(SVGA_CFLAGS) -o $@ -c $<

ifneq ($(QW_COMMON_DIR),)
$(BUILD_DIR)/svga/%.o: $(QW_COMMON_DIR)/%.c
	$(MAKE_SURE_svga_DIR)
	$(CC) $(CFLAGS) $(SVGA_CFLAGS) -o $@ -c $<
endif

$(BUILD_DIR)/svga/%.o: $(COMMON_DIR)/%.s
	$(MAKE_SURE_svga_DIR)
	$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<

$(SVGAQUAKE): $(BUILD_DIR)/../$(SVGAQUAKE)

$(BUILD_DIR)/../$(SVGAQUAKE): $(OBJSquake-svga)
	$(CC) $(CFLAGS) $(OBJSquake-svga) $(SVGA_LDFLAGS) $(LDFLAGS) -o $(BUILD_DIR)/../$(SVGAQUAKE)
# XXX - Can this be automated?
clean-$(SVGAQUAKE):
	rm -f $(OBJSquake-svga)
endif

###########################################################################
#
# qw-client-ggi
#
ifneq ($(GGIQUAKE),)

# Map the list of source files into a list of object files
ALL_GGI_SRC = $(GENERAL_SRC) $(SW_REND_SRC) $(GGI_VID_SRC) model.c
OBJSquake-ggi = $(patsubst %,$(BUILD_DIR)/ggi/%,$(addsuffix .o, $(basename $(ALL_GGI_SRC) .c .s)))

GGI_CFLAGS  = -DGGI 
GGI_LDFLAGS = 
GGI_VID_SRC = vid_ggi.c

# This can be thought of as a macro that makes sure that the ggi
# sub-directory is created
# XXX - can we avoid doing every compile?
MAKE_SURE_ggi_DIR = @DIR=ggi; $(MAKE_SURE_DIR)

$(BUILD_DIR)/ggi/%.o: $(SRC_DIR)/%.c
	$(MAKE_SURE_ggi_DIR)
	$(CC) $(CFLAGS) $(GGI_CFLAGS) -o $@ -c $<

$(BUILD_DIR)/ggi/%.o: $(SRC_DIR)/%.s
	$(MAKE_SURE_ggi_DIR)
	$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<

$(BUILD_DIR)/ggi/%.o: $(COMMON_DIR)/%.c
	$(MAKE_SURE_ggi_DIR)
	$(CC) $(CFLAGS) $(GGI_CFLAGS) -o $@ -c $<

ifneq ($(QW_COMMON_DIR),)
$(BUILD_DIR)/ggi/%.o: $(QW_COMMON_DIR)/%.c
	$(MAKE_SURE_ggi_DIR)
	$(CC) $(CFLAGS) $(GGI_CFLAGS) -o $@ -c $<
endif

$(BUILD_DIR)/ggi/%.o: $(COMMON_DIR)/%.s
	$(MAKE_SURE_ggi_DIR)
	$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<

$(GGIQUAKE): $(BUILD_DIR)/../$(GGIQUAKE)

$(BUILD_DIR)/../$(GGIQUAKE): $(OBJSquake-ggi)
	$(CC) $(CFLAGS) $(OBJSquake-ggi) $(GGI_LDFLAGS) $(LDFLAGS) -o $(BUILD_DIR)/../$(GGIQUAKE)
# XXX - Can this be automated?
clean-$(GGIQUAKE):
	rm -f $(OBJSquake-ggi)
endif


###########################################################################
#
# qw-client-gl
#
ifneq ($(GLQUAKE),)
OBJSquake-gl = $(patsubst %,$(BUILD_DIR)/gl/%,$(addsuffix .o, $(basename $(ALL_GL_SRC) .c .s)))

GL_CFLAGS  = -DGLQUAKE 
GL_LDFLAGS = $(X11_LDFLAGS) 
# XXX - is this platform independent?
GL_VID_SRC = gl_vidlinuxglx.c

# This can be thought of as a macro that makes sure that the x11
# sub-directory is created
# XXX - can we avoid doing every compile?
MAKE_SURE_gl_DIR = @DIR=gl; $(MAKE_SURE_DIR)

$(BUILD_DIR)/gl/%.o: $(SRC_DIR)/%.c
	$(MAKE_SURE_gl_DIR)
	$(CC) $(CFLAGS) $(GL_CFLAGS) -o $@ -c $<

$(BUILD_DIR)/gl/%.o: $(SRC_DIR)/%.s
	$(MAKE_SURE_gl_DIR)
	$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<

$(BUILD_DIR)/gl/%.o: $(COMMON_DIR)/%.c
	$(MAKE_SURE_gl_DIR)
	$(CC) $(CFLAGS) $(GL_CFLAGS) -o $@ -c $<

ifneq ($(QW_COMMON_DIR),)
$(BUILD_DIR)/gl/%.o: $(QW_COMMON_DIR)/%.c
	$(MAKE_SURE_gl_DIR)
	$(CC) $(CFLAGS) $(GL_CFLAGS) -o $@ -c $<
endif

$(BUILD_DIR)/gl/%.o: $(COMMON_DIR)/%.s
	$(MAKE_SURE_gl_DIR)
	$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<

$(GLQUAKE): $(BUILD_DIR)/../$(GLQUAKE)

$(BUILD_DIR)/../$(GLQUAKE): $(OBJSquake-gl)
	$(CC) $(CFLAGS) $(OBJSquake-gl) $(GL_LDFLAGS) $(LDFLAGS) -o $(BUILD_DIR)/../$(GLQUAKE)

# XXX - Can this be automated?
clean-$(GLQUAKE):
	rm -f $(OBJSquake-gl)
endif

###########################################################################
#
# qw-client-3dfx
#
ifneq ($(TDFXQUAKE),)
OBJSquake-3dfx = $(patsubst %,$(BUILD_DIR)/3dfx/%,$(addsuffix .o, $(basename $(ALL_TDFX_SRC) .c .s)))

TDFX_CFLAGS  = -DGLQUAKE  
TDFX_LDFLAGS =  
TDFX_VID_SRC = gl_vidlinux_3dfx.c

# This can be thought of as a macro that makes sure that the x11
# sub-directory is created
# XXX - can we avoid doing every compile?
MAKE_SURE_3dfx_DIR = @DIR=3dfx; $(MAKE_SURE_DIR)

$(BUILD_DIR)/3dfx/%.o: $(SRC_DIR)/%.c
	$(MAKE_SURE_3dfx_DIR)
	$(CC) $(CFLAGS) $(TDFX_CFLAGS) -o $@ -c $<

$(BUILD_DIR)/3dfx/%.o: $(SRC_DIR)/%.s
	$(MAKE_SURE_3dfx_DIR)
	$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<

$(BUILD_DIR)/3dfx/%.o: $(COMMON_DIR)/%.c
	$(MAKE_SURE_3dfx_DIR)
	$(CC) $(CFLAGS) $(TDFX_CFLAGS) -o $@ -c $<

ifneq ($(QW_COMMON_DIR),)
$(BUILD_DIR)/3dfx/%.o: $(QW_COMMON_DIR)/%.c
	$(MAKE_SURE_3dfx_DIR)
	$(CC) $(CFLAGS) $(TDFX_CFLAGS) -o $@ -c $<
endif

$(BUILD_DIR)/3dfx/%.o: $(COMMON_DIR)/%.s
	$(MAKE_SURE_gl_DIR)
	$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<

$(TDFXQUAKE): $(BUILD_DIR)/../$(TDFXQUAKE)

$(BUILD_DIR)/../$(TDFXQUAKE): $(OBJSquake-3dfx)
	$(CC) $(CFLAGS) $(OBJSquake-3dfx) $(TDFX_LDFLAGS) $(LDFLAGS) -o $(BUILD_DIR)/../$(TDFXQUAKE)

# XXX - Can this be automated?
clean-$(TDFXQUAKE):
	rm -f $(OBJSquake-3dfx)
endif


###########################################################################
#
# qw-client-sdl
#
ifneq ($(SDLQUAKE),)
ALL_SDL_SRC = $(GENERAL_SRC) $(SW_REND_SRC) $(SDL_VID_SRC) model.c
OBJSquake-sdl= $(patsubst %,$(BUILD_DIR)/sdl/%,$(addsuffix .o, $(basename $(ALL_SDL_SRC) .c .s)))

SDL_CFLAGS  = 
SDL_LDFLAGS = 
SDL_VID_SRC = vid_sdl.c

# This can be thought of as a macro that makes sure that the x11
# sub-directory is created
# XXX - can we avoid doing every compile?
MAKE_SURE_sdl_DIR = @DIR=sdl; $(MAKE_SURE_DIR)

$(BUILD_DIR)/sdl/%.o: $(SRC_DIR)/%.c
	$(MAKE_SURE_sdl_DIR)
	$(CC) $(CFLAGS) $(SDL_CFLAGS) -o $@ -c $<

$(BUILD_DIR)/sdl/%.o: $(SRC_DIR)/%.s
	$(MAKE_SURE_sdl_DIR)
	$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<

$(BUILD_DIR)/sdl/%.o: $(COMMON_DIR)/%.c
	$(MAKE_SURE_sdl_DIR)
	$(CC) $(CFLAGS) $(SDL_CFLAGS) -o $@ -c $<

ifneq ($(QW_COMMON_DIR),)
$(BUILD_DIR)/sdl/%.o: $(QW_COMMON_DIR)/%.c
	$(MAKE_SURE_sdl_DIR)
	$(CC) $(CFLAGS) $(SDL_CFLAGS) -o $@ -c $<
endif

$(BUILD_DIR)/sdl/%.o: $(COMMON_DIR)/%.s
	$(MAKE_SURE_sdl_DIR)
	$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<

$(SDLQUAKE): $(BUILD_DIR)/../$(SDLQUAKE)

$(BUILD_DIR)/../$(SDLQUAKE): $(OBJSquake-sdl)
	$(CC) $(CFLAGS) $(OBJSquake-sdl) $(SDL_LDFLAGS) $(LDFLAGS) -o $(BUILD_DIR)/../$(SDLQUAKE)
# XXX - Can this be automated?
clean-$(SDLQUAKE):
	rm -f $(OBJSquake-sdl)
endif

###########################################################################
#
# cleaning (clean, distclean)
#
distclean: clean
	rm -f config.cache config.log config.status Makefile

clean: $(CLEAN_TARGETS)
	for i in $(targets); do \
	  rm -f $(BUILD_DIR)/../$$i; \
	done

install: $(targets)
	$(PROJECT_DIR)/mkinstalldirs $(DESTDIR)$(prefix)$(bindir)
	for i in $(targets); do \
	   $(PROJECT_DIR)/install-sh -m 755 $(BUILD_DIR)/../$$i \
	     $(DESTDIR)$(prefix)$(bindir)/$$i; \
	done

check:
	@echo check not implemented
