forked from raz0red/wii-mednafen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
335 lines (297 loc) · 12.9 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
#*--------------------------------------------------------------------------*#
# __ __.__.__ _____ .___ _____ #
# / \ / \__|__| / \ ____ __| _/____ _____ _/ ____\____ ____ #
# \ \/\/ / | |/ \ / \_/ __ \ / __ |/ \\__ \\ __\/ __ \ / \ #
# \ /| | / Y \ ___// /_/ | | \/ __ \| | \ ___/| | \ #
# \__/\ / |__|__\____|__ /\___ >____ |___| (____ /__| \___ >___| / #
# \/ \/ \/ \/ \/ \/ \/ \/ #
# #
# WiiMednafen by raz0red #
# Wii port of the Mednafen emulator #
# #
# [github.com/raz0red/wii-mednafen] #
# #
#----------------------------------------------------------------------------#
# #
# This program is free software; you can redistribute it and/or #
# modify it under the terms of the GNU General Public License #
# as published by the Free Software Foundation; either version 2 #
# of the License, or (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software #
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA #
# 02110-1301, USA. #
# #
#*--------------------------------------------------------------------------*#
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC)
endif
#include $(DEVKITPPC)/gamecube_rules
include $(DEVKITPPC)/wii_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET := boot
BUILD := build
DATA := \
res/fonts \
res/gfx
SOURCES := \
src/mednafen/src \
src/mednafen/src/compress \
src/mednafen/src/drivers \
src/mednafen/src/sexyal \
src/mednafen/src/sexyal/drivers \
src/mednafen/src/sound \
src/mednafen/src/string \
src/mednafen/src/trio \
src/mednafen/src/video \
src/mednafen/src/gb \
src/mednafen/src/gba \
src/mednafen/src/lynx \
src/mednafen/src/md \
src/mednafen/src/md/cart \
src/mednafen/src/md/cd \
src/mednafen/src/md/input \
src/mednafen/src/nes \
src/mednafen/src/nes/boards \
src/mednafen/src/nes/input \
src/mednafen/src/nes/ntsc \
src/mednafen/src/nes/ppu \
src/mednafen/src/ngp \
src/mednafen/src/ngp/TLCS-900h \
src/mednafen/src/pce_fast \
src/mednafen/src/pcfx \
src/mednafen/src/pcfx/input \
src/mednafen/src/sms \
src/mednafen/src/vb \
src/mednafen/src/wswan \
src/mednafen/src/hw_cpu/c68k \
src/mednafen/src/hw_cpu/v810 \
src/mednafen/src/hw_cpu/v810/fpu-new \
src/mednafen/src/hw_cpu/z80-fuse \
src/mednafen/src/hw_sound/gb_apu \
src/mednafen/src/hw_sound/pce_psg \
src/mednafen/src/hw_sound/sms_apu \
src/mednafen/src/hw_sound/ym2413 \
src/mednafen/src/hw_sound/ym2612 \
src/mednafen/src/hw_misc/arcade_card \
src/mednafen/src/hw_video/huc6270 \
src/mednafen/src/mpcdec \
src/mednafen/src/cdrom \
src/mednafen/src/tremor \
src/wii \
src/wii/emulator \
src/wii/emulator/helper \
src/wii/emulator/gb \
src/wii/emulator/gba \
src/wii/emulator/gg \
src/wii/emulator/lynx \
src/wii/emulator/md \
src/wii/emulator/nes \
src/wii/emulator/ngp \
src/wii/emulator/vb \
src/wii/emulator/pcefast \
src/wii/emulator/pcfx \
src/wii/emulator/wswan \
src/wii/emulator/sms
INCLUDES := \
wii-emucommon/include \
wii-emucommon/netprint/include \
wii-emucommon/pngu/include \
wii-emucommon/FreeTypeGX/include \
wii-emucommon/i18n/include \
wii-emucommon/sdl/SDL/include \
wii-emucommon/sdl/SDL_ttf/include \
wii-emucommon/sdl/SDL_image/include \
src/mednafen/include \
src/mednafen/include/blip \
src/mednafen/src/drivers \
src/mednafen/src/md \
src/mednafen/src/ngp \
src/mednafen/src/ngp/TLCS-900h \
src/mednafen/src/hw_sound \
src/mednafen/src/hw_misc \
src/mednafen/src/hw_cpu \
src/mednafen/src/hw_video \
src/wii \
src/wii/emulator \
src/wii/emulator/helper \
src/wii/emulator/gb \
src/wii/emulator/gba \
src/wii/emulator/gg \
src/wii/emulator/lynx \
src/wii/emulator/md \
src/wii/emulator/nes \
src/wii/emulator/ngp \
src/wii/emulator/vb \
src/wii/emulator/pcefast \
src/wii/emulator/pcfx \
src/wii/emulator/wswan \
src/wii/emulator/sms
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
#CFLAGS -Wall -DWII_NETTRACE -DWII_NETTRACE -DTRACK_UNIQUE_MSGIDS
# -fomit-frame-pointer \
# --param large-function-growth=800 \
# --param inline-unit-growth=200 \
# -Winline \
# -Wno-strict-aliasing \
CFLAGS = \
-g -O3 $(MACHDEP) $(INCLUDE) -DHAVE_CONFIG_H -DHAVE_FLOAT_H -DMEM2 -fno-strict-overflow -fsigned-char \
-Winline \
-fomit-frame-pointer \
--param large-function-growth=800 \
--param inline-unit-growth=200 \
-Wno-strict-aliasing \
-Wno-narrowing \
-DWII \
-DVB_BPP=8 \
-DWSWAN_BPP=16 \
-DGBA_BPP=16 \
-DPCE_FAST_BPP=16 \
-DNES_BPP=16 \
-DPCFX_BPP=16 \
-DMD_BPP=16 \
-DPLAYER_BPP=16
# -g
# -DWII_NETTRACE
# -DTRACK_UNIQUE_MSGIDS
# -DUSB_WIILOAD \
# -DC68K_GEN
CXXFLAGS = $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := \
-lSDL -lemucommon -ltinysmb -lfat -lwiiuse -lbte -logc -lm -lpng -lfreetype \
-lz -lwiikeyboard -lbz2
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := \
wii-emucommon/ \
wii-emucommon/sdl/SDL/lib \
wii-emucommon/sdl/SDL_ttf/lib \
wii-emucommon/sdl/SDL_image/lib
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
export LD := $(CC)
else
export LD := $(CXX)
endif
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
$(sFILES:.s=.o) $(SFILES:.S=.o)
#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD) \
-I$(LIBOGC_INC) \
-I$(DEVKITPRO)/portlibs/ppc/include \
-I$(DEVKITPRO)/portlibs/ppc/include/freetype2
#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(CURDIR)/$(dir)) \
-L$(LIBOGC_LIB) \
-L$(DEVKITPRO)/portlibs/ppc/lib
export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
#---------------------------------------------------------------------------------
run:
psoload $(TARGET).dol
#---------------------------------------------------------------------------------
reload:
psoload -r $(TARGET).dol
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).dol: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES)
#---------------------------------------------------------------------------------
# This rule links in binary data with the .jpg extension
#---------------------------------------------------------------------------------
%.jpg.o : %.jpg
#---------------------------------------------------------------------------------
@echo $(notdir $<)
$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------
# This rule links in binary data with the .png extension
#---------------------------------------------------------------------------------
%.png.o : %.png
#---------------------------------------------------------------------------------
@echo $(notdir $<)
$(bin2o)
-include $(DEPENDS)
%.ttf.o : %.ttf
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------
# This rule links in binary data
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
%.mod.o : %.mod
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------