2008-08-20 22:58:09 +00:00
|
|
|
#
|
2006-04-13 20:47:06 +00:00
|
|
|
# Build Makefile for GNU Make
|
2008-08-20 22:58:09 +00:00
|
|
|
#
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
# 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
|
2007-08-17 19:32:56 +00:00
|
|
|
# LINKED_GTK - enables compile-time linkage to GTK
|
2006-04-13 20:47:06 +00:00
|
|
|
#
|
2007-08-16 23:25:24 +00:00
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
SUPERBUILD ?= 1
|
|
|
|
POLYMOST ?= 1
|
2008-05-10 01:29:37 +00:00
|
|
|
POLYMER ?= 1
|
2006-04-13 20:47:06 +00:00
|
|
|
USE_OPENGL ?= 1
|
|
|
|
NOASM ?= 0
|
2007-08-17 19:32:56 +00:00
|
|
|
LINKED_GTK ?= 0
|
2008-03-26 09:28:21 +00:00
|
|
|
BUILD32_ON_64 ?= 0
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-08-20 22:58:09 +00:00
|
|
|
# Debugging/Build options
|
2006-04-13 20:47:06 +00:00
|
|
|
# RELEASE - 1 = no debugging
|
|
|
|
# EFENCE - 1 = compile with Electric Fence for malloc() debugging
|
2008-08-20 22:58:09 +00:00
|
|
|
# OPTLEVEL - 0..3 = GCC optimization strategy
|
|
|
|
#
|
2006-04-13 20:47:06 +00:00
|
|
|
RELEASE?=1
|
|
|
|
EFENCE?=0
|
2008-08-20 22:58:09 +00:00
|
|
|
OPTLEVEL ?= 2
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-08-20 22:58:09 +00:00
|
|
|
# SDK locations for Windows - 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
|
|
|
|
|
2008-08-20 22:58:09 +00:00
|
|
|
# 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
|
|
|
|
2008-08-20 22:58:09 +00:00
|
|
|
# Filename extensions - these won't need to change
|
|
|
|
#
|
2006-04-13 20:47:06 +00:00
|
|
|
o=o
|
|
|
|
res=o
|
|
|
|
asm=nasm
|
|
|
|
|
2008-08-20 22:58:09 +00:00
|
|
|
# Debugging and release
|
|
|
|
#
|
|
|
|
ifneq ($(RELEASE),0)
|
|
|
|
# Debugging disabled
|
2008-06-14 09:25:22 +00:00
|
|
|
debug=-fomit-frame-pointer -O$(OPTLEVEL)
|
2006-04-13 20:47:06 +00:00
|
|
|
else
|
2008-08-20 22:58:09 +00:00
|
|
|
# Debugging enabled
|
2006-04-13 20:47:06 +00:00
|
|
|
debug=-ggdb -O0 -DDEBUGGINGAIDS -DNOSDLPARACHUTE
|
|
|
|
endif
|
|
|
|
|
|
|
|
CC=gcc
|
|
|
|
CXX=gcc
|
|
|
|
AS=nasm
|
|
|
|
RC=windres
|
|
|
|
AR=ar
|
|
|
|
RANLIB=ranlib
|
2008-03-22 10:23:57 +00:00
|
|
|
OURCFLAGS=$(debug) -W -Wall -Wimplicit -Wno-char-subscripts \
|
2006-04-13 20:47:06 +00:00
|
|
|
-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 \
|
2008-05-10 01:29:37 +00:00
|
|
|
$(OBJ)/scriptfile.$o
|
|
|
|
ifeq (1,$(POLYMER))
|
|
|
|
ENGINEOBJS+= $(OBJ)/polymer.$o
|
|
|
|
endif
|
2006-08-31 01:54:23 +00:00
|
|
|
|
|
|
|
EDITOROBJS=$(OBJ)/build.$o \
|
|
|
|
$(OBJ)/config.$o
|
|
|
|
|
2008-08-20 22:58:09 +00:00
|
|
|
# PLATFORM SPECIFIC SETTINGS
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
ifeq ($(PLATFORM),LINUX)
|
|
|
|
ASFLAGS+= -f elf
|
|
|
|
LIBS+= -lm
|
|
|
|
endif
|
2008-08-20 22:58:09 +00:00
|
|
|
ifeq ($(PLATFORM),DARWIN)
|
|
|
|
ENGINEOBJS += $(OBJ)/StartupWinController.editor.$o \
|
|
|
|
$(OBJ)//osxbits.$o
|
|
|
|
ASFLAGS += -f Mach-O
|
|
|
|
TARGETOPTS += -DNOASM
|
|
|
|
endif
|
2006-04-13 20:47:06 +00:00
|
|
|
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)
|
2008-04-25 01:46:19 +00:00
|
|
|
ENGINEOBJS+= $(OBJ)/gtkbits.$o
|
|
|
|
ifeq ($(LINKED_GTK),0)
|
|
|
|
ENGINEOBJS+= $(OBJ)/dynamicgtk.$o
|
|
|
|
endif
|
2006-08-31 01:54:23 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
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
|
2008-02-18 08:46:42 +00:00
|
|
|
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-08-20 22:58:09 +00:00
|
|
|
$(OBJ)/%.$o: $(SRC)/%.m
|
|
|
|
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@
|
|
|
|
|
2006-08-31 01:54:23 +00:00
|
|
|
$(OBJ)/%.$o: $(SRC)/%.cpp
|
2008-02-18 08:46:42 +00:00
|
|
|
$(CXX) $(CXXFLAGS) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@
|
2006-04-13 20:47:06 +00:00
|
|
|
|
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
|
2008-02-18 08:46:42 +00:00
|
|
|
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-08-31 01:54:23 +00:00
|
|
|
$(OBJ)/%.$o: $(RSRC)/%.c
|
2008-02-18 08:46:42 +00:00
|
|
|
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@
|
2006-04-13 20:47:06 +00:00
|
|
|
|
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
|
2008-08-20 22:58:09 +00:00
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
clean:
|
2006-08-31 01:54:23 +00:00
|
|
|
-rm -f $(OBJ)/*
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
veryclean: clean
|
2006-11-16 03:00:03 +00:00
|
|
|
-rm -f $(ENGINELIB) $(EDITORLIB) $(UTILS)
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
.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
|