Remove ctf/ from Makefile and simplify it.

This commit is contained in:
Yamagi Burmeister 2011-10-09 16:55:23 +00:00
parent 96887896a7
commit 24b5f7fe97
3 changed files with 189 additions and 250 deletions

435
Makefile
View file

@ -5,9 +5,7 @@
# - SDL Client (quake2) #
# - Server (q2ded) #
# - SDL OpenGL-Refresher (ref_gl.so) #
# - games: #
# - Quake II (baseq2) #
# - Quake II - Threewave Capture The Flag (ctf) #
# - Quake II Game (baseq2) #
# #
# Dependencies: #
# - SDL 1.2 #
@ -20,8 +18,6 @@
# Platforms: #
# - Linux #
# - FreeBSD #
# - Maybe any other UNIX compliant system #
# supported by SDL 1.2 #
# ------------------------------------------------------ #
# Check the OS type
@ -31,6 +27,7 @@ OSTYPE := $(shell uname -s)
ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/amd64/x86_64/)
# Refuse all other plattforms as a firewall against PEBKAC
# (You'll need some #ifdef for your unsupported plattform!)
ifneq ($(ARCH),i386)
ifneq ($(ARCH),x86_64)
$(error arch $(ARCH) is currently not supported)
@ -44,10 +41,35 @@ CC := gcc
# ----------
# Base CFLAGS. These are extended later
# for each independet target
CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer\
-fstack-protector-all -Wall -pipe -g -MMD
# Base CFLAGS.
#
# -O2 are enough optimizations.
#
# -fno-strict-aliasing since the source doesn't comply
# with strict aliasing rules and it's next to impossible
# to get it there...
#
# -fomit-frame-pointer since the framepointer is mostly
# useless for debugging Quake II and slows things down.
#
# -g to build allways with debug symbols. Please do not
# change this, since it's our only chance to debug this
# crap when random crashes happen!
#
# -MMD to generate header dependencies.
CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer \
-Wall -pipe -g -MMD
# ----------
# Extra CFLAGS for SDL
SDLCFLAGS := $(shell sdl-config --cflags)
# ----------
# Extra CFLAGS for X11
X11CFLAGS := $(shell pkg-config x11 --cflags)
X11CFLAGS += $(shell pkg-config xxf86vm --cflags)
# ----------
@ -60,8 +82,7 @@ endif
# ----------
# Base LDFLAGS. These are extended later
# for each independet target
# Base LDFLAGS.
ifeq ($(OSTYPE),Linux)
LDFLAGS := -L/usr/lib -lm -ldl
else ifeq ($(OSTYPE),FreeBSD)
@ -70,8 +91,21 @@ endif
# ----------
# Extra LDFLAGS for SDL
SDLLDFLAGS := $(shell sdl-config --libs)
# ----------
# Extra LDFLAGS for X11
X11LDFLAGS := $(shell pkg-config x11 --libs)
X11LDFLAGS += $(shell pkg-config xxf86vm --libs)
# ----------
# Builds everything
all: client server refresher baseq2 ctf
all: client server refresher game
# ----------
# Cleanup
clean:
@ -89,12 +123,10 @@ client:
build/client/%.o: %.c
@echo '===> CC $<'
@mkdir -p $(@D)
@$(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $<
@$(CC) -c $(CFLAGS) $(X11CFLAGS) $(SDLCFLAGS) $(INCLUDE) -o $@ $<
release/quake2 : LDFLAGS += -lvorbis -lvorbisfile -logg -lz
release/quake2 : INCLUDE += -I/usr/include/SDL -I/usr/local/include/SDL
release/quake2 : LDFLAGS += -lvorbis -lvorbisfile -logg -lz \
-lXxf86vm -lX11 \
$(shell sdl-config --libs)
# ----------
# The server
@ -122,18 +154,16 @@ refresher:
build/refresher/%.o: %.c
@echo '===> CC $<'
@mkdir -p $(@D)
@$(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $<
@$(CC) -c $(CFLAGS) $(SDLCFLAGS) $(INCLUDE) -o $@ $<
release/ref_gl.so : INCLUDE += -I/usr/local/include/SDL \
-I/usr/include/SDL -I/usr/X11R6/include
release/ref_gl.so : CFLAGS += -fPIC
release/ref_gl.so : LDFLAGS += -shared
# ----------
# The baseq2 game
baseq2:
@echo '===> Building baseq2'
game:
@echo '===> Building baseq2/game.so'
@mkdir -p release/baseq2
$(MAKE) release/baseq2/game.so
@ -147,70 +177,58 @@ release/baseq2/game.so : LDFLAGS += -shared
# ----------
# The ctf game
ctf:
@echo '===> Building ctf'
@mkdir -p release/ctf
$(MAKE) release/ctf/game.so
build/ctf/%.o: %.c
@echo '===> CC $<'
@mkdir -p $(@D)
@$(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $<
release/ctf/game.so : CFLAGS += -fPIC
release/ctf/game.so : LDFLAGS += -shared
# Used by the game
GAME_OBJS_ = \
src/common/shared/flash.o \
src/common/shared/shared.o \
src/game/g_ai.o \
src/game/g_chase.o \
src/game/g_cmds.o \
src/game/g_combat.o \
src/game/g_func.o \
src/game/g_items.o \
src/game/g_main.o \
src/game/g_misc.o \
src/game/g_monster.o \
src/game/g_phys.o \
src/game/g_spawn.o \
src/game/g_svcmds.o \
src/game/g_target.o \
src/game/g_trigger.o \
src/game/g_turret.o \
src/game/g_utils.o \
src/game/g_weapon.o \
src/game/monster/berserker/berserker.o \
src/game/monster/boss2/boss2.o \
src/game/monster/boss3/boss3.o \
src/game/monster/boss3/boss31.o \
src/game/monster/boss3/boss32.o \
src/game/monster/brain/brain.o \
src/game/monster/chick/chick.o \
src/game/monster/flipper/flipper.o \
src/game/monster/float/float.o \
src/game/monster/flyer/flyer.o \
src/game/monster/gladiator/gladiator.o \
src/game/monster/gunner/gunner.o \
src/game/monster/hover/hover.o \
src/game/monster/infantry/infantry.o \
src/game/monster/insane/insane.o \
src/game/monster/medic/medic.o \
src/game/monster/misc/move.o \
src/game/monster/mutant/mutant.o \
src/game/monster/parasite/parasite.o \
src/game/monster/soldier/soldier.o \
src/game/monster/supertank/supertank.o \
src/game/monster/tank/tank.o \
src/game/player/client.o \
src/game/player/hud.o \
src/game/player/trail.o \
src/game/player/view.o \
src/game/player/weapon.o \
src/game/savegame/savegame.o
# ----------
# Used by the baseq2 game
BASEQ2_OBJS_ = \
src/game/baseq2/g_ai.o \
src/game/baseq2/g_chase.o \
src/game/baseq2/g_cmds.o \
src/game/baseq2/g_combat.o \
src/game/baseq2/g_func.o \
src/game/baseq2/g_items.o \
src/game/baseq2/g_main.o \
src/game/baseq2/g_misc.o \
src/game/baseq2/g_monster.o \
src/game/baseq2/g_phys.o \
src/game/baseq2/g_spawn.o \
src/game/baseq2/g_svcmds.o \
src/game/baseq2/g_target.o \
src/game/baseq2/g_trigger.o \
src/game/baseq2/g_turret.o \
src/game/baseq2/g_utils.o \
src/game/baseq2/g_weapon.o \
src/game/baseq2/monster/berserker/berserker.o \
src/game/baseq2/monster/boss2/boss2.o \
src/game/baseq2/monster/boss3/boss3.o \
src/game/baseq2/monster/boss3/boss31.o \
src/game/baseq2/monster/boss3/boss32.o \
src/game/baseq2/monster/brain/brain.o \
src/game/baseq2/monster/chick/chick.o \
src/game/baseq2/monster/flipper/flipper.o \
src/game/baseq2/monster/float/float.o \
src/game/baseq2/monster/flyer/flyer.o \
src/game/baseq2/monster/gladiator/gladiator.o \
src/game/baseq2/monster/gunner/gunner.o \
src/game/baseq2/monster/hover/hover.o \
src/game/baseq2/monster/infantry/infantry.o \
src/game/baseq2/monster/insane/insane.o \
src/game/baseq2/monster/medic/medic.o \
src/game/baseq2/monster/misc/move.o \
src/game/baseq2/monster/mutant/mutant.o \
src/game/baseq2/monster/parasite/parasite.o \
src/game/baseq2/monster/soldier/soldier.o \
src/game/baseq2/monster/supertank/supertank.o \
src/game/baseq2/monster/tank/tank.o \
src/game/baseq2/player/client.o \
src/game/baseq2/player/hud.o \
src/game/baseq2/player/trail.o \
src/game/baseq2/player/view.o \
src/game/baseq2/player/weapon.o \
src/game/baseq2/savegame/savegame.o
# Used by the client
CLIENT_OBJS_ := \
src/client/cl_cin.o \
@ -237,10 +255,7 @@ CLIENT_OBJS_ := \
src/client/sound/snd_mem.o \
src/client/sound/snd_mix.o \
src/client/sound/snd_vorbis.o \
src/client/sound/snd_wav.o
# Used by the client and the server
COMMON_OBJS_ := \
src/client/sound/snd_wav.o \
src/common/crc.o \
src/common/cvar.o \
src/common/filesystem.o \
@ -262,41 +277,75 @@ COMMON_OBJS_ := \
src/common/model/cm_boxtracing.o \
src/common/model/cm_bsp.o \
src/common/model/cm_vis.o \
src/common/unzip/ioapi.o \
src/common/unzip/unzip.o
# Used by the ctf game
CTF_OBJS_ = \
src/game/ctf/g_ai.o \
src/game/ctf/g_chase.o \
src/game/ctf/g_cmds.o \
src/game/ctf/g_combat.o \
src/game/ctf/g_ctf.o \
src/game/ctf/g_func.o \
src/game/ctf/g_items.o \
src/game/ctf/g_main.o \
src/game/ctf/g_misc.o \
src/game/ctf/g_monster.o \
src/game/ctf/g_phys.o \
src/game/ctf/g_save.o \
src/game/ctf/g_spawn.o \
src/game/ctf/g_svcmds.o \
src/game/ctf/g_target.o \
src/game/ctf/g_trigger.o \
src/game/ctf/g_utils.o \
src/game/ctf/g_weapon.o \
src/game/ctf/m_move.o \
src/game/ctf/p_client.o \
src/game/ctf/p_hud.o \
src/game/ctf/p_menu.o \
src/game/ctf/p_trail.o \
src/game/ctf/p_view.o \
src/game/ctf/p_weapon.o
# Used by the client, the server and baseq2
GAME_ABI_OBJS_ := \
src/common/shared/flash.o \
src/common/shared/shared.o
src/common/shared/shared.o \
src/common/unzip/ioapi.o \
src/common/unzip/unzip.o \
src/sdl/cd.o \
src/sdl/sound.o \
src/server/sv_cmd.o \
src/server/sv_conless.o \
src/server/sv_entities.o \
src/server/sv_game.o \
src/server/sv_init.o \
src/server/sv_main.o \
src/server/sv_save.o \
src/server/sv_send.o \
src/server/sv_user.o \
src/server/sv_world.o \
src/unix/glob.o \
src/unix/hunk.o \
src/unix/misc.o \
src/unix/network.o \
src/unix/system.o \
src/unix/vid.o
# ----------
# Used by the server
SERVER_OBJS_ := \
src/common/crc.o \
src/common/cvar.o \
src/common/filesystem.o \
src/common/md4.o \
src/common/misc.o \
src/common/netchan.o \
src/common/pmove.o \
src/common/szone.o \
src/common/zone.o \
src/common/command/cmd_execution.o \
src/common/command/cmd_parser.o \
src/common/command/cmd_script.o \
src/common/common/com_arg.o \
src/common/common/com_clientserver.o \
src/common/message/msg_io.o \
src/common/message/msg_read.o \
src/common/model/cm_areaportals.o \
src/common/model/cm_box.o \
src/common/model/cm_boxtracing.o \
src/common/model/cm_bsp.o \
src/common/model/cm_vis.o \
src/common/shared/flash.o \
src/common/shared/shared.o \
src/common/unzip/ioapi.o \
src/common/unzip/unzip.o \
src/server/sv_cmd.o \
src/server/sv_conless.o \
src/server/sv_entities.o \
src/server/sv_game.o \
src/server/sv_init.o \
src/server/sv_main.o \
src/server/sv_save.o \
src/server/sv_send.o \
src/server/sv_user.o \
src/server/sv_world.o \
src/unix/glob.o \
src/unix/hunk.o \
src/unix/misc.o \
src/unix/network.o \
src/unix/system.o
# ----------
# Used by the OpenGL refresher
OPENGL_OBJS_ = \
@ -315,169 +364,59 @@ OPENGL_OBJS_ = \
src/refresh/files/pcx.o \
src/refresh/files/sp2.o \
src/refresh/files/tga.o \
src/refresh/files/wal.o
# Used by the OpenGL refresher and ctf
LIGHT_GAME_ABI_OBJS_ = \
src/common/shared/shared.o
# Used by the client
UNIX_CLIENT_OBJS_ := \
src/refresh/files/wal.o \
src/sdl/input.o \
src/sdl/refresh.o \
src/common/shared/shared.o \
src/unix/glob.o \
src/unix/hunk.o \
src/unix/misc.o \
src/unix/network.o \
src/unix/system.o \
src/unix/vid.o
# Used by the OpenGL refresher
UNIX_OPENGL_OBJS_ = \
src/unix/glob.o \
src/unix/hunk.o \
src/unix/misc.o \
src/unix/qgl.o
# Used by the server
UNIX_SERVER_OBJS_ := \
src/unix/glob.o \
src/unix/hunk.o \
src/unix/misc.o \
src/unix/network.o \
src/unix/system.o
# Used by the client
SDL_OBJS_ := \
src/sdl/cd.o \
src/sdl/sound.o
# Used by the OpenGL refresher
SDL_OPENGL_OBJS_ := \
src/sdl/input.o \
src/sdl/refresh.o
# Used by the server
SERVER_OBJS_ := \
src/server/sv_cmd.o \
src/server/sv_conless.o \
src/server/sv_entities.o \
src/server/sv_game.o \
src/server/sv_init.o \
src/server/sv_main.o \
src/server/sv_save.o \
src/server/sv_send.o \
src/server/sv_user.o \
src/server/sv_world.o
# ----------
# Rewrite pathes to our object directory
CLIENT_COMMON_OBJS = $(patsubst %,build/client/%,$(COMMON_OBJS_))
CLIENT_GAME_ABI_OBJS = $(patsubst %,build/client/%,$(GAME_ABI_OBJS_))
CLIENT_OBJS = $(patsubst %,build/client/%,$(CLIENT_OBJS_))
CLIENT_SERVER_OBJS = $(patsubst %,build/client/%,$(SERVER_OBJS_))
UNIX_CLIENT_OBJS = $(patsubst %,build/client/%,$(UNIX_CLIENT_OBJS_))
SDL_OBJS = $(patsubst %,build/client/%,$(SDL_OBJS_))
SERVER_OBJS = $(patsubst %,build/server/%,$(SERVER_OBJS_))
SERVER_COMMON_OBJS = $(patsubst %,build/server/%,$(COMMON_OBJS_))
SERVER_GAME_ABI_OBJS = $(patsubst %,build/server/%,$(GAME_ABI_OBJS_))
UNIX_SERVER_OBJS= $(patsubst %,build/server/%,$(UNIX_SERVER_OBJS_))
OPENGL_OBJS = $(patsubst %,build/refresher/%,$(OPENGL_OBJS_))
OPENGL_GAME_ABI_OBJS = $(patsubst %,build/refresher/%,$(LIGHT_GAME_ABI_OBJS_))
UNIX_OPENGL_OBJS = $(patsubst %,build/refresher/%,$(UNIX_OPENGL_OBJS_))
SDL_OPENGL_OBJS = $(patsubst %,build/refresher/%,$(SDL_OPENGL_OBJS_))
BASEQ2_OBJS = $(patsubst %,build/baseq2/%,$(BASEQ2_OBJS_))
BASEQ2_GAME_ABI_OBJS = $(patsubst %,build/baseq2/%,$(GAME_ABI_OBJS_))
CTF_OBJS = $(patsubst %,build/ctf/%,$(LIGHT_GAME_ABI_OBJS_))
CTF_GAME_ABI_OBJS = $(patsubst %,build/ctf/%,$(CTF_OBJS_))
GAME_OBJS = $(patsubst %,build/baseq2/%,$(GAME_OBJS_))
# ----------
# Generate header dependencies
CLIENT_DEPS= $(CLIENT_OBJS:.o=.d)
CLIENT_COMMON_DEPS = $(CLIENT_COMMON_OBJS:.o=.d)
CLIENT_GAME_ABI_DEPS = $(CLIENT_GAME_ABI_OBJS:.o=.d)
CLIENT_SERVER_DEPS = $(CLIENT_SERVER_OBJS:.o=.d)
UNIX_CLIENT_DEPS = $(UNIX_CLIENT_OBJS:.o=.d)
SDL_DEPS = $(SDL_OBJS:.o=.d)
SERVER_DEPS= $(SERVER_OBJS:.o=.d)
SERVER_COMMON_DEPS= $(SERVER_COMMON_OBJS:.o=.d)
SERVER_GAME_ABI_DEPS = $(SERVER_GAME_ABI_OBJS:.o=.d)
UNIX_SERVER_DEPS= $(UNIX_SERVER_OBJS:.o=.d)
OPENGL_DEPS= $(OPENGL_OBJS:.o=.d)
OPENGL_GAME_ABI_DEPS= $(OPENGL_GAME_ABI_OBJS:.o=.d)
UNIX_OPENGL_DEPS= $(UNIX_OPENGL_OBJS:.o=.d)
SDL_OPENGL_DEPS= $(SDL_OPENGL_OBJS:.o=.d)
BASEQ2_DEPS= $(BASEQ2_OBJS:.o=.d)
BASEQ2_GAME_ABI_DEPS= $(BASEQ2_GAME_ABI_OBJS:.o=.d)
CTF_DEPS= $(CTF_OBJS:.o=.d)
CTF_GAME_ABI_DEPS= $(CTF_GAME_ABI_OBJS:.o=.d)
GAME_DEPS= $(GAME_OBJS:.o=.d)
# ----------
# Suck header dependencies in
-include $(CLIENT_DEPS)
-include $(CLIENT_COMMON_DEPS)
-include $(CLIENT_GAME_ABI_DEPS)
-include $(CLIENT_SERVER_DEPS)
-include $(UNIX_CLIENT_DEPS)
-include $(SDL_DEPS)
-include $(SERVER_DEPS)
-include $(SERVER_COMMON_DEPS)
-include $(SERVER_GAME_ABI_DEPS)
-include $(UNIX_SERVER_DEPS)
-include $(OPENGL_DEPS)
-include $(OPENGL_GAME_ABI_DEPS)
-include $(UNIX_OPENGL_DEPS)
-include $(SDL_OPENGL_DEPS)
-include $(BASEQ2_DEPS)
-include $(BASEQ2_GAME_ABI_DEPS)
-include $(CTF_DEPS)
-include $(CTF_GAME_ABI_DEPS)
-include $(GAME_DEPS)
# ----------
# release/quake2
release/quake2 : $(CLIENT_OBJS) $(CLIENT_COMMON_OBJS) $(CLIENT_GAME_ABI_OBJS) \
$(UNIX_CLIENT_OBJS) $(SDL_OBJS) $(CLIENT_SERVER_OBJS)
release/quake2 : $(CLIENT_OBJS)
@echo '===> LD $@'
@$(CC) $(LDFLAGS) -o $@ $(CLIENT_OBJS) $(CLIENT_COMMON_OBJS) \
$(CLIENT_GAME_ABI_OBJS) $(UNIX_CLIENT_OBJS) \
$(SDL_OBJS) $(CLIENT_SERVER_OBJS)
@$(CC) $(LDFLAGS) $(X11LDFLAGS) $(SDLLDFLAGS) -o $@ $(CLIENT_OBJS)
# release/q2ded
release/q2ded : $(SERVER_OBJS) $(SERVER_COMMON_OBJS) $(SERVER_GAME_ABI_OBJS) \
$(UNIX_SERVER_OBJS)
release/q2ded : $(SERVER_OBJS)
@echo '===> LD $@'
@$(CC) $(LDFLAGS) -o $@ $(SERVER_OBJS) $(SERVER_COMMON_OBJS) \
$(SERVER_GAME_ABI_OBJS) $(UNIX_SERVER_OBJS)
@$(CC) $(LDFLAGS) -o $@ $(SERVER_OBJS)
# release/ref_gl.so
release/ref_gl.so : $(OPENGL_OBJS) $(OPENGL_GAME_ABI_OBJS) \
$(UNIX_OPENGL_OBJS) $(SDL_OPENGL_OBJS)
release/ref_gl.so : $(OPENGL_OBJS)
@echo '===> LD $@'
@$(CC) $(LDFLAGS) -o $@ $(OPENGL_OBJS) $(OPENGL_GAME_ABI_OBJS) \
$(UNIX_OPENGL_OBJS) $(SDL_OPENGL_OBJS)
@$(CC) $(LDFLAGS) -o $@ $(OPENGL_OBJS)
# release/bsaeq2/game.so
release/baseq2/game.so : $(BASEQ2_OBJS) $(BASEQ2_GAME_ABI_OBJS)
# release/baseq2/game.so
release/baseq2/game.so : $(GAME_OBJS)
@echo '===> LD $@'
@$(CC) $(LDFLAGS) -o $@ $(BASEQ2_OBJS) $(BASEQ2_GAME_ABI_OBJS)
@$(CC) $(LDFLAGS) -o $@ $(GAME_OBJS)
# release/ctf/game.so
release/ctf/game.so : $(CTF_OBJS) $(CTF_GAME_ABI_OBJS)
@echo '===> LD $@'
@$(CC) $(LDFLAGS) -o $@ $(CTF_OBJS) $(CTF_GAME_ABI_OBJS)
# ----------

View file

@ -27,7 +27,7 @@
#ifndef GAME_LOCAL_H
#define GAME_LOCAL_H
#include "../../../common/header/shared.h"
#include "../../common/header/shared.h"
/* define GAME_INCLUDE so that game.h does not define the
short, server-visible gclient_t and edict_t structures,

View file

@ -28,7 +28,7 @@
#define SV_SERVER_H
#include "../../common/header/common.h"
#include "../../game/baseq2/header/game.h"
#include "../../game/header/game.h"
#define MAX_MASTERS 8
#define LATENCY_COUNTS 16