forked from jonof/jfduke3d
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
220 lines (179 loc) · 5.13 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
# Duke3D Makefile for GNU Make
# Create Makefile.user yourself to provide your own overrides
# for configurable values
-include Makefile.user
##
##
## CONFIGURABLE OPTIONS
##
##
# Debugging options
RELEASE ?= 1
# DirectX SDK location
DXROOT ?= $(HOME)/sdks/directx/dx7
# Engine source code path
EROOT ?= ../jfbuild.git
# JMACT library source path
MACTROOT ?= ../jfmact.git
# JFAudioLib source path
AUDIOLIBROOT ?= ../jfaudiolib.git
# Engine options
SUPERBUILD ?= 1
POLYMOST ?= 1
USE_OPENGL ?= 1
DYNAMIC_OPENGL ?= 1
NOASM ?= 0
LINKED_GTK ?= 0
##
##
## HERE BE DRAGONS
##
##
# build locations
SRC=source
RSRC=rsrc
EINC=$(EROOT)/include
ELIB=$(EROOT)
INC=$(SRC)
o=o
ifneq (0,$(RELEASE))
# debugging disabled
debug=-fomit-frame-pointer -O1
else
# debugging enabled
debug=-ggdb -O0
endif
include $(AUDIOLIBROOT)/Makefile.shared
CC=gcc
CXX=g++
OURCFLAGS=$(debug) -W -Wall -Wimplicit -Wno-char-subscripts -Wno-unused \
-fno-pic -funsigned-char -fno-strict-aliasing -DNO_GCC_BUILTINS -DNOCOPYPROTECT \
-I$(INC) -I$(EINC) -I$(MACTROOT) -I$(AUDIOLIBROOT)/include
OURCXXFLAGS=-fno-exceptions -fno-rtti
LIBS=-lm
GAMELIBS=
NASMFLAGS=-s #-g
EXESUFFIX=
JMACTOBJ=$(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
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)/testcd.$o \
$(SRC)/osdfuncs.$o \
$(SRC)/osdcmds.$o \
$(SRC)/grpscan.$o \
$(SRC)/sounds.$o \
$(JMACTOBJ)
EDITOROBJS=$(SRC)/astub.$o
include $(EROOT)/Makefile.shared
ifeq ($(PLATFORM),LINUX)
NASMFLAGS+= -f elf
GAMELIBS+= $(JFAUDIOLIB_LDFLAGS)
endif
ifeq ($(PLATFORM),WINDOWS)
OURCFLAGS+= -DUNDERSCORES -I$(DXROOT)/include
NASMFLAGS+= -DUNDERSCORES -f win32
GAMEOBJS+= $(SRC)/gameres.$o $(SRC)/winbits.$o $(SRC)/startwin.game.$o
EDITOROBJS+= $(SRC)/buildres.$o
GAMELIBS+= -ldsound \
$(AUDIOLIBROOT)/third-party/mingw32/lib/libvorbisfile.a \
$(AUDIOLIBROOT)/third-party/mingw32/lib/libvorbis.a \
$(AUDIOLIBROOT)/third-party/mingw32/lib/libogg.a
endif
ifeq ($(RENDERTYPE),SDL)
OURCFLAGS+= $(subst -Dmain=SDL_main,,$(shell sdl-config --cflags))
ifeq (1,$(HAVE_GTK2))
OURCFLAGS+= -DHAVE_GTK2 $(shell pkg-config --cflags gtk+-2.0)
GAMEOBJS+= $(SRC)/game_banner.$o $(SRC)/startgtk.game.$o
EDITOROBJS+= $(SRC)/editor_banner.$o
endif
GAMEOBJS+= $(SRC)/game_icon.$o
EDITOROBJS+= $(SRC)/build_icon.$o
endif
OURCFLAGS+= $(BUILDCFLAGS)
.PHONY: clean all engine $(ELIB)/$(ENGINELIB) $(ELIB)/$(EDITORLIB) $(AUDIOLIBROOT)/$(JFAUDIOLIB)
# 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 osx && xcodebuild -target All -buildstyle $(style)
endif
all: duke3d$(EXESUFFIX) build$(EXESUFFIX)
duke3d$(EXESUFFIX): $(GAMEOBJS) $(ELIB)/$(ENGINELIB) $(AUDIOLIBROOT)/$(JFAUDIOLIB)
$(CXX) $(CXXFLAGS) $(OURCXXFLAGS) $(OURCFLAGS) -o $@ $^ $(LIBS) $(GAMELIBS) -Wl,[email protected]
build$(EXESUFFIX): $(EDITOROBJS) $(ELIB)/$(EDITORLIB) $(ELIB)/$(ENGINELIB)
$(CXX) $(CXXFLAGS) $(OURCXXFLAGS) $(OURCFLAGS) -o $@ $^ $(LIBS) -Wl,[email protected]
include Makefile.deps
.PHONY: enginelib editorlib
enginelib editorlib:
$(MAKE) -C $(EROOT) \
SUPERBUILD=$(SUPERBUILD) POLYMOST=$(POLYMOST) \
USE_OPENGL=$(USE_OPENGL) DYNAMIC_OPENGL=$(DYNAMIC_OPENGL) \
NOASM=$(NOASM) RELEASE=$(RELEASE) $@
$(ELIB)/$(ENGINELIB): enginelib
$(ELIB)/$(EDITORLIB): editorlib
$(AUDIOLIBROOT)/$(JFAUDIOLIB):
$(MAKE) -C $(AUDIOLIBROOT) RELEASE=$(RELEASE)
# RULES
$(SRC)/%.$o: $(SRC)/%.nasm
nasm $(NASMFLAGS) $< -o $@
$(SRC)/%.$o: $(SRC)/%.c
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
$(SRC)/%.$o: $(SRC)/%.cpp
$(CXX) $(CXXFLAGS) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
$(MACTROOT)/%.$o: $(MACTROOT)/%.c
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
$(SRC)/%.$o: $(SRC)/misc/%.rc
windres -i $< -o $@ --include-dir=$(EINC) --include-dir=$(SRC)
$(SRC)/%.$o: $(SRC)/util/%.c
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
$(SRC)/%.$o: $(RSRC)/%.c
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
$(SRC)/game_banner.$o: $(RSRC)/game_banner.c
$(SRC)/editor_banner.$o: $(RSRC)/editor_banner.c
$(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//' >> $@
# PHONIES
clean:
ifeq ($(PLATFORM),DARWIN)
cd osx && xcodebuild -target All clean
else
-rm -f $(GAMEOBJS) $(EDITOROBJS)
$(MAKE) -C $(EROOT) clean
$(MAKE) -C $(AUDIOLIBROOT) clean
endif
veryclean: clean
ifeq ($(PLATFORM),DARWIN)
else
-rm -f duke3d$(EXESUFFIX) build$(EXESUFFIX) core*
$(MAKE) -C $(EROOT) veryclean
endif
ifeq ($(PLATFORM),WINDOWS)
.PHONY: datainst
datainst:
cd datainst && $(MAKE) GAME=DUKE3D
endif