-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
388 lines (303 loc) · 9.72 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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# ---------------------------------------------------------------------------- #
empty:=
space:= $(empty) $(empty)
# ---------------------------------------------------------------------------- #
# FIXME some unknown 'rv' flag is being passed here externally -- remove it
ARFLAGS =
################################################################################
#
# CONFIGURATIONS & PLATFORMS
#
################################################################################
CONFIGURATIONS := DEBUG RELEASE
CONFIGURATION ?= RELEASE
PLATFORMS := HW1 HW2
PLATFORM ?= HW2
# ---------------------------------------------------------------------------- #
ifeq ($(CONFIGURATION), DEBUG)
CONFIGURATION = DEBUG
DEBUG = TRUE
ASFLAGS += -D_DEBUG
CCFLAGS += -D_DEBUG
CXXFLAGS += -D_DEBUG
else ifeq ($(CONFIGURATION), RELEASE)
CONFIGURATION = RELEASE
DEBUG = FALSE
ASFLAGS += -DNDEBUG
CCFLAGS += -DNDEBUG
CXXFLAGS += -DNDEBUG
else
$(error Unknown configuration '$(CONFIGURATION)'. Must be one of: $(CONFIGURATIONS))
endif
# ---------------------------------------------------------------------------- #
ifeq ($(PLATFORM), HW2)
EPPC = TRUE
MARLIN = DI
ORCA = TRUE
PROCESSOR = gekko
TRK_INTEGRATION = TRUE
GX_REV = 2
BUGLIST += BUG_CLR_LOAD_DLY
BUGLIST += BUG_XF_STALL
else ifeq ($(PLATFORM), HW1)
EPPC = TRUE
MARLIN = DI
ORCA = TRUE
PROCESSOR = gekko
TRK_INTEGRATION = TRUE
GX_REV = 1
BUGLIST += BUG_BYPASS_REG
BUGLIST += BUG_INDX_ALIGN
BUGLIST += BUG_TRIANGLE_FAN
BUGLIST += BUG_NO_8b_SCALE
BUGLIST += BUG_INDX_MTX_LOAD
BUGLIST += BUG_MTX_INDX_VTX
BUGLIST += BUG_DBL_CLR_LOAD
BUGLIST += BUG_16MB_XFB_LMT
BUGLIST += BUG_XF_STALL
else
$(error Unknown platform '$(PLATFORM)'. Must be one of: $(PLATFORMS))
endif
# ---------------------------------------------------------------------------- #
ifdef EPPC
ASFLAGS += -DEPPC
CCFLAGS += -DEPPC
CXXFLAGS += -DEPPC
endif
# ---------------------------------------------------------------------------- #
ifdef MARLIN
ASFLAGS += -DMARLIN=$(MARLIN)
CCFLAGS += -DMARLIN=$(MARLIN)
CXXFLAGS += -DMARLIN=$(MARLIN)
endif
# ---------------------------------------------------------------------------- #
ifdef ORCA
ASFLAGS += -DORCA
CCFLAGS += -DORCA
CXXFLAGS += -DORCA
endif
# ---------------------------------------------------------------------------- #
ifeq ($(PROCESSOR), gekko)
GEKKO = TRUE
ASFLAGS += -DGEKKO
CCFLAGS += -DGEKKO
CXXFLAGS += -DGEKKO
endif
# ---------------------------------------------------------------------------- #
ifdef GX_REV
ASFLAGS += -DGX_REV=$(GX_REV)
CCFLAGS += -DGX_REV=$(GX_REV)
CXXFLAGS += -DGX_REV=$(GX_REV)
endif
# ---------------------------------------------------------------------------- #
ifeq ($(CONFIGURATION), DEBUG)
ASFLAGS += -g
CCFLAGS += -g
CXXFLAGS += -g
LDFLAGS += -g
endif
# ---------------------------------------------------------------------------- #
BUGFLAGS = $(addprefix -D, $(BUGLIST))
ASFLAGS += $(BUGFLAGS)
CCFLAGS += $(BUGFLAGS)
CXXFLAGS += $(BUGFLAGS)
# ---------------------------------------------------------------------------- #
LIB_SUFFIX := .a
ELF_SUFFIX := .elf
DOL_SUFFIX := .dol
PLF_SUFFIX := .plf
PREPLF_SUFFIX := .preplf
REL_SUFFIX := .rel
STR_SUFFIX := .str
LCF_SUFFIX := .lcf
LST_SUFFIX := .lst
MAP_SUFFIX := .map
ifeq ($(CONFIGURATION), DEBUG)
LIB_SUFFIX := $(addprefix D,$(LIB_SUFFIX))
ELF_SUFFIX := $(addprefix D,$(ELF_SUFFIX))
DOL_SUFFIX := $(addprefix D,$(DOL_SUFFIX))
PLF_SUFFIX := $(addprefix D,$(PLF_SUFFIX))
PREPLF_SUFFIX := $(addprefix D,$(PREPLF_SUFFIX))
REL_SUFFIX := $(addprefix D,$(REL_SUFFIX))
STR_SUFFIX := $(addprefix D,$(STR_SUFFIX))
LCF_SUFFIX := $(addprefix D,$(LCF_SUFFIX))
LST_SUFFIX := $(addprefix D,$(LST_SUFFIX))
MAP_SUFFIX := $(addprefix D,$(MAP_SUFFIX))
endif
DEP_SUFFIX := .d
OBJ_SUFFIX := .o
# ---------------------------------------------------------------------------- #
ASFLAGS += -nodefaults -proc $(PROCESSOR) -D$(PLATFORM)
LDFLAGS += -nodefaults -fp hardware -unused -map ${@:$(ELF_SUFFIX)=$(MAP_SUFFIX)} -lcf linker.lcf
ARFLAGS += -nodefaults -xm l
CCFLAGS += \
-nodefaults -proc $(PROCESSOR) -D$(PLATFORM) \
-align powerpc -enum int -multibyte -MMD -rtti off \
-char unsigned -fp hardware -Cpp_exceptions off
CXXFLAGS += \
-nodefaults -proc $(PROCESSOR) -D$(PLATFORM) \
-align powerpc -enum int -multibyte -MMD -rtti off \
-char unsigned -fp hardware -Cpp_exceptions off
################################################################################
#
# WARNINGS & OPTIMIZATIONS
#
################################################################################
WARNINGS = \
-w all, \
nonotused, \
noimplicit, \
nounusedarg, \
nonotinlined
CCFLAGS += $(WARNINGS)
CXXFLAGS += $(WARNINGS)
# ---------------------------------------------------------------------------- #
ifeq ($(CONFIGURATION), DEBUG)
OPTIMIZATIONS = \
-opt off \
-inline off
else
OPTIMIZATIONS = \
-opt level=1, peephole \
-inline off, auto
endif
CCFLAGS += $(OPTIMIZATIONS)
CXXFLAGS += $(OPTIMIZATIONS)
################################################################################
#
# GLOBAL PATHS
#
################################################################################
ROOT_PATH := $(realpath .)
SRC_ROOT := $(ROOT_PATH)/source
# ---------------------------------------------------------------------------- #
ifdef DOLPHIN_ROOT
SDK_PATH := $(subst $(space),\$(space),$(subst \,/,$(DOLPHIN_ROOT)))
else
SDK_PATH := /dolphin
endif
SDK_LIB_PATH := $(SDK_PATH)/$(PLATFORM)/lib
# ---------------------------------------------------------------------------- #
ifdef MUSYX_ROOT
MUSYX_PATH := $(subst $(space),\$(space),$(subst \,/,$(MUSYX_ROOT)))
else
MUSYX_PATH := /MusyXSDK
endif
# ---------------------------------------------------------------------------- #
ifdef HVQ_ROOT
HVQ_PATH := $(subst $(space),\$(space),$(subst \,/,$(HVQ_ROOT)))
else
HVQ_PATH := /HVQM4
endif
# ---------------------------------------------------------------------------- #
MW_CW_PATH := $(subst $(space),\$(space),$(subst \,/,$(CWFOLDER)))
AMC_DDK_PATH := $(subst $(space),\$(space),$(subst \,/,$(AMCDDKBIN)))
ODEMU_SDK_PATH := $(subst $(space),\$(space),$(subst \,/,$(ODEMUSDKBIN)))
MW_BIN_PATH := $(MW_CW_PATH)/PowerPC_EABI_TOOLS/Command_Line_Tools
MW_LIB_PATH := $(MW_CW_PATH)/PowerPC_EABI_Support
# ---------------------------------------------------------------------------- #
BUILD_ROOT := $(ROOT_PATH)/build/$(CONFIGURATION)-$(PLATFORM)
BIN_ROOT := $(BUILD_ROOT)/bin
DEP_ROOT := $(BUILD_ROOT)/dep
OBJ_ROOT := $(BUILD_ROOT)/obj
# ---------------------------------------------------------------------------- #
AS := $(MW_BIN_PATH)/mwasmeppc.exe
CC := $(MW_BIN_PATH)/mwcceppc.exe
CXX := $(MW_BIN_PATH)/mwcceppc.exe
LD := $(MW_BIN_PATH)/mwldeppc.exe
AR := $(MW_BIN_PATH)/mwldeppc.exe
################################################################################
#
# LIBRARIES
#
################################################################################
# dolphin sdk
LDFLAGS += -lr $(SDK_LIB_PATH)
# metroworks
LDFLAGS += -lr $(MW_LIB_PATH)
# project libraries
LDFLAGS += -lr $(BIN_ROOT)
# ---------------------------------------------------------------------------- #
MW_LIBS = \
Runtime.PPCEABI.H.a \
MSL_C.PPCEABI.bare.H.a
ifdef TRK_INTEGRATION
CCFLAGS += -DTRK_INTEGRATION
CXXFLAGS += -DTRK_INTEGRATION
MW_LIBS += TRK_MINNOW_DOLPHIN.a
ifdef ODEMUSDKBIN
LDFLAGS += -L$(realpath $(ODEMU_SDK_PATH)/../lib)
TRK_LIBS += OdemuExi2.a
endif
ifdef AMCDDKBIN
LDFLAGS += -L$(realpath $(AMC_DDK_PATH)/../lib)
TRK_LIBS += AmcExi2.a
endif
ifdef AMCDDKBIN
TRK_LIBS += amcnotstub$(LIB_SUFFIX)
else
TRK_LIBS += amcstubs$(LIB_SUFFIX)
endif
ifdef ODEMUSDKBIN
TRK_LIBS += odenotstub$(LIB_SUFFIX)
else
TRK_LIBS += odemustubs$(LIB_SUFFIX)
endif
endif
# ---------------------------------------------------------------------------- #
SDK_LIBS = \
base$(LIB_SUFFIX) \
db$(LIB_SUFFIX) \
os$(LIB_SUFFIX) \
mtx$(LIB_SUFFIX) \
dvd$(LIB_SUFFIX) \
vi$(LIB_SUFFIX) \
pad$(LIB_SUFFIX) \
ai$(LIB_SUFFIX) \
ar$(LIB_SUFFIX) \
dsp$(LIB_SUFFIX) \
card$(LIB_SUFFIX) \
gx$(LIB_SUFFIX) \
$(TRK_LIBS) \
gd$(LIB_SUFFIX) \
si$(LIB_SUFFIX) \
exi$(LIB_SUFFIX) \
musyx$(LIB_SUFFIX)
################################################################################
#
# INCLUDES
#
################################################################################
SYSTEM_INCLUDES = \
-I$(SDK_PATH)/include \
-ir $(MW_CW_PATH)/PowerPC_EABI_Support/MSL/MSL_C \
-ir $(MW_CW_PATH)/PowerPC_EABI_Support/MSL/MSL_C++ \
-I$(MW_CW_PATH)/PowerPC_EABI_Support/Runtime/Inc
# ---------------------------------------------------------------------------- #
USER_INCLUDES = \
-I$(SRC_ROOT)
# ---------------------------------------------------------------------------- #
INCLUDES = $(USER_INCLUDES) -i- $(SYSTEM_INCLUDES)
# ---------------------------------------------------------------------------- #
CCFLAGS += -nosyspath
CXXFLAGS += -nosyspath
################################################################################
#
# PROJECTS
#
################################################################################
PROJECTS = \
nddemo
# ---------------------------------------------------------------------------- #
# this rule should always be the first so as to be default
build: $(PROJECTS)
clean:
@echo Cleaning build directories...
@rm -rf $(ROOT_PATH)/build
@rm -rf $(BIN_ROOT)
@rm -rf $(DEP_ROOT)
@rm -rf $(OBJ_ROOT)
@echo Done.
# ---------------------------------------------------------------------------- #
include $(addprefix $(SRC_ROOT)/, $(addsuffix .make,$(PROJECTS)))
# ---------------------------------------------------------------------------- #