mirror of
https://github.com/yquake2/rogue.git
synced 2024-11-21 20:01:39 +00:00
7929e845d3
See https://github.com/yquake2/yquake2/issues/71 and https://github.com/yquake2/xatrix/issues/4 In ClientThink(), the float value ent->velocity[i]*8 is saved into a short and if the value is too big for a short, in 32bit gcc builds the short is set to SHRT_MIN, resulting in the player being pressed down instead of up. Now we put the result in a 32bit int first (which should be big enough) and assign the int to the short. This still overflows, but with -fwrapv at least in a defined way (most probably the same way the original binaries did). The Makefile now sets $CC to gcc for MingW builds, this should fix https://github.com/yquake2/xatrix/issues/3 And while I was at it, when the game lib is loaded, it prints the date it was built, this is especially interesting for our Win32 binaries.
234 lines
5.3 KiB
Makefile
234 lines
5.3 KiB
Makefile
# ----------------------------------------------------- #
|
|
# Makefile for the rogue game module for Quake II #
|
|
# #
|
|
# Just type "make" to compile the #
|
|
# - Ground Zero Game (game.so) #
|
|
# #
|
|
# Dependencies: #
|
|
# - None, but you need a Quake II to play. #
|
|
# While in theorie every client should work #
|
|
# Yamagi Quake II ist recommended. #
|
|
# #
|
|
# Platforms: #
|
|
# - FreeBSD #
|
|
# - Linux #
|
|
# - Mac OS X #
|
|
# - OpenBSD #
|
|
# - Windows #
|
|
# ----------------------------------------------------- #
|
|
|
|
# Detect the OS
|
|
ifdef SystemRoot
|
|
OSTYPE := Windows
|
|
else
|
|
OSTYPE := $(shell uname -s)
|
|
endif
|
|
|
|
# Special case for MinGW
|
|
ifneq (,$(findstring MINGW,$(OSTYPE)))
|
|
OSTYPE := Windows
|
|
endif
|
|
|
|
# Detect the architecture
|
|
ifeq ($(OSTYPE), Windows)
|
|
# At this time only i386 is supported on Windows
|
|
ARCH := i386
|
|
# seems like mingw doesn't set CC by default
|
|
CC := gcc
|
|
else
|
|
# Some platforms call it "amd64" and some "x86_64"
|
|
ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/amd64/x86_64/)
|
|
endif
|
|
|
|
# Refuse all other platforms as a firewall against PEBKAC
|
|
# (You'll need some #ifdef for your unsupported plattform!)
|
|
ifeq ($(findstring $(ARCH), i386 x86_64 sparc64 ia64),)
|
|
$(error arch $(ARCH) is currently not supported)
|
|
endif
|
|
|
|
# ----------
|
|
|
|
# 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!
|
|
#
|
|
# -fPIC for position independend code.
|
|
#
|
|
# -MMD to generate header dependencies.
|
|
ifeq ($(OSTYPE), Darwin)
|
|
CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer \
|
|
-Wall -pipe -g -fwrapv -arch i386 -arch x86_64
|
|
else
|
|
CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer \
|
|
-Wall -pipe -g -MMD -fwrapv
|
|
endif
|
|
|
|
# ----------
|
|
|
|
# Base LDFLAGS.
|
|
ifeq ($(OSTYPE), Darwin)
|
|
LDFLAGS := -shared -arch i386 -arch x86_64
|
|
else
|
|
LDFLAGS := -shared
|
|
endif
|
|
|
|
# ----------
|
|
|
|
# Builds everything
|
|
all: rogue
|
|
|
|
# ----------
|
|
|
|
# When make is invoked by "make VERBOSE=1" print
|
|
# the compiler and linker commands.
|
|
|
|
ifdef VERBOSE
|
|
Q :=
|
|
else
|
|
Q := @
|
|
endif
|
|
|
|
# ----------
|
|
|
|
# Phony targets
|
|
.PHONY : all clean rogue
|
|
|
|
# ----------
|
|
|
|
# Cleanup
|
|
clean:
|
|
@echo "===> CLEAN"
|
|
${Q}rm -Rf build release
|
|
|
|
# ----------
|
|
|
|
# The rogue game
|
|
ifeq ($(OSTYPE), Windows)
|
|
rogue:
|
|
@echo "===> Building game.dll"
|
|
${Q}mkdir -p release
|
|
$(MAKE) release/game.dll
|
|
|
|
build/%.o: %.c
|
|
@echo "===> CC $<"
|
|
${Q}mkdir -p $(@D)
|
|
${Q}$(CC) -c $(CFLAGS) -o $@ $<
|
|
else
|
|
rogue:
|
|
@echo "===> Building game.so"
|
|
${Q}mkdir -p release
|
|
$(MAKE) release/game.so
|
|
|
|
build/%.o: %.c
|
|
@echo "===> CC $<"
|
|
${Q}mkdir -p $(@D)
|
|
${Q}$(CC) -c $(CFLAGS) -o $@ $<
|
|
|
|
release/game.so : CFLAGS += -fPIC
|
|
endif
|
|
|
|
# ----------
|
|
|
|
ROGUE_OBJS_ = \
|
|
src/g_ai.o \
|
|
src/g_chase.o \
|
|
src/g_cmds.o \
|
|
src/g_combat.o \
|
|
src/g_func.o \
|
|
src/g_items.o \
|
|
src/g_main.o \
|
|
src/g_misc.o \
|
|
src/g_monster.o \
|
|
src/g_newai.o \
|
|
src/g_newdm.o \
|
|
src/g_newfnc.o \
|
|
src/g_newtarg.o \
|
|
src/g_newtrig.o \
|
|
src/g_newweap.o \
|
|
src/g_phys.o \
|
|
src/g_spawn.o \
|
|
src/g_sphere.o \
|
|
src/g_svcmds.o \
|
|
src/g_target.o \
|
|
src/g_trigger.o \
|
|
src/g_turret.o \
|
|
src/g_utils.o \
|
|
src/g_weapon.o \
|
|
src/dm/ball.o \
|
|
src/dm/tag.o \
|
|
src/monster/berserker/berserker.o \
|
|
src/monster/boss2/boss2.o \
|
|
src/monster/boss3/boss3.o \
|
|
src/monster/boss3/boss31.o \
|
|
src/monster/boss3/boss32.o \
|
|
src/monster/brain/brain.o \
|
|
src/monster/carrier/carrier.o \
|
|
src/monster/chick/chick.o \
|
|
src/monster/flipper/flipper.o \
|
|
src/monster/float/float.o \
|
|
src/monster/flyer/flyer.o \
|
|
src/monster/gladiator/gladiator.o \
|
|
src/monster/gunner/gunner.o \
|
|
src/monster/hover/hover.o \
|
|
src/monster/infantry/infantry.o \
|
|
src/monster/insane/insane.o \
|
|
src/monster/medic/medic.o \
|
|
src/monster/misc/move.o \
|
|
src/monster/mutant/mutant.o \
|
|
src/monster/parasite/parasite.o \
|
|
src/monster/soldier/soldier.o \
|
|
src/monster/stalker/stalker.o \
|
|
src/monster/supertank/supertank.o \
|
|
src/monster/tank/tank.o \
|
|
src/monster/turret/turret.o \
|
|
src/monster/widow/widow.o \
|
|
src/monster/widow/widow2.o \
|
|
src/player/client.o \
|
|
src/player/hud.o \
|
|
src/player/trail.o \
|
|
src/player/view.o \
|
|
src/player/weapon.o \
|
|
src/savegame/savegame.o \
|
|
src/shared/flash.o \
|
|
src/shared/rand.o \
|
|
src/shared/shared.o
|
|
|
|
# ----------
|
|
|
|
# Rewrite pathes to our object directory
|
|
ROGUE_OBJS = $(patsubst %,build/%,$(ROGUE_OBJS_))
|
|
|
|
# ----------
|
|
|
|
# Generate header dependencies
|
|
ROGUE_DEPS= $(ROGUE_OBJS:.o=.d)
|
|
|
|
# ----------
|
|
|
|
# Suck header dependencies in
|
|
-include $(ROGUE_DEPS)
|
|
|
|
# ----------
|
|
|
|
ifeq ($(OSTYPE), Windows)
|
|
release/game.dll : $(ROGUE_OBJS)
|
|
@echo "===> LD $@"
|
|
${Q}$(CC) $(LDFLAGS) -o $@ $(ROGUE_OBJS)
|
|
else
|
|
release/game.so : $(ROGUE_OBJS)
|
|
@echo "===> LD $@"
|
|
${Q}$(CC) $(LDFLAGS) -o $@ $(ROGUE_OBJS)
|
|
endif
|
|
|
|
# ----------
|