/
Makefile
148 lines (121 loc) · 5.96 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
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
ifeq ($(strip $(CTRULIB)),)
$(error "Please set CTRULIB in your environment. export DEVKITARM=<path to>ctrulib/libctru")
endif
ifeq ($(filter $(DEVKITARM)/bin,$(PATH)),)
export PATH:=$(DEVKITARM)/bin:$(PATH)
endif
# FIRMVERSION = OLD_MEMMAP
# FIRMVERSION = NEW_MEMMAP
# CNVERSION = WEST
# CNVERSION = JPN
# ROVERSION = 1024
# ROVERSION = 2049
# ROVERSION = 3074
# ROVERSION = 4096
# SPIDERVERSION = 2050
# SPIDERVERSION = 3074
# SPIDERVERSION = 4096
export FIRMVERSION
export CNVERSION
export ROVERSION
export SPIDERVERSION
export MENUVERSION
export LOADROPBIN
export OTHERAPP
PAYLOAD_SRCPATH := build/cn_secondary_payload.bin
ROPBIN_CMD0 :=
ROPBIN_CMD1 :=
ifneq ($(strip $(LOADROPBIN)),)
ROPBIN_CMD0 := @cp build/menu_ropbin.bin cn_secondary_payload/data/
ROPBIN_CMD1 := @cp menu_payload/menu_ropbin.bin build/
endif
OUTNAME = $(FIRMVERSION)_$(CNVERSION)_$(MENUVERSION)
QRCODE_TARGET0 := q/$(OUTNAME).png
QRCODE_TARGET1 := build/cn_save_initial_loader.bin
QRCODE_TARGET1_CMD := @cp $(QRCODE_TARGET1) cn_secondary_payload/data/
ifneq ($(strip $(OTHERAPP)),)
PAYLOAD_SRCPATH := cn_secondary_payload/cn_secondary_payload.bin
QRCODE_TARGET0 :=
QRCODE_TARGET1 :=
QRCODE_TARGET1_CMD :=
endif
SCRIPTS = "scripts"
.PHONY: directories all menu_ropdb build/constants firm_constants/constants.txt cn_constants/constants.txt menu_ropdb/ropdb.txt cn_qr_initial_loader/cn_qr_initial_loader.bin.png cn_save_initial_loader/cn_save_initial_loader.bin cn_secondary_payload/cn_secondary_payload.bin cn_bootloader/cn_bootloader.bin menu_payload/menu_payload_regionfree.bin menu_payload/menu_payload_loadropbin.bin menu_payload/menu_ropbin.bin
all: directories build/constants $(QRCODE_TARGET0) p/$(OUTNAME).bin $(QRCODE_TARGET1)
directories:
@mkdir -p build && mkdir -p build/cro
@mkdir -p p
@mkdir -p q
menu_ropdb:
@mkdir -p menu_ropdb/11272
@mkdir -p menu_ropdb/12288
@mkdir -p menu_ropdb/13330
@mkdir -p menu_ropdb/15360
@mkdir -p menu_ropdb/16404
@mkdir -p menu_ropdb/17415
@mkdir -p menu_ropdb/19456
@mkdir -p menu_ropdb/20480_usa
@echo building ropDB for menu version 11272...
@python scripts/portRopDb.py menu_17415_code.bin menu_11272_code.bin 0x00100000 menu_ropdb/17415_proto/ropdb.txt menu_ropdb/11272/ropdb.txt
@echo building ropDB for menu version 12288...
@python scripts/portRopDb.py menu_17415_code.bin menu_12288_code.bin 0x00100000 menu_ropdb/17415_proto/ropdb.txt menu_ropdb/12288/ropdb.txt
@echo building ropDB for menu version 13330...
@python scripts/portRopDb.py menu_17415_code.bin menu_13330_code.bin 0x00100000 menu_ropdb/17415_proto/ropdb.txt menu_ropdb/13330/ropdb.txt
@echo building ropDB for menu version 15360...
@python scripts/portRopDb.py menu_17415_code.bin menu_15360_code.bin 0x00100000 menu_ropdb/17415_proto/ropdb.txt menu_ropdb/15360/ropdb.txt
@echo building ropDB for menu version 16404...
@python scripts/portRopDb.py menu_17415_code.bin menu_16404_code.bin 0x00100000 menu_ropdb/17415_proto/ropdb.txt menu_ropdb/16404/ropdb.txt
@echo building ropDB for menu version 17415...
@python scripts/portRopDb.py menu_17415_code.bin menu_17415_code.bin 0x00100000 menu_ropdb/17415_proto/ropdb.txt menu_ropdb/17415/ropdb.txt
@echo building ropDB for menu version 19456...
@python scripts/portRopDb.py menu_17415_code.bin menu_19456_code.bin 0x00100000 menu_ropdb/17415_proto/ropdb.txt menu_ropdb/19456/ropdb.txt
@echo building ropDB for menu version 20480_usa...
@python scripts/portRopDb.py menu_17415_code.bin menu_20480_usa_code.bin 0x00100000 menu_ropdb/17415_proto/ropdb.txt menu_ropdb/20480_usa/ropdb.txt
q/$(OUTNAME).png: build/cn_qr_initial_loader.bin.png
@cp build/cn_qr_initial_loader.bin.png q/$(OUTNAME).png
p/$(OUTNAME).bin: $(PAYLOAD_SRCPATH)
@cp $(PAYLOAD_SRCPATH) p/$(OUTNAME).bin
firm_constants/constants.txt:
@cd firm_constants && make
cn_constants/constants.txt:
@cd cn_constants && make
menu_ropdb/ropdb.txt:
@cd menu_ropdb && make
build/constants: firm_constants/constants.txt cn_constants/constants.txt menu_ropdb/ropdb.txt
@python $(SCRIPTS)/makeHeaders.py $(FIRMVERSION) $(CNVERSION) $(SPIDERVERSION) $(ROVERSION) $(MENUVERSION) build/constants $^
build/cn_qr_initial_loader.bin.png: cn_qr_initial_loader/cn_qr_initial_loader.bin.png
@cp cn_qr_initial_loader/cn_qr_initial_loader.bin.png build
cn_qr_initial_loader/cn_qr_initial_loader.bin.png:
@cd cn_qr_initial_loader && make
build/cn_save_initial_loader.bin: cn_save_initial_loader/cn_save_initial_loader.bin
@cp cn_save_initial_loader/cn_save_initial_loader.bin build
cn_save_initial_loader/cn_save_initial_loader.bin:
@cd cn_save_initial_loader && make
build/cn_secondary_payload.bin: cn_secondary_payload/cn_secondary_payload.bin
@python $(SCRIPTS)/blowfish.py cn_secondary_payload/cn_secondary_payload.bin build/cn_secondary_payload.bin scripts
cn_secondary_payload/cn_secondary_payload.bin: $(QRCODE_TARGET1) build/menu_payload_regionfree.bin build/menu_payload_loadropbin.bin build/menu_ropbin.bin
@mkdir -p cn_secondary_payload/data
$(QRCODE_TARGET1_CMD)
@cp build/menu_payload_regionfree.bin cn_secondary_payload/data/
@cp build/menu_payload_loadropbin.bin cn_secondary_payload/data/
$(ROPBIN_CMD0)
@cd cn_secondary_payload && make
build/menu_payload_regionfree.bin build/menu_payload_loadropbin.bin build/menu_ropbin.bin: menu_payload/menu_payload_regionfree.bin menu_payload/menu_payload_loadropbin.bin menu_payload/menu_ropbin.bin
@cp menu_payload/menu_payload_regionfree.bin build/
@cp menu_payload/menu_payload_loadropbin.bin build/
$(ROPBIN_CMD1)
menu_payload/menu_payload_regionfree.bin menu_payload/menu_payload_loadropbin.bin menu_payload/menu_ropbin.bin:
@cd menu_payload && make
clean:
@rm -rf build/*
@cd firm_constants && make clean
@cd cn_constants && make clean
@cd menu_ropdb && make clean
@cd cn_qr_initial_loader && make clean
@cd cn_save_initial_loader && make clean
@cd cn_secondary_payload && make clean
@cd menu_payload && make clean
@echo "all cleaned up !"