forked from smealum/ninjhax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
158 lines (120 loc) · 5.62 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
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
OUTNAME = $(FIRMVERSION)_$(CNVERSION)_$(SPIDERVERSION)_$(ROVERSION)
SCRIPTS = "scripts"
.PHONY: directories all build/constants firm_constants/constants.txt ro_constants/constants.txt spider_constants/constants.txt cn_constants/constants.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 spider_initial_rop/spider_initial_rop.bin spider_thread0_rop/spider_thread0_rop.bin oss_cro/out_oss.cro build/ro_initial_code.bin build/ro_initial_rop.bin build/spider_code.bin
all: directories build/constants q/$(OUTNAME).png p/$(OUTNAME).bin build/cn_save_initial_loader.bin
directories:
@mkdir -p build && mkdir -p build/cro
@mkdir -p p
@mkdir -p q
q/$(OUTNAME).png: build/cn_qr_initial_loader.bin.png
@cp build/cn_qr_initial_loader.bin.png q/$(OUTNAME).png
p/$(OUTNAME).bin: build/cn_secondary_payload.bin
@cp build/cn_secondary_payload.bin p/$(OUTNAME).bin
firm_constants/constants.txt:
@cd firm_constants && make
ro_constants/constants.txt:
@cd ro_constants && make
spider_constants/constants.txt:
@cd spider_constants && make
cn_constants/constants.txt:
@cd cn_constants && make
build/constants: firm_constants/constants.txt ro_constants/constants.txt spider_constants/constants.txt cn_constants/constants.txt
@python $(SCRIPTS)/makeHeaders.py $(FIRMVERSION) $(CNVERSION) $(SPIDERVERSION) $(ROVERSION) 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: build/cn_save_initial_loader.bin build/spider_hook_rop.bin build/spider_initial_rop.bin build/spider_thread0_rop.bin build/cn_bootloader.bin
@cp build/cn_save_initial_loader.bin cn_secondary_payload/data
@cp build/spider_hook_rop.bin cn_secondary_payload/data
@cp build/spider_initial_rop.bin cn_secondary_payload/data
@cp build/spider_thread0_rop.bin cn_secondary_payload/data
@cp build/cn_bootloader.bin cn_secondary_payload/data
@cd cn_secondary_payload && make
build/cn_bootloader.bin: cn_bootloader/cn_bootloader.bin
@cp cn_bootloader/cn_bootloader.bin build
cn_bootloader/cn_bootloader.bin:
@cd cn_bootloader && make
build/spider_hook_rop.bin: spider_hook_rop/spider_hook_rop.bin
@cp spider_hook_rop/spider_hook_rop.bin build
spider_hook_rop/spider_hook_rop.bin:
@cd spider_hook_rop && make
build/spider_initial_rop.bin: spider_initial_rop/spider_initial_rop.bin
@cp spider_initial_rop/spider_initial_rop.bin build
spider_initial_rop/spider_initial_rop.bin:
@cd spider_initial_rop && make
build/spider_thread0_rop.bin: spider_thread0_rop/spider_thread0_rop.bin
@cp spider_thread0_rop/spider_thread0_rop.bin build
spider_thread0_rop/spider_thread0_rop.bin: build/oss.cro
@cd spider_thread0_rop && make
build/oss.cro: oss_cro/out_oss.cro
@cp oss_cro/out_oss.cro build
@python $(SCRIPTS)/makePatches.py $(SCRIPTS)
@python $(SCRIPTS)/fixCRRpatch.py build/out_oss.cro build/cro/patchCRR.bin
oss_cro/out_oss.cro: build/ro_initial_rop.bin build/ro_initial_code.bin build/spider_code.bin
@cd oss_cro && make
build/ro_initial_rop.bin: ro_initial_rop/ro_initial_rop.bin
@cp ro_initial_rop/ro_initial_rop.bin build
ro_initial_rop/ro_initial_rop.bin: build/constants
@cd ro_initial_rop && make
build/ro_initial_code.bin: ro_initial_code/ro_initial_code.bin
@cp ro_initial_code/ro_initial_code.bin build
ro_initial_code/ro_initial_code.bin: build/ro_command_handler.bin build/constants
@cd ro_initial_code && make
build/ro_command_handler.bin: ro_command_handler/ro_command_handler.bin
@cp ro_command_handler/ro_command_handler.bin build
ro_command_handler/ro_command_handler.bin: build/constants
@cd ro_command_handler && make
build/spider_code.bin: spider_code/spider_code.bin
@cp spider_code/spider_code.bin build
spider_code/spider_code.bin:
@cd spider_code && make
clean:
@rm -rf build/*
@cd firm_constants && make clean
@cd cn_constants && make clean
@cd ro_constants && make clean
@cd spider_constants && make clean
@cd cn_bootloader && make clean
@cd cn_qr_initial_loader && make clean
@cd cn_save_initial_loader && make clean
@cd cn_secondary_payload && make clean
@cd oss_cro && make clean
@cd ro_command_handler && make clean
@cd ro_initial_code && make clean
@cd ro_initial_rop && make clean
@cd spider_code && make clean
@cd spider_hook_rop && make clean
@cd spider_initial_rop && make clean
@cd spider_thread0_rop && make clean
@echo "all cleaned up !"