forked from jonof/jfbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
301 lines (254 loc) · 7.56 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# 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
# DYNAMIC_OPENGL - enables run-time loading of OpenGL library
# NOASM - disables the use of assembly code
# LINKED_GTK - enables compile-time linkage to GTK
#
SUPERBUILD ?= 1
POLYMOST ?= 1
USE_OPENGL ?= 1
DYNAMIC_OPENGL ?= 1
NOASM ?= 0
LINKED_GTK ?= 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
DXROOT=z:/sdks/directx/dx7
FMODROOTWIN=c:/sdks/fmodapi374win/api
# build locations - OBJ gets overridden to the game-specific objects dir
OBJ?=obj.gnu
SRC=src
GAME=kenbuild
TOOLS=tools
INC=include
# 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=g++
AS=nasm
RC=windres
AR=ar
RANLIB=ranlib
OURCFLAGS=$(debug) -W -Wall -Wimplicit -Wno-char-subscripts -Wno-unused \
-fno-pic -funsigned-char -fno-strict-aliasing -DNO_GCC_BUILTINS \
-DKSFORBUILD -I$(INC) -I$(SRC)
OURCXXFLAGS=-fno-exceptions -fno-rtti
GAMECFLAGS=-I$(GAME) -I$(INC)
LIBS=
GAMELIBS=
ASFLAGS=-s #-g
EXESUFFIX=
include Makefile.shared
ENGINEOBJS=
ifeq (0,$(NOASM))
ENGINEOBJS+= $(SRC)/a.$o
endif
ENGINEOBJS+= \
$(SRC)/a-c.$o \
$(SRC)/baselayer.$o \
$(SRC)/cache1d.$o \
$(SRC)/compat.$o \
$(SRC)/crc32.$o \
$(SRC)/defs.$o \
$(SRC)/engine.$o \
$(SRC)/polymost.$o \
$(SRC)/polymosttex.$o \
$(SRC)/polymosttex-squish.$o \
$(SRC)/polymosttexcache.$o \
$(SRC)/hightile.$o \
$(SRC)/mdsprite.$o \
$(SRC)/glbuild.$o \
$(SRC)/kplib.$o \
$(SRC)/lzf_c.$o \
$(SRC)/lzf_d.$o \
$(SRC)/md4.$o \
$(SRC)/mmulti.$o \
$(SRC)/osd.$o \
$(SRC)/pragmas.$o \
$(SRC)/scriptfile.$o \
$(SRC)/textfont.$o \
$(SRC)/smalltextfont.$o
EDITOROBJS=$(SRC)/build.$o \
$(SRC)/config.$o
GAMEEXEOBJS=$(GAME)/game.$o \
$(GAME)/sound_stub.$o \
$(GAME)/config.$o \
$(ENGINELIB)
EDITOREXEOBJS=$(GAME)/bstub.$o \
$(EDITORLIB) \
$(ENGINELIB)
ENGINEOBJS+= \
$(LIBSQUISH)/alpha.$o \
$(LIBSQUISH)/clusterfit.$o \
$(LIBSQUISH)/colourblock.$o \
$(LIBSQUISH)/colourfit.$o \
$(LIBSQUISH)/colourset.$o \
$(LIBSQUISH)/maths.$o \
$(LIBSQUISH)/rangefit.$o \
$(LIBSQUISH)/singlecolourfit.$o \
$(LIBSQUISH)/squish.$o
# 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
GAMELIBS+= -L$(FMODROOTWIN)/lib
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)
ENGINEOBJS+= $(SRC)/sdlayer.$o
OURCFLAGS+= $(subst -Dmain=SDL_main,,$(SDLCONFIG_CFLAGS))
ifeq (1,$(HAVE_GTK2))
OURCFLAGS+= -DHAVE_GTK2 $(shell pkg-config --cflags gtk+-2.0)
ENGINEOBJS+= $(SRC)/gtkbits.$o $(SRC)/dynamicgtk.$o
EDITOROBJS+= $(SRC)/startgtk.editor.$o
GAMEEXEOBJS+= $(GAME)/game_banner.$o $(GAME)/startgtk.game.$o
EDITOREXEOBJS+= $(GAME)/editor_banner.$o
endif
GAMEEXEOBJS+= $(GAME)/game_icon.$o
EDITOREXEOBJS+= $(GAME)/build_icon.$o
endif
ifeq ($(RENDERTYPE),WIN)
ENGINEOBJS+= $(SRC)/winlayer.$o
EDITOROBJS+= $(SRC)/startwin.editor.$o
GAMEEXEOBJS+= $(GAME)/gameres.$(res) $(GAME)/startwin.game.$o
EDITOREXEOBJS+= $(GAME)/buildres.$(res)
endif
ifneq (0,$(EFENCE))
LIBS+= -lefence
OURCFLAGS+= -DEFENCE
endif
OURCFLAGS+= $(BUILDCFLAGS)
.PHONY: clean veryclean all utils enginelib editorlib
# TARGETS
# Invoking Make from the terminal in OSX just chains the build on to xcode
ifeq ($(PLATFORM),DARWIN)
ifeq ($(RELEASE),0)
style=Debug
else
style=Release
endif
.PHONY: alldarwin
alldarwin:
cd xcode && xcodebuild -project engine.xcodeproj -alltargets -configuration $(style)
cd xcode && xcodebuild -project game.xcodeproj -alltargets -configuration $(style)
endif
UTILS=kextract$(EXESUFFIX) kgroup$(EXESUFFIX) transpal$(EXESUFFIX) wad2art$(EXESUFFIX) wad2map$(EXESUFFIX) arttool$(EXESUFFIX)
all: game$(EXESUFFIX) build$(EXESUFFIX)
utils: $(UTILS)
enginelib: $(ENGINELIB)
editorlib: $(EDITORLIB)
$(ENGINELIB): $(ENGINEOBJS)
$(AR) rc $@ $^
$(RANLIB) $@
$(EDITORLIB): $(EDITOROBJS)
$(AR) rc $@ $^
$(RANLIB) $@
game$(EXESUFFIX): $(GAMEEXEOBJS)
$(CXX) $(CFLAGS) $(OURCFLAGS) -o $@ $^ $(GAMELIBS) $(LIBS)
build$(EXESUFFIX): $(EDITOREXEOBJS)
$(CXX) $(CFLAGS) $(OURCFLAGS) -o $@ $^ $(LIBS)
kextract$(EXESUFFIX): $(TOOLS)/kextract.$o $(ENGINELIB)
$(CC) -o $@ $^ $(ENGINELIB)
kgroup$(EXESUFFIX): $(TOOLS)/kgroup.$o $(ENGINELIB)
$(CC) -o $@ $^ $(ENGINELIB)
transpal$(EXESUFFIX): $(TOOLS)/transpal.$o $(ENGINELIB)
$(CC) -o $@ $^ $(ENGINELIB)
arttool$(EXESUFFIX): $(TOOLS)/arttool.$o
$(CXX) -o $@ $^
wad2art$(EXESUFFIX): $(TOOLS)/wad2art.$o $(ENGINELIB)
$(CC) -o $@ $^ $(ENGINELIB)
wad2map$(EXESUFFIX): $(TOOLS)/wad2map.$o $(ENGINELIB)
$(CC) -o $@ $^ $(ENGINELIB)
generateicon$(EXESUFFIX): $(TOOLS)/generateicon.$o $(ENGINELIB)
$(CC) -o $@ $^ $(ENGINELIB)
cacheinfo$(EXESUFFIX): $(TOOLS)/cacheinfo.$o $(ENGINELIB)
$(CC) -o $@ $^ $(ENGINELIB)
# DEPENDENCIES
include Makefile.deps
# RULES
$(SRC)/%.$o: $(SRC)/%.$(asm)
$(AS) $(ASFLAGS) $< -o $@
$(SRC)/%.$o: $(SRC)/%.c
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
$(SRC)/%.$o: $(SRC)/%.cc
$(CXX) $(CXXFLAGS) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
$(SRC)/%.$o: $(SRC)/%.cpp
$(CXX) $(CXXFLAGS) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
$(LIBSQUISH)/%.$o: $(LIBSQUISH)/%.cpp
$(CXX) $(CXXFLAGS) $(BUILDCFLAGS) -O2 -c $< -o $@ 2>&1
$(GAME)/%.$o: $(GAME)/%.c
$(CC) $(CFLAGS) $(OURCFLAGS) $(GAMECFLAGS) -c $< -o $@ 2>&1
$(GAME)/%.$o: $(GAME)/%.cpp
$(CXX) $(CXXFLAGS) $(OURCXXFLAGS) $(OURCFLAGS) $(GAMECFLAGS) -c $< -o $@ 2>&1
$(GAME)/%.$o: $(GAME)/rsrc/%.c
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
$(GAME)/%.$(res): $(GAME)/rsrc/%.rc
$(RC) -i $< -o $@ --include-dir=$(INC) --include-dir=$(GAME)
$(RSRC)/game_banner.c: $(RSRC)/game.bmp
echo "#include <gdk-pixbuf/gdk-pixdata.h>" > $@
gdk-pixbuf-csource --extern --struct --raw --name=startbanner_pixdata $^ | sed 's/load_inc//' >> $@
$(RSRC)/editor_banner.c: $(RSRC)/build.bmp
echo "#include <gdk-pixbuf/gdk-pixdata.h>" > $@
gdk-pixbuf-csource --extern --struct --raw --name=startbanner_pixdata $^ | sed 's/load_inc//' >> $@
$(TOOLS)/%.$o: $(TOOLS)/%.c
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
$(TOOLS)/%.$o: $(TOOLS)/%.cc
$(CXX) $(CXXFLAGS) -c $< -o $@ 2>&1
# PHONIES
clean:
ifeq ($(PLATFORM),DARWIN)
cd xcode && xcodebuild -project engine.xcodeproj -alltargets -configuration $(style) clean
cd xcode && xcodebuild -project game.xcodeproj -alltargets -configuration $(style) clean
else
-rm -f $(ENGINEOBJS) $(EDITOROBJS) $(GAMEEXEOBJS) $(EDITOREXEOBJS)
endif
veryclean: clean
ifeq ($(PLATFORM),DARWIN)
else
-rm -f $(ENGINELIB) $(EDITORLIB) game$(EXESUFFIX) build$(EXESUFFIX) $(UTILS)
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