-
Notifications
You must be signed in to change notification settings - Fork 18
/
Makefile
218 lines (179 loc) · 5.45 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
# Duke3D Makefile for GNU Make
# Create Makefile.user yourself to provide your own overrides
# for configurable values
-include Makefile.user
##
##
## CONFIGURABLE OPTIONS
##
##
# Engine options
# USE_POLYMOST - enables Polymost renderer
# USE_OPENGL - enables OpenGL support in Polymost
# Define as 0 to disable OpenGL
# Define as USE_GL2 (or 1 or 2) for GL 2.0/2.1 profile
# Define as USE_GL3 (or 3) for GL 3.2 Core profile
# Define as USE_GLES2 (or 12) for GLES 2.0 profile
# USE_ASM - enables the use of assembly code if supported
#
USE_POLYMOST ?= 1
USE_OPENGL ?= 1
USE_ASM ?= 1
# Debugging options
# RELEASE - 1 = optimised release build, no debugging aids
RELEASE ?= 1
# Path where game data is installed
DATADIR ?= /usr/local/share/games/jfduke3d
##
##
## HERE BE DRAGONS
##
##
ENGINEROOT=jfbuild
ENGINEINC=$(ENGINEROOT)/include
MACTROOT=jfmact
AUDIOLIBROOT=jfaudiolib
SRC=src
RSRC=rsrc
CC?=gcc
CXX?=g++
RC?=windres
OURCFLAGS=-g -W -Wall -fno-strict-aliasing -std=c99
OURCXXFLAGS=-g -W -Wall -fno-exceptions -fno-rtti -std=c++98
OURCPPFLAGS=-I$(SRC) -I$(ENGINEINC) -I$(MACTROOT) -I$(AUDIOLIBROOT)/include
OURLDFLAGS=
ifneq ($(RELEASE),0)
# Default optimisation settings
CFLAGS?=-fomit-frame-pointer -O1
CXXFLAGS?=-fomit-frame-pointer -O1
else
CFLAGS?=-Og
CXXFLAGS?=-Og
endif
# Filename extensions, used in Makefile.deps etc
o=o
res=o
include $(ENGINEROOT)/Makefile.shared
# Apply shared flags
OURCFLAGS+= $(BUILDCFLAGS)
OURCXXFLAGS+= $(BUILDCXXFLAGS)
OURCPPFLAGS+= $(BUILDCPPFLAGS)
OURLDFLAGS+= $(BUILDLDFLAGS)
include $(AUDIOLIBROOT)/Makefile.shared
OURLDFLAGS+= $(JFAUDIOLIB_LDFLAGS)
GAMEOBJS=$(SRC)/game.$o \
$(SRC)/actors.$o \
$(SRC)/gamedef.$o \
$(SRC)/global.$o \
$(SRC)/menues.$o \
$(SRC)/player.$o \
$(SRC)/premap.$o \
$(SRC)/sector.$o \
$(SRC)/rts.$o \
$(SRC)/config.$o \
$(SRC)/osdfuncs.$o \
$(SRC)/osdcmds.$o \
$(SRC)/grpscan.$o \
$(SRC)/sounds.$o
GAMEOBJS+= \
$(MACTROOT)/util_lib.$o \
$(MACTROOT)/file_lib.$o \
$(MACTROOT)/control.$o \
$(MACTROOT)/keyboard.$o \
$(MACTROOT)/mouse.$o \
$(MACTROOT)/mathutil.$o \
$(MACTROOT)/scriplib.$o \
$(MACTROOT)/animlib.$o
EDITOROBJS=$(SRC)/astub.$o
# Specialise for the platform
ifeq ($(PLATFORM),LINUX)
OURLDFLAGS+= $(JFAUDIOLIB_LDFLAGS)
OURCPPFLAGS+= -DDATADIR=\"$(DATADIR)\"
endif
ifeq ($(PLATFORM),BSD)
OURLDFLAGS+= $(JFAUDIOLIB_LDFLAGS) -pthread
OURCPPFLAGS+= -DDATADIR=\"$(DATADIR)\"
endif
ifeq ($(PLATFORM),WINDOWS)
GAMEOBJS+= $(SRC)/gameres.$(res) \
$(SRC)/winbits.$o \
$(SRC)/startwin_game.$o
EDITOROBJS+= $(SRC)/buildres.$(res)
OURLDFLAGS+= -lole32 -ldsound \
$(AUDIOLIBROOT)/third-party/mingw32/lib/libvorbisfile.a \
$(AUDIOLIBROOT)/third-party/mingw32/lib/libvorbis.a \
$(AUDIOLIBROOT)/third-party/mingw32/lib/libogg.a
endif
ifeq ($(PLATFORM),DARWIN)
GAMEOBJS+= $(SRC)/StartupWinController.$o \
$(SRC)/GameListSource.$o
OURLDFLAGS+= -framework AppKit
endif
ifeq ($(RENDERTYPE),SDL)
OURCFLAGS+= $(SDLCONFIG_CFLAGS)
OURLDFLAGS+= $(SDLCONFIG_LIBS)
ifeq (1,$(HAVE_GTK))
OURCFLAGS+= $(GTKCONFIG_CFLAGS)
OURLDFLAGS+= $(GTKCONFIG_LIBS)
GAMEOBJS+= $(SRC)/startgtk_game.$o \
$(RSRC)/startgtk_game_gresource.$o
EDITOROBJS+= $(RSRC)/startgtk_build_gresource.$o
endif
GAMEOBJS+= $(RSRC)/sdlappicon_game.$o
EDITOROBJS+= $(RSRC)/sdlappicon_build.$o
endif
# Source-control version stamping
ifneq (,$(findstring git version,$(shell git --version)))
GAMEOBJS+= $(SRC)/version-auto.$o
EDITOROBJS+= $(SRC)/version-auto.$o
else
GAMEOBJS+= $(SRC)/version.$o
EDITOROBJS+= $(SRC)/version.$o
endif
# TARGETS
.PHONY: clean veryclean all
all: duke3d$(EXESUFFIX) build$(EXESUFFIX)
include Makefile.deps
$(ENGINEROOT)/%:
$(MAKE) -C $(@D) -f Makefile \
USE_POLYMOST=$(USE_POLYMOST) \
USE_OPENGL=$(USE_OPENGL) \
USE_ASM=$(USE_ASM) \
RELEASE=$(RELEASE) $(@F)
$(AUDIOLIBROOT)/%:
$(MAKE) -C $(@D) \
RELEASE=$(RELEASE) $(@F)
duke3d$(EXESUFFIX): $(GAMEOBJS) $(ENGINEROOT)/$(ENGINELIB) $(AUDIOLIBROOT)/$(JFAUDIOLIB)
$(CXX) $(CPPFLAGS) $(OURCPPFLAGS) $(CXXFLAGS) $(OURCXXFLAGS) -o $@ $^ $(LDFLAGS) $(OURLDFLAGS)
build$(EXESUFFIX): $(EDITOROBJS) $(ENGINEROOT)/$(EDITORLIB) $(ENGINEROOT)/$(ENGINELIB)
$(CXX) $(CPPFLAGS) $(OURCPPFLAGS) $(CXXFLAGS) $(OURCXXFLAGS) -o $@ $^ $(LDFLAGS) $(OURLDFLAGS)
# RULES
$(SRC)/%.$o: $(SRC)/%.c
$(CC) $(CPPFLAGS) $(OURCPPFLAGS) $(CFLAGS) $(OURCFLAGS) -c $< -o $@
$(SRC)/%.$o: $(SRC)/%.m
$(CC) $(CPPFLAGS) $(OURCPPFLAGS) $(CFLAGS) $(OURCFLAGS) -c $< -o $@
$(MACTROOT)/%.$o: $(MACTROOT)/%.c
$(CC) $(CPPFLAGS) $(OURCPPFLAGS) $(CFLAGS) $(OURCFLAGS) -c $< -o $@
$(RSRC)/%.$o: $(RSRC)/%.c
$(CC) $(CPPFLAGS) $(OURCPPFLAGS) $(CFLAGS) $(OURCFLAGS) -c $< -o $@
$(SRC)/%.$(res): $(SRC)/%.rc
$(RC) -i $< -o $@ --include-dir=$(SRC) --include-dir=$(ENGINEINC)
$(RSRC)/%_gresource.c $(RSRC)/%_gresource.h: $(RSRC)/%.gresource.xml
glib-compile-resources --generate --manual-register --c-name=startgtk --target=$@ --sourcedir=$(RSRC) $<
$(RSRC)/sdlappicon_%.c: $(RSRC)/%.png | $(ENGINEROOT)/generatesdlappicon$(EXESUFFIX)
$(ENGINEROOT)/generatesdlappicon$(EXESUFFIX) $< > $@
# PHONIES
clean::
-rm -f $(GAMEOBJS) $(EDITOROBJS)
veryclean:: clean
-rm -f duke3d$(EXESUFFIX) build$(EXESUFFIX) core*
clean::
$(MAKE) -C $(ENGINEROOT) $@
$(MAKE) -C $(AUDIOLIBROOT) $@
veryclean::
$(MAKE) -C $(ENGINEROOT) $@
.PHONY: $(SRC)/version-auto.c
$(SRC)/version-auto.c:
printf "const char *game_version = \"%s\";\n" "$(shell git describe --always || echo git error)" > $@
echo "const char *game_date = __DATE__;" >> $@
echo "const char *game_time = __TIME__;" >> $@