-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
373 lines (306 loc) · 10.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
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
# SPDX-License-Identifier: CC0-1.0
#
# SPDX-FileContributor: Antonio Niño Díaz, 2023
BLOCKSDS ?= /opt/blocksds/core
BLOCKSDSEXT ?= /opt/blocksds/external
ifneq (,$(shell which python3))
PYTHON := python3
else ifneq (,$(shell which python2))
PYTHON := python2
else ifneq (,$(shell which python))
PYTHON := python
else
$(error "Python not found in PATH, please install it.")
endif
# User config
# ===========
NAME := bootstrap
GAME_TITLE := flashcard-bootstrap
GAME_SUBTITLE := kernel replacement project
GAME_AUTHOR := lifehackerhansol
GAME_ICON := icon.bmp
# DLDI and internal SD slot of DSi
# --------------------------------
# Root folder of the SD image
SDROOT := sdroot
# Name of the generated image it "DSi-1.sd" for no$gba in DSi mode
SDIMAGE := image.bin
# Source code paths
# -----------------
NITROFSDIR := # A single directory that is the root of NitroFS
# Tools
# -----
MAKE := make
RM := rm -rf
# Verbose flag
# ------------
ifeq ($(VERBOSE),1)
V :=
else
V := @
endif
# Directories
# -----------
ARM9DIR := arm9
ARM7DIR := arm7
DATA := $(CURDIR)/data
# Build artfacts
# --------------
ROM := $(NAME).nds
ROM_R4ILS := $(NAME)_r4ils.nds
ROM_GATEWAY := $(NAME)_gateway.nds
ROM_DSONE := $(NAME)_dsone.nds
ROM_R4ISDHC := $(NAME)_r4isdhc.nds
ROM_02000000 := $(NAME)_02000000.nds
ROM_02000450 := $(NAME)_02000450.nds
ROM_02000800 := $(NAME)_02000800.nds
# Targets
# -------
.PHONY: all clean dist arm9 arm9_r4isdhc arm7 dldipatch sdimage
all: $(ROM) \
_ds_menu.dat \
N5/_ds_menu.dat \
ez5sys.bin \
_boot_mp.nds \
bootme.nds \
r4i.sys \
ismat.dat \
_ds_menu.nds \
ez5isys.bin \
ACEP/_ds_menu.dat \
akmenu4.nds \
ttmenu.dat \
r4.dat \
_dsmenu.dat \
dsedgei.dat \
ezds.dat \
MAZE/_ds_menu.dat \
r4ids.cn/_ds_menu.dat \
R4iLS/_dsmenu.dat \
Gateway/_dsmenu.dat \
G003/g003menu.eng \
DSOneSDHC_DSOnei/ttmenu.dat \
scfw.sc \
r4dspro.com/_ds_menu.dat
clean:
@echo " CLEAN"
$(V)$(MAKE) -f Makefile.arm9 clean --no-print-directory
$(V)$(MAKE) -f Makefile.arm9_crt0set clean --no-print-directory
$(V)$(MAKE) -f Makefile.arm9_r4ids clean --no-print-directory
$(V)$(MAKE) -f Makefile.arm9_r4isdhc clean --no-print-directory
$(V)$(MAKE) -f Makefile.arm7 clean --no-print-directory
$(V)$(RM) $(ROM) $(ROM_02000000) $(ROM_02000450) $(ROM_02000800) $(ROM_DSONE) $(ROM_R4ILS) $(ROM_GATEWAY) $(ROM_R4ISDHC) build $(SDIMAGE)
$(V)$(RM) bootstrap bootstrap.zip \
_ds_menu.dat N5 ez5sys.bin _boot_mp.nds bootme.nds r4i.sys ismat.dat _ds_menu.nds ez5isys.bin ACEP akmenu4.nds \
ttmenu.dat r4.dat _dsmenu.dat dsedgei.dat MAZE r4ids.cn R4iLS Gateway G003 DSOneSDHC_DSOnei scfw.sc r4dspro.com ezds.dat
arm9:
$(V)+$(MAKE) -f Makefile.arm9 --no-print-directory
arm9_02000000:
$(V)+$(MAKE) -f Makefile.arm9_crt0set --no-print-directory CRT0=0x02000000
arm9_02000450:
$(V)+$(MAKE) -f Makefile.arm9_crt0set --no-print-directory CRT0=0x02000450
arm9_r4isdhc:
$(V)+$(MAKE) -f Makefile.arm9_r4isdhc
arm9_02000800:
$(V)+$(MAKE) -f Makefile.arm9_r4ids --no-print-directory
arm7:
$(V)+$(MAKE) -f Makefile.arm7 --no-print-directory
ifneq ($(strip $(NITROFSDIR)),)
# Additional arguments for ndstool
NDSTOOL_ARGS := -d $(NITROFSDIR)
# Make the NDS ROM depend on the filesystem only if it is needed
$(ROM): $(NITROFSDIR)
endif
# Combine the title strings
ifeq ($(strip $(GAME_SUBTITLE)),)
GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_AUTHOR)
else
GAME_FULL_TITLE := $(GAME_TITLE);$(GAME_SUBTITLE);$(GAME_AUTHOR)
endif
$(ROM): arm9 arm7
@echo " NDSTOOL $@"
$(V)$(BLOCKSDS)/tools/ndstool/ndstool -c $@ \
-h 0x200 \
-7 build/arm7.elf -9 build/arm9.elf \
-b $(GAME_ICON) "$(GAME_FULL_TITLE)" \
$(NDSTOOL_FAT)
$(ROM_GATEWAY): arm9 arm7
@echo " NDSTOOL $@"
$(V)$(BLOCKSDS)/tools/ndstool/ndstool -c $@ \
-h 0x200 -g "####" "##" "R4IT" \
-7 build/arm7.elf -9 build/arm9.elf \
-b $(GAME_ICON) "$(GAME_FULL_TITLE)" \
$(NDSTOOL_FAT)
$(ROM_R4ILS): arm9 arm7
@echo " NDSTOOL $@"
$(V)$(BLOCKSDS)/tools/ndstool/ndstool -c $@ \
-h 0x200 -g "####" "##" "R4XX" \
-7 build/arm7.elf -9 build/arm9.elf \
-b $(GAME_ICON) "$(GAME_FULL_TITLE)" \
$(NDSTOOL_FAT)
$(ROM_DSONE): arm9 arm7
@echo " NDSTOOL $@"
$(V)$(BLOCKSDS)/tools/ndstool/ndstool -c $@ \
-h 0x200 -g "ENG0" \
-7 build/arm7.elf -9 build/arm9.elf \
-b $(GAME_ICON) "$(GAME_FULL_TITLE)" \
$(NDSTOOL_FAT)
$(ROM_02000000): arm9_02000000 arm7
@echo " NDSTOOL $@"
$(V)$(BLOCKSDS)/tools/ndstool/ndstool -c $@ \
-h 0x200 \
-7 build/arm7.elf -9 build/arm9_0x02000000.elf \
-b $(GAME_ICON) "$(GAME_FULL_TITLE)" \
$(NDSTOOL_FAT)
$(ROM_02000450): arm9_02000450 arm7
@echo " NDSTOOL $@"
$(V)$(BLOCKSDS)/tools/ndstool/ndstool -c $@ \
-h 0x200 \
-7 build/arm7.elf -9 build/arm9_0x02000450.elf \
-b $(GAME_ICON) "$(GAME_FULL_TITLE)" \
$(NDSTOOL_FAT)
$(ROM_02000800): arm9_02000800 arm7
@echo " NDSTOOL $@"
$(V)$(BLOCKSDS)/tools/ndstool/ndstool -c $@ \
-h 0x200 \
-7 build/arm7.elf -9 build/arm9_r4ids.elf \
-b $(GAME_ICON) "$(GAME_FULL_TITLE)" \
$(NDSTOOL_FAT)
$(ROM_R4ISDHC): arm9_r4isdhc arm7
@echo " NDSTOOL $@"
$(V)$(BLOCKSDS)/tools/ndstool/ndstool -c $@ \
-h 0x200 \
-7 build/arm7.elf -9 build/arm9_r4isdhc.elf \
-b $(GAME_ICON) "$(GAME_FULL_TITLE)" \
$(NDSTOOL_FAT)
@$(V)$(BLOCKSDS)/tools/ndstool/ndstool -x $@ -9 arm9.bin -7 arm7.bin -t banner.bin -h header.bin
@$(PYTHON) resource/r4isdhc/r4isdhc.py arm9.bin new9.bin
@$(V)$(BLOCKSDS)/tools/ndstool/ndstool -c $@ -9 new9.bin -7 arm7.bin -t banner.bin -h header.bin -r9 0x02000000
@rm -rf arm9.bin new9.bin arm7.bin banner.bin header.bin
sdimage:
@echo " MKFATIMG $(SDIMAGE) $(SDROOT)"
$(V)$(BLOCKSDS)/tools/mkfatimg/mkfatimg -t $(SDROOT) $(SDIMAGE)
dldipatch: $(ROM)
@echo " DLDIPATCH $(ROM)"
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch \
$(BLOCKSDS)/sys/dldi_r4/r4tf.dldi $(ROM)
dist : all
@mkdir -p bootstrap/M3R_iTDS_R4RTS/_system_/_sys_data
@mkdir -p bootstrap/DSOneSDHC_DSOnei
@mkdir -p bootstrap/N5
@mkdir -p bootstrap/G003/system
@cp -r README.md _ds_menu.dat ez5sys.bin ttmenu.dat r4.dat _boot_mp.nds bootme.nds ismat.dat _ds_menu.nds ez5isys.bin akmenu4.nds _dsmenu.dat dsedgei.dat scfw.sc ezds.dat bootstrap
@cp -r MAZE ACEP R4iLS Gateway r4ids.cn r4dspro.com bootstrap
@cp -r resource/M3R_iTDS_R4RTS/* bootstrap/M3R_iTDS_R4RTS/
@cp -r resource/DSOneSDHC_DSOnei/* bootstrap/DSOneSDHC_DSOnei/
@cp resource/N5/_ax_menu.dat bootstrap/N5/_ax_menu.dat
@cp -r resource/G003/* bootstrap/G003/system
@cp G003/g003menu.eng bootstrap/G003/system
@cp -r DSOneSDHC_DSOnei/* bootstrap/DSOneSDHC_DSOnei/
@cp r4i.sys bootstrap/M3R_iTDS_R4RTS/_system_/_sys_data/r4i.sys
@cp N5/_ds_menu.dat bootstrap/N5/_ds_menu.dat
@cd bootstrap && zip -r bootstrap.zip *
@mv bootstrap/bootstrap.zip .
_ds_menu.dat: $(ROM)
@echo "Make original R4"
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch "DLDI/r4tfv3.dldi" $<
@./resource/r4denc/r4denc $< $@
N5/_ds_menu.dat: $(ROM)
@echo "Make N5"
@[ -d N5 ] || mkdir -p "N5"
@cp $< $@
ez5sys.bin: $(ROM)
@echo "Make EZ-Flash V"
@cp $< $@
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch DLDI/ez5h.dldi $@
_boot_mp.nds: $(ROM)
@echo "Make GBAMP"
@cp $< $@
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch DLDI/mpcf.dldi $@
r4i.sys : $(ROM)
@echo "Make M3R_iTDS_R4RTS"
@cp $< $@
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch "DLDI/m3ds.dldi" $@
ismat.dat: $(ROM)
@echo "Make iSmart Premium"
@cp $< $@
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch DLDI/mati.dldi $@
_ds_menu.nds: ismat.dat
@echo "Make r4i.cn"
@cp $< $@
ez5isys.bin: ismat.dat
@echo "Make EZ-Flash Vi"
@cp $< $@
bootme.nds: $(ROM)
@echo "Make Games n Music"
@cp $< $@
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch DLDI/gmtf.dldi $<
ACEP/_ds_menu.dat: $(ROM)
@echo "Make Ace3DS+"
@[ -d ACEP ] || mkdir -p ACEP
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch DLDI/ace3ds_sd.dldi $<
@./resource/r4denc/r4denc --key 0x4002 $< $@
scfw.sc: $(ROM_DSONE)
@echo "Make SuperCard DSONE"
@cp $< $@
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch DLDI/scds3.dldi $<
akmenu4.nds: $(ROM_02000450)
@echo "Make AK2"
@cp $< $@
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch DLDI/ak2_sd.dldi $@
r4dspro.com/_ds_menu.dat: akmenu4.nds
@echo "Make AK2 (broken CMD25)"
@[ -d r4dspro.com ] || mkdir -p r4dspro.com
@cp $< $@
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch "DLDI/ak2_sd_singlewrite.dldi" $@
ttmenu.dat: $(ROM)
@echo "Make DSTT"
@cp $< $@
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch DLDI/ttio_sdhc.dldi $@
DSOneSDHC_DSOnei/ttmenu.dat: $(ROM)
@echo "Make DSONE SDHC"
@[ -d DSOneSDHC_DSOnei ] || mkdir -p DSOneSDHC_DSOnei
@cp $< $@
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch DLDI/scdssdhc2.dldi $@
r4.dat: $(ROM_R4ISDHC)
@echo "Make R4i-SDHC"
@cp $< $@
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch DLDI/ttio_sdhc.dldi $@
_dsmenu.dat: $(ROM_02000000)
@echo "Make R4iDSN"
@cp $< $@
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch DLDI/r4idsn_sd.dldi $@
dsedgei.dat: $(ROM_02000800)
@echo "Make EDGEi"
@cp $< $@
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch DLDI/ak2_sd.dldi $@
ezds.dat: $(ROM)
@echo "Make EZ-Flash Parallel"
@cp $< $@
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch DLDI/ez5n.dldi $@
@$(PYTHON) resource/dldinoap/dldinoap.py $@
MAZE/_ds_menu.dat: $(ROM_02000000)
@echo "Make Amaze3DS/R4igold.cc Wood"
@[ -d MAZE ] || mkdir -p MAZE
@cp $< $@
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch DLDI/ak2_sd.dldi $@
r4ids.cn/_ds_menu.dat: $(ROM_02000800)
@echo "Make r4ids.cn"
@[ -d r4ids.cn ] || mkdir -p r4ids.cn
@cp $< $@
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch DLDI/ak2_sd.dldi $@
R4iLS/_dsmenu.dat: $(ROM_R4ILS)
@echo "Make R4iLS"
@[ -d R4iLS ] || mkdir -p R4iLS
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch DLDI/ace3ds_sd.dldi $<
@./resource/r4denc/r4denc --key 0x4002 $< $@
Gateway/_dsmenu.dat: $(ROM_GATEWAY)
@echo "Make GW"
@[ -d Gateway ] || mkdir -p Gateway
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch DLDI/ace3ds_sd.dldi $<
@./resource/r4denc/r4denc --key 0x4002 $< $@
G003/g003menu.eng: $(ROM_02000000)
@echo "Make GMP-Z003"
@[ -d G003 ] || mkdir -p G003
$(V)$(BLOCKSDS)/tools/dldipatch/dldipatch patch DLDI/g003.dldi $<
@./resource/dsbize/dsbize $< $@ 0x12