CC = gcc
CXX = g++

CPPFLAGS = -DSIN
# comment this out to enable assertions:
CPPFLAGS+= -DNDEBUG
CPPFLAGS+= -Did386=1

CFLAGS = -Wall -fPIC
#CFLAGS+= -g -ggdb
CFLAGS+= -O2
CFLAGS+= -ffast-math
#CFLAGS+= -fwrapv

CXXFLAGS = $(CFLAGS)
CXXFLAGS+= -fno-exceptions -fno-rtti
CXXFLAGS+= -Wno-sign-compare
CXXFLAGS+= -Wno-overloaded-virtual

LDFLAGS = -shared
# make sure that this flags is supported
LDFLAGS+= -Wl,--no-undefined
# export only the relevant functions:
LDFLAGS+= -Wl,--version-script=game.version
LDLIBS = -lm

TARGETS = game.so

GAME = actor.o \
	ammo.o \
	animals.o \
	archive.o \
	areaportal.o \
	armor.o \
	assaultrifle.o \
	bacrodai.o \
	behavior.o \
	bouncingbetty.o \
	box.o \
	bspline.o \
	bullet.o \
	camera.o \
	camgun.o \
	chaingun.o \
	class.o \
	console.o \
	ctf.o \
	ctf_turret.o \
	deadbody.o \
	doors.o \
	earthquake.o \
	entity.o \
	eonandpeon.o \
	explosion.o \
	fists.o \
	gamescript.o \
	genericbullet.o \
	genericrocket.o \
	gibs.o \
	glowstick.o \
	g_main.o \
	g_phys.o \
	grapple.o \
	gravpath.o \
	g_spawn.o \
	g_utils.o \
	hammer.o \
	health.o \
	heligun.o \
	inventoryitem.o \
	item.o \
	keys.o \
	launcher.o \
	lensflare.o \
	light.o \
	listener.o \
	magnum.o \
	misc.o \
	mover.o \
	mutanthands.o \
	navigate.o \
	object.o \
	path.o \
	peon.o \
	player.o \
	playerstart.o \
	powerups.o \
	pulserifle.o \
	q_shared.o \
	quantumd.o \
	reactiveshields.o \
	rocketlauncher.o \
	rocket_turret.o \
	script.o \
	scriptmaster.o \
	scriptslave.o \
	scriptvariable.o \
	secgun.o \
	securityturret.o \
	sentient.o \
	shield.o \
	shotgun.o \
	shotrocketlauncher.o \
	silencer.o \
	skeet.o \
	sniperrifle.o \
	speargun.o \
	specialfx.o \
	spidermine.o \
	steering.o \
	stungun.o \
	surface.o \
	testweapon.o \
	thrall.o \
	trigger.o \
	turret.o \
	vehicle.o \
	viewthing.o \
	weapon.o \
	worldspawn.o \
	wrench.o
# str.cpp is only good for TestStringClass()
#	str.o

.PHONY: default all clean
#

OBJECTS = $(GAME)

default: all

all: $(TARGETS)

%.o: %.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@

%.o: %.cpp
	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@

game.so: $(OBJECTS)
	$(CXX) -o $@ $(LDFLAGS) $(OBJECTS) $(LDLIBS)

clean:
	rm -f *.o $(TARGETS)
