zaero/Makefile

232 lines
5.2 KiB
Makefile
Raw Normal View History

2011-10-11 15:28:06 +00:00
# ----------------------------------------------------- #
# Makefile for the zaero game module for Quake II #
# #
# Just type "make" to compile the #
# - Zaero Game (game.so / game.dll) #
2011-10-11 15:28:06 +00:00
# #
# Dependencies: #
# - None, but you need a Quake II to play. #
# While in theorie every one should work #
# Yamagi Quake II ist recommended. #
# #
# Platforms: #
# - Linux #
# - FreeBSD #
# ----------------------------------------------------- #
2009-04-10 08:06:07 +00:00
# Detect the OS
ifdef SystemRoot
OSTYPE := Windows
else
2009-04-10 08:06:07 +00:00
OSTYPE := $(shell uname -s)
endif
2009-04-10 08:06:07 +00:00
# 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"
2009-04-10 08:06:07 +00:00
ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/amd64/x86_64/)
endif
2009-04-10 08:06:07 +00:00
# Refuse all other platforms as a firewall against PEBKAC
2011-10-11 15:28:06 +00:00
# (You'll need some #ifdef for your unsupported plattform!)
ifeq ($(findstring $(ARCH), i386 x86_64 sparc64 ia64),)
2009-04-10 08:06:07 +00:00
$(error arch $(ARCH) is currently not supported)
endif
# ----------
# Base CFLAGS.
2011-10-11 15:28:06 +00:00
#
# -O2 are enough optimizations.
#
2011-10-11 15:28:06 +00:00
# -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)
2011-10-11 15:28:06 +00:00
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
2009-04-10 08:06:07 +00:00
# ----------
2011-10-11 15:28:06 +00:00
# Base LDFLAGS.
ifeq ($(OSTYPE), Darwin)
LDFLAGS := -shared -arch i386 -arch x86_64
else
2011-10-11 15:28:06 +00:00
LDFLAGS := -shared
endif
2009-04-10 08:06:07 +00:00
2011-10-11 15:28:06 +00:00
# ----------
2009-04-10 08:06:07 +00:00
2011-10-11 15:28:06 +00:00
# Builds everything
all: zaero
2009-04-10 08:06:07 +00:00
# ----------
# 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 zaero
# ----------
2011-10-11 15:28:06 +00:00
# Cleanup
ifeq ($(OSTYPE), Windows)
clean:
@echo "===> CLEAN"
@-rmdir /S /Q release build
else
2011-10-11 15:28:06 +00:00
clean:
@echo "===> CLEAN"
${Q}rm -Rf build release
endif
2009-04-10 08:06:07 +00:00
2011-10-11 15:28:06 +00:00
# ----------
2009-04-10 08:06:07 +00:00
2011-10-11 15:28:06 +00:00
# The zaero game
ifeq ($(OSTYPE), Windows)
zaero:
@echo "===> Building game.dll"
${Q}tools/mkdir.exe -p release
${MAKE} release/game.dll
build/%.o: %.c
@echo "===> CC $<"
${Q}tools/mkdir.exe -p $(@D)
${Q}$(CC) -c $(CFLAGS) -o $@ $<
else
2009-04-10 08:06:07 +00:00
zaero:
@echo "===> Building game.so"
${Q}mkdir -p release
2009-04-10 08:06:07 +00:00
$(MAKE) release/game.so
2011-10-11 15:28:06 +00:00
build/%.o: %.c
@echo "===> CC $<"
${Q}mkdir -p $(@D)
${Q}$(CC) -c $(CFLAGS) -o $@ $<
release/game.so : CFLAGS += -fPIC
endif
2009-04-10 08:06:07 +00:00
# ----------
2011-10-11 15:28:06 +00:00
ZAERO_OBJS_ = \
src/g_ai.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_phys.o \
src/g_spawn.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/monster/actor/actor.o \
src/monster/berserker/berserker.o \
src/monster/boss/boss.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/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/handler/handler.o \
src/monster/hound/hound.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/sentien/sentien.o \
src/monster/soldier/soldier.o \
src/monster/supertank/supertank.o \
src/monster/tank/tank.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/shared.o \
src/zaero/acannon.o \
src/zaero/ai.o \
src/zaero/anim.o \
src/zaero/camera.o \
src/zaero/frames.o \
src/zaero/item.o \
src/zaero/mtest.o \
src/zaero/spawn.o \
src/zaero/trigger.o \
src/zaero/weapon.o
2009-04-10 08:06:07 +00:00
# ----------
2011-10-11 15:28:06 +00:00
# Rewrite pathes to our object directory
ZAERO_OBJS = $(patsubst %,build/%,$(ZAERO_OBJS_))
2009-04-10 08:06:07 +00:00
2011-10-11 15:28:06 +00:00
# ----------
2009-04-10 08:06:07 +00:00
2011-10-11 15:28:06 +00:00
# Generate header dependencies
ZAERO_DEPS= $(ZAERO_OBJS:.o=.d)
2009-04-10 08:06:07 +00:00
2011-10-11 15:28:06 +00:00
# ----------
2009-04-10 08:06:07 +00:00
2011-10-11 15:28:06 +00:00
# Suck header dependencies in
-include $(ZAERO_DEPS)
2009-04-10 08:06:07 +00:00
# ----------
ifeq ($(OSTYPE), Windows)
release/game.dll : $(ZAERO_OBJS)
@echo "===> LD $@"
${Q}$(CC) $(LDFLAGS) -o $@ $(ZAERO_OBJS)
else
2009-04-10 08:06:07 +00:00
release/game.so : $(ZAERO_OBJS)
@echo "===> LD $@"
${Q}$(CC) $(LDFLAGS) -o $@ $(ZAERO_OBJS)
endif
2009-04-10 08:06:07 +00:00
2011-10-11 15:28:06 +00:00
# ----------