-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
337 lines (276 loc) · 12.1 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
#---------------------------------------------------------------------------------
# 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)/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
#---------------------------------------------------------------------------------
VERSION := 70r78.13
RELEASE := release
# to override RELEASE use: make announce RELEASE=beta
ifeq ($(findstring compat,$(VERSION)),compat)
RELEASE := release
else ifeq ($(findstring debug,$(VERSION)),debug)
RELEASE := debug
else ifeq ($(findstring c,$(VERSION)),c)
RELEASE := bugfix
else ifeq ($(findstring b,$(VERSION)),b)
RELEASE := beta
else ifeq ($(findstring a,$(VERSION)),a)
RELEASE := alpha
else ifeq ($(findstring t,$(VERSION)),t)
RELEASE := test
else ifeq ($(findstring x,$(VERSION)),x)
RELEASE := experimental
endif
BINBASE := cfg$(VERSION)
TARGET := $(BINBASE)
BUILD := build
SOURCES := source source/pngu source/libwbfs source/unzip
DATA := data
INCLUDES :=
GETTEXT := tools/gettext
UPLOAD := tools/googlecode_upload.py
GAUTH ?= -u username -w passwd
INSTDIR := ../Cfg_USB_Loader_$(VERSION)
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
DKV := $(shell $(DEVKITPPC)/bin/$(CC) --version | sed 's/^.*(devkitPPC release \([0-9]*\)).*$$/\1/;q')
PORTLIBS := $(DEVKITPRO)/portlibs/ppc
BUILD_222 := 0
ifeq ($(BUILD_222),1)
BUILD := build_222
TARGET := $(BINBASE)-222
BUILD_222_FLAG := -DBUILD_222=$(BUILD_222)
endif
BUILD_DEBUG := 0
ifeq ($(BUILD_DEBUG),1)
BUILD := build_dbg
TARGET := $(BINBASE)-dbg
BUILD_DBG_FLAG := -DBUILD_DBG=3 -DDEBUG_PATCH=1
endif
BUILD_DEBUG_PATCH := 0
ifeq ($(BUILD_DEBUG_PATCH),1)
BUILD := build_dbg_patch
TARGET := $(BINBASE)-dbg-patch
BUILD_DBG_FLAG := -DDEBUG_PATCH=1
endif
#"-g" tells the compiler to include support for the debugger
#"-Wall" tells it to warn us about all suspicious-looking code
DEBUG_OPT = -Os
#DEBUG_OPT = -g
BUILD_FLAGS = -DVERSION=$(VERSION) -DDEVKITPPCVER=$(DKV) -DCCOPT=\"$(DEBUG_OPT)\" $(BUILD_222_FLAG) $(BUILD_DBG_FLAG)
CFLAGS = $(DEBUG_OPT) -Wall $(MACHDEP) $(INCLUDE) $(BUILD_FLAGS) $(DEFINES)
CXXFLAGS = $(CFLAGS)
# start address:
# Original: 0x80a00100
# NeoGammaR4: 0x80dfff00
# cfg 33-36: 0x80c00000
# cfg 37-49: 0x80b00000
# cfg 50-..: 0x80a80000
# cfg 70r78.13-..: 0x80a50000
LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map,--section-start,.init=0x80a50000
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
#LIBS := -lmetaphrasis -lfreetype -lasnd -lpng -lz -lfat -lwiiuse -lbte -lmad -lmodplay -logc -lm -ltremor
LIBAESND=$(wildcard $(LIBOGC_LIB)/libaesnd.a)
ifneq ($(strip $(LIBAESND)),)
LAESND := -laesnd
endif
LIBS := -lgrrlib -lfat -lntfs -lext2fs -lpng -ljpeg -lwiiuse -lbte -lmad -lmodplay -lasnd -logc -lm -lz
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
#LIBDIRS := $(DEVKITPPC)/lib $(CURDIR) $(CURDIR)/lib/png $(CURDIR)/lib/freetype $(CURDIR)/lib/libfat
LIBDIRS := $(DEVKITPPC)/lib $(CURDIR) $(CURDIR)/lib/png $(CURDIR)/lib/libfat $(CURDIR)/lib/libntfs $(CURDIR)/lib/libext2fs $(CURDIR)/lib/jpeg $(CURDIR)/lib/grrlib $(CURDIR)/lib/zlib $(PORTLIBS)
#---------------------------------------------------------------------------------
# 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 PATH := $(CURDIR)/$(GETTEXT):$(PATH)
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$(LIBOGC_INC)/ogc -I$(LIBOGC_INC)/ogc/machine
#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib$(DKV) -L$(dir)/lib) \
-L$(LIBOGC_LIB)
export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) 222 debug lang all clean tags
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@echo
@echo $(CURDIR)
@echo Building $(TARGET) $(BUILD_FLAGS)
@grep _V_STR $(LIBOGC_INC)/ogc/libversion.h | cut -f2 -d'"'
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
222:
@$(MAKE) --no-print-directory BUILD_222=1
debug:
@$(MAKE) --no-print-directory BUILD_DEBUG=1
debug_patch:
@$(MAKE) --no-print-directory BUILD_DEBUG_PATCH=1
#---------------------------------------------------------------------------------
lang:
@[ -d Languages ] || mkdir -p Languages
@echo
@echo "Building Language File ($@$(VERSION).pot)"
@xgettext --sort-output --no-wrap --no-location -k -kgt -kgts -o Languages/$@$(VERSION).pot source/*.c
#---------------------------------------------------------------------------------
all: $(BUILD) 222 lang
@echo Done All
# @make --no-print-directory build
# @make --no-print-directory BUILD_222=1
# @make --no-print-directory lang
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
@rm -fr $(BUILD)_222 $(OUTPUT)-222.elf $(OUTPUT)-222.dol
@rm -fr $(BUILD)_dbg $(OUTPUT)-dbg.elf $(OUTPUT)-dbg.dol
@rm -fr $(BUILD)_dbg_patch $(OUTPUT)-dbg-patch.elf $(OUTPUT)-dbg-patch.dol
cleanall: clean
@rm -fr *.dol *.elf
#---------------------------------------------------------------------------------
run:
wiiload $(OUTPUT).dol debug=0 simple=0 home=exit gui=coverflow3d gui_style=grid gui_antialias=4 gui_compress_covers=1 music=sd://mp3 button_2=random
# wiiload $(OUTPUT).dol simple=0 device=usb cover_style=3d widescreen=1 covers_size=100,100 debug=1 music=sd://mp3 gui_font=Vera_Mono_12_Bold.png hide_game=RB7E admin_lock=1 wpreview_coords=10,100,200,0
# widescreen = [auto], 0, 1
# home = [reboot], exit, screenshot
# cover_style = [standard], 3d, disc
DATE=$(shell date +%F)
SIZE=$(shell stat -c %s $(BINBASE).dol 2>/dev/null)
SIZE_222=$(shell stat -c %s $(BINBASE)-222.dol 2>/dev/null)
define ANNOUNCE_SH
CHANGES=`sed -n '/cfg v'$(VERSION)' /,/cfg v/{/cfg v/!p}' README-CFG.txt`
echo "===== updates.txt: ====="
cat << END
release = $(VERSION) ($(RELEASE))
size = $(SIZE)
date = $(DATE)
url = http://cfg-loader.googlecode.com/files/$(BINBASE).dol
$$CHANGES
release = $(VERSION)-222 ($(RELEASE))
size = $(SIZE_222)
date = $(DATE)
url = http://cfg-loader.googlecode.com/files/$(BINBASE)-222.dol
Same as $(VERSION) but with different
default options:
ios=222-mload
END
echo "===== forum ====="
cat << END
[b]cfg v$(VERSION) ($(RELEASE))[/b]
[url="http://cfg-loader.googlecode.com/files/$(BINBASE).dol"]$(BINBASE).dol[/url]
[url="http://cfg-loader.googlecode.com/files/$(BINBASE)-222.dol"]$(BINBASE)-222.dol[/url]
[url="http://cfg-loader.googlecode.com/files/lang$(VERSION).zip"]lang$(VERSION).zip[/url]
(or online update)
[pre]Changes:
cfg v$(VERSION) ($(RELEASE))
$$CHANGES
[/pre]
END
endef
export ANNOUNCE_SH
announce:
@echo "$$ANNOUNCE_SH" | sh
DOLS := $(BINBASE)-222.dol $(BINBASE).dol
ELFS := $(BINBASE)-222.elf $(BINBASE).elf
BINS := $(ELFS) $(DOLS)
upload:
for F in $(DOLS); do echo uploading $$F ; $(UPLOAD) $(GAUTH) -p cfg-loader -s $$F $$F ; done
upload_elf:
for F in $(ELFS); do echo uploading $$F ; $(UPLOAD) $(GAUTH) -p cfg-loader -s $$F $$F ; done
upload_lang:
echo uploading Languages/lang$(VERSION).zip
$(UPLOAD) $(GAUTH) -p cfg-loader -s lang$(VERSION).zip Languages/lang$(VERSION).zip
upload_full:
echo uploading ../Cfg_USB_Loader_$(VERSION).zip
$(UPLOAD) $(GAUTH) -p cfg-loader -s Cfg_USB_Loader_$(VERSION).zip ../Cfg_USB_Loader_$(VERSION).zip
install:
cp $(BINBASE).dol $(INSTDIR)/inSDRoot/apps/USBLoader/boot.dol
-rm $(INSTDIR)/*.dol
#cp $(BINBASE)-222.dol $(INSTDIR)/
cp README-CFG.txt $(INSTDIR)/
sed -i 's/<version>.*</<version>'$(VERSION)' (release)</' $(INSTDIR)/inSDRoot/apps/USBLoader/meta.xml
sed -i 's/<release_date>.*</<release_date>'`date +%Y%m%d000000`'</' $(INSTDIR)/inSDRoot/apps/USBLoader/meta.xml
cp Languages/*.lang $(INSTDIR)/inSDRoot/usb-loader/languages
-rm $(INSTDIR)/inSDRoot/usb-loader/languages/*_miss.lang
cp Languages/lang.pot $(INSTDIR)/inSDRoot/usb-loader/languages
tags:
cd source ; ctags -R .
#---------------------------------------------------------------------------------
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)
%.png.o : %.png
@echo $(notdir $<)
@$(bin2o)
%.ttf.o : %.ttf
@echo $(notdir $<)
@$(bin2o)
%.wav.o : %.wav
@echo $(notdir $<)
@$(bin2o)
%.bin.o : %.bin
@echo $(notdir $<)
@$(bin2o)
#%.o: %.c
# @echo $(notdir $<)
# $(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -c $< -o $@
-include $(DEPENDS)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------