2006-04-13 20:47:06 +00:00
|
|
|
# Build Makefile for GNU Make
|
|
|
|
|
|
|
|
# Notes:
|
|
|
|
# As of 6 July 2005, the engine should handle optimisations being enabled.
|
|
|
|
# If things seem to be going wrong, lower or disable optimisations, then
|
|
|
|
# try again. If things are still going wrong, call me.
|
|
|
|
#
|
|
|
|
|
|
|
|
# Engine options - these may be overridden by game makefiles
|
|
|
|
# SUPERBUILD - enables voxels
|
|
|
|
# POLYMOST - enables Polymost renderer
|
|
|
|
# USE_OPENGL - enables OpenGL support in Polymost
|
|
|
|
# NOASM - disables the use of inline assembly pragmas
|
|
|
|
#
|
|
|
|
# SETSPRITEZ - set to 1 for Shadow Warrior
|
|
|
|
SUPERBUILD ?= 1
|
|
|
|
POLYMOST ?= 1
|
|
|
|
USE_OPENGL ?= 1
|
|
|
|
NOASM ?= 0
|
|
|
|
|
|
|
|
SETSPRITEZ ?= 0
|
|
|
|
|
|
|
|
# Debugging options
|
|
|
|
# RELEASE - 1 = no debugging
|
|
|
|
# EFENCE - 1 = compile with Electric Fence for malloc() debugging
|
|
|
|
RELEASE?=1
|
|
|
|
EFENCE?=0
|
|
|
|
|
|
|
|
# SDK locations - adjust to match your setup
|
2006-04-15 03:12:08 +00:00
|
|
|
DXROOT=c:/sdks/directx/dx61
|
2006-04-13 20:47:06 +00:00
|
|
|
FMODROOTWIN=c:/sdks/fmodapi374win/api
|
|
|
|
|
|
|
|
# build locations - OBJ gets overridden to the game-specific objects dir
|
2006-08-31 01:54:23 +00:00
|
|
|
OBJ?=obj.gnu
|
|
|
|
SRC=src
|
|
|
|
RSRC=rsrc
|
|
|
|
INC=include
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
# filename extensions - these won't need to change
|
|
|
|
o=o
|
|
|
|
res=o
|
|
|
|
asm=nasm
|
|
|
|
|
|
|
|
# debugging and release
|
|
|
|
ifneq ($(RELEASE),0)
|
|
|
|
# debugging disabled
|
|
|
|
debug=-fomit-frame-pointer -O2
|
|
|
|
else
|
|
|
|
# debugging enabled
|
|
|
|
debug=-ggdb -O0 -DDEBUGGINGAIDS -DNOSDLPARACHUTE
|
|
|
|
endif
|
|
|
|
|
|
|
|
CC=gcc
|
|
|
|
CXX=gcc
|
|
|
|
AS=nasm
|
|
|
|
RC=windres
|
|
|
|
AR=ar
|
|
|
|
RANLIB=ranlib
|
|
|
|
OURCFLAGS=$(debug) -W -Wall -Wimplicit -Wno-char-subscripts -Wno-unused \
|
|
|
|
-funsigned-char -fno-strict-aliasing -DNO_GCC_BUILTINS \
|
2006-08-31 01:54:23 +00:00
|
|
|
-DKSFORBUILD -I$(INC)
|
2006-04-13 20:47:06 +00:00
|
|
|
OURCXXFLAGS=-fno-exceptions -fno-rtti
|
|
|
|
LIBS=
|
|
|
|
ASFLAGS=-s #-g
|
|
|
|
EXESUFFIX=
|
|
|
|
|
|
|
|
include Makefile.shared
|
|
|
|
|
2006-09-10 17:40:34 +00:00
|
|
|
ENGINEOBJS=
|
|
|
|
ifeq (0,$(NOASM))
|
|
|
|
ENGINEOBJS+= $(OBJ)/a.$o
|
2006-04-13 20:47:06 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ENGINEOBJS+= \
|
2006-09-10 17:40:34 +00:00
|
|
|
$(OBJ)/a-c.$o \
|
2006-08-31 01:54:23 +00:00
|
|
|
$(OBJ)/baselayer.$o \
|
|
|
|
$(OBJ)/cache1d.$o \
|
|
|
|
$(OBJ)/compat.$o \
|
|
|
|
$(OBJ)/crc32.$o \
|
|
|
|
$(OBJ)/defs.$o \
|
|
|
|
$(OBJ)/engine.$o \
|
|
|
|
$(OBJ)/glbuild.$o \
|
|
|
|
$(OBJ)/kplib.$o \
|
|
|
|
$(OBJ)/lzf_c.$o \
|
|
|
|
$(OBJ)/lzf_d.$o \
|
|
|
|
$(OBJ)/md4.$o \
|
2006-12-04 04:12:14 +00:00
|
|
|
$(OBJ)/mmulti.$o \
|
2006-08-31 01:54:23 +00:00
|
|
|
$(OBJ)/osd.$o \
|
|
|
|
$(OBJ)/pragmas.$o \
|
2006-10-15 18:59:45 +00:00
|
|
|
$(OBJ)/scriptfile.$o \
|
2006-08-31 01:54:23 +00:00
|
|
|
$(OBJ)/polymer.$o
|
|
|
|
|
|
|
|
EDITOROBJS=$(OBJ)/build.$o \
|
|
|
|
$(OBJ)/config.$o
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
# detect the platform
|
|
|
|
ifeq ($(PLATFORM),LINUX)
|
|
|
|
ASFLAGS+= -f elf
|
|
|
|
LIBS+= -lm
|
|
|
|
endif
|
|
|
|
ifeq ($(PLATFORM),BSD)
|
|
|
|
ASFLAGS+= -f elf
|
|
|
|
OURCFLAGS+= -I/usr/X11R6/include
|
|
|
|
LIBS+= -lm
|
|
|
|
endif
|
|
|
|
ifeq ($(PLATFORM),WINDOWS)
|
|
|
|
OURCFLAGS+= -DUNDERSCORES -I$(DXROOT)/include -I$(FMODROOTWIN)/inc
|
|
|
|
LIBS+= -lm
|
|
|
|
ASFLAGS+= -DUNDERSCORES -f win32
|
|
|
|
endif
|
|
|
|
ifeq ($(PLATFORM),BEOS)
|
|
|
|
ASFLAGS+= -f elf
|
|
|
|
TARGETOPTS+= -DNOASM
|
|
|
|
endif
|
|
|
|
ifeq ($(PLATFORM),SUNOS)
|
|
|
|
LIBS+= -lm
|
|
|
|
endif
|
|
|
|
ifeq ($(PLATFORM),SYLLABLE)
|
|
|
|
ASFLAGS+= -f elf
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(RENDERTYPE),SDL)
|
2006-08-31 01:54:23 +00:00
|
|
|
ENGINEOBJS+= $(OBJ)/sdlayer.$o
|
2006-04-13 20:47:06 +00:00
|
|
|
OURCFLAGS+= $(subst -Dmain=SDL_main,,$(SDLCONFIG_CFLAGS))
|
|
|
|
|
|
|
|
ifeq (1,$(HAVE_GTK2))
|
|
|
|
OURCFLAGS+= -DHAVE_GTK2 $(shell pkg-config --cflags gtk+-2.0)
|
2006-08-31 01:54:23 +00:00
|
|
|
ENGINEOBJS+= $(OBJ)/gtkbits.$o $(OBJ)/dynamicgtk.$o
|
|
|
|
EDITOROBJS+= $(OBJ)/startgtk.editor.$o
|
2006-04-13 20:47:06 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
ifeq ($(RENDERTYPE),WIN)
|
2006-08-31 01:54:23 +00:00
|
|
|
ENGINEOBJS+= $(OBJ)/winlayer.$o
|
|
|
|
EDITOROBJS+= $(OBJ)/startwin.editor.$o
|
2006-04-13 20:47:06 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq (0,$(EFENCE))
|
|
|
|
LIBS+= -lefence
|
|
|
|
OURCFLAGS+= -DEFENCE
|
|
|
|
endif
|
|
|
|
|
|
|
|
OURCFLAGS+= $(BUILDCFLAGS)
|
|
|
|
|
2006-07-01 01:40:18 +00:00
|
|
|
.PHONY: clean veryclean all utils enginelib editorlib
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
# TARGETS
|
|
|
|
|
|
|
|
# Invoking Make from the terminal in OSX just chains the build on to xcode
|
|
|
|
ifeq ($(PLATFORM),DARWIN)
|
|
|
|
ifeq ($(RELEASE),0)
|
|
|
|
style=Development
|
|
|
|
else
|
|
|
|
style=Deployment
|
|
|
|
endif
|
|
|
|
.PHONY: alldarwin
|
|
|
|
alldarwin:
|
|
|
|
cd osx/engine && xcodebuild -target All -buildstyle $(style)
|
|
|
|
endif
|
|
|
|
|
|
|
|
UTILS=kextract$(EXESUFFIX) kgroup$(EXESUFFIX) transpal$(EXESUFFIX) wad2art$(EXESUFFIX) wad2map$(EXESUFFIX)
|
|
|
|
|
2006-11-16 03:00:03 +00:00
|
|
|
all: $(OBJ)/$(ENGINELIB) $(OBJ)/$(EDITORLIB)
|
2006-04-13 20:47:06 +00:00
|
|
|
utils: $(UTILS)
|
|
|
|
|
2006-08-31 01:54:23 +00:00
|
|
|
enginelib: $(OBJ)/$(ENGINELIB)
|
|
|
|
$(OBJ)/$(ENGINELIB): $(ENGINEOBJS)
|
2006-04-13 20:47:06 +00:00
|
|
|
$(AR) rc $@ $^
|
|
|
|
$(RANLIB) $@
|
|
|
|
|
2006-08-31 01:54:23 +00:00
|
|
|
editorlib: $(OBJ)/$(EDITORLIB)
|
|
|
|
$(OBJ)/$(EDITORLIB): $(EDITOROBJS)
|
2006-04-13 20:47:06 +00:00
|
|
|
$(AR) rc $@ $^
|
|
|
|
$(RANLIB) $@
|
|
|
|
|
2006-08-31 01:54:23 +00:00
|
|
|
pragmacheck$(EXESUFFIX): $(OBJ)/pragmacheck.$o $(OBJ)/pragmas.$o
|
2006-04-13 20:47:06 +00:00
|
|
|
$(CC) $(subst -Dmain=app_main,,$(OURCFLAGS)) -o $@ $^
|
|
|
|
|
2006-08-31 01:54:23 +00:00
|
|
|
kextract$(EXESUFFIX): $(OBJ)/kextract.$o $(OBJ)/compat.$o
|
2006-04-13 20:47:06 +00:00
|
|
|
$(CC) -o $@ $^
|
2006-08-31 01:54:23 +00:00
|
|
|
kgroup$(EXESUFFIX): $(OBJ)/kgroup.$o $(OBJ)/compat.$o
|
2006-04-13 20:47:06 +00:00
|
|
|
$(CC) -o $@ $^
|
2006-08-31 01:54:23 +00:00
|
|
|
transpal$(EXESUFFIX): $(OBJ)/transpal.$o $(OBJ)/pragmas.$o $(OBJ)/compat.$o
|
2006-04-13 20:47:06 +00:00
|
|
|
$(CC) -o $@ $^
|
2006-08-31 01:54:23 +00:00
|
|
|
wad2art$(EXESUFFIX): $(OBJ)/wad2art.$o $(OBJ)/pragmas.$o $(OBJ)/compat.$o
|
2006-04-13 20:47:06 +00:00
|
|
|
$(CC) -o $@ $^
|
2006-08-31 01:54:23 +00:00
|
|
|
wad2map$(EXESUFFIX): $(OBJ)/wad2map.$o $(OBJ)/pragmas.$o $(OBJ)/compat.$o
|
2006-04-13 20:47:06 +00:00
|
|
|
$(CC) -o $@ $^
|
2006-08-31 01:54:23 +00:00
|
|
|
generateicon$(EXESUFFIX): $(OBJ)/generateicon.$o $(OBJ)/kplib.$o
|
2006-04-13 20:47:06 +00:00
|
|
|
$(CC) -o $@ $^
|
2006-08-31 01:54:23 +00:00
|
|
|
cacheinfo$(EXESUFFIX): $(OBJ)/cacheinfo.$o $(OBJ)/compat.$o
|
2006-04-13 20:47:06 +00:00
|
|
|
$(CC) -o $@ $^
|
|
|
|
enumdisplay$(EXESUFFIX): src/misc/enumdisplay.c
|
|
|
|
$(CC) -g -Os -o $@ $^ -I$(DXROOT)/include -lgdi32
|
2006-08-31 01:54:23 +00:00
|
|
|
mapdump$(EXESUFFIX): $(OBJ)/mapdump.$o
|
|
|
|
$(CC) -o $@ $^
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
# DEPENDENCIES
|
|
|
|
include Makefile.deps
|
|
|
|
|
|
|
|
# RULES
|
2006-08-31 01:54:23 +00:00
|
|
|
$(OBJ)/%.$o: $(SRC)/%.nasm
|
2006-04-13 20:47:06 +00:00
|
|
|
$(AS) $(ASFLAGS) $< -o $@
|
|
|
|
|
2006-08-31 01:54:23 +00:00
|
|
|
$(OBJ)/%.$o: $(SRC)/%.c
|
2006-04-13 20:47:06 +00:00
|
|
|
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
|
|
|
|
|
2006-08-31 01:54:23 +00:00
|
|
|
$(OBJ)/%.$o: $(SRC)/%.cpp
|
2006-04-13 20:47:06 +00:00
|
|
|
$(CXX) $(CXXFLAGS) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
|
|
|
|
|
2006-08-31 01:54:23 +00:00
|
|
|
$(OBJ)/%.$o: $(SRC)/misc/%.rc
|
2006-11-16 03:00:03 +00:00
|
|
|
$(RC) -i $< -o $@ --include-dir=$(INC) --include-dir=$(SRC)
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-08-31 01:54:23 +00:00
|
|
|
$(OBJ)/%.$o: $(SRC)/util/%.c
|
2006-04-13 20:47:06 +00:00
|
|
|
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
|
|
|
|
|
2006-08-31 01:54:23 +00:00
|
|
|
$(OBJ)/%.$o: $(RSRC)/%.c
|
2006-04-13 20:47:06 +00:00
|
|
|
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
|
|
|
|
|
2006-08-31 01:54:23 +00:00
|
|
|
$(OBJ)/editor_banner.$o: $(RSRC)/editor_banner.c
|
2006-04-13 20:47:06 +00:00
|
|
|
echo "#include <gdk-pixbuf/gdk-pixdata.h>" > $@
|
|
|
|
gdk-pixbuf-csource --extern --struct --raw --name=startbanner_pixdata $^ | sed 's/load_inc//' >> $@
|
2006-08-31 01:54:23 +00:00
|
|
|
$(RSRC)/editor_banner.c: $(RSRC)/build.bmp
|
2006-04-13 20:47:06 +00:00
|
|
|
echo "#include <gdk-pixbuf/gdk-pixdata.h>" > $@
|
|
|
|
gdk-pixbuf-csource --extern --struct --raw --name=startbanner_pixdata $^ | sed 's/load_inc//' >> $@
|
|
|
|
|
|
|
|
# PHONIES
|
|
|
|
clean:
|
|
|
|
ifeq ($(PLATFORM),DARWIN)
|
|
|
|
cd osx/engine && xcodebuild -target All clean
|
|
|
|
else
|
2006-08-31 01:54:23 +00:00
|
|
|
-rm -f $(OBJ)/*
|
2006-04-13 20:47:06 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
veryclean: clean
|
|
|
|
ifeq ($(PLATFORM),DARWIN)
|
|
|
|
else
|
2006-11-16 03:00:03 +00:00
|
|
|
-rm -f $(ENGINELIB) $(EDITORLIB) $(UTILS)
|
2006-04-13 20:47:06 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
.PHONY: fixlineends
|
|
|
|
fixlineends:
|
|
|
|
for a in `find . -type f \( -name '*.c' -o -name '*.h' -o -name 'Makefile*' \) \! -path '*/.svn/*'`; do \
|
|
|
|
echo Fixing $$a && tr -d "\015" < $$a > $$a.fix && mv $$a.fix $$a; \
|
|
|
|
done
|