-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathMakefile
96 lines (74 loc) · 2.83 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
rwildcard = $(foreach d, $(wildcard $1*), $(filter $(subst *, %, $2), $d) $(call rwildcard, $d/, $2))
CC := arm-none-eabi-gcc
AS := arm-none-eabi-as
LD := arm-none-eabi-ld
OC := arm-none-eabi-objcopy
name := ReiNand
dir_source := source
dir_data := data
dir_build := build
dir_cakehax := CakeHax
dir_cakebrah := CakeBrah
dir_loader := loader
dir_out := out
dir_payload := payloads
ASFLAGS := -mlittle-endian -mcpu=arm946e-s -march=armv5te
CFLAGS := -Wall -MMD -MP -O2 -marm $(ASFLAGS) -fno-builtin -fshort-wchar -std=c11 -Wno-main
FLAGS := name=$(name).dat dir_out=$(abspath $(dir_out)) ICON=$(abspath icon.png) --no-print-directory
objects_cfw = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
$(call rwildcard, $(dir_source), *.s *.c)))
.PHONY: all
all: launcher a9lh loader sighax
.PHONY: a9lh
a9lh: $(dir_out)/arm9loaderhax.bin
.PHONY: launcher
launcher: $(dir_out)/$(name).dat
.PHONY: loader
loader: $(dir_out)/rei/loader.cxi
.PHONY: clean
clean:
@$(MAKE) $(FLAGS) -C $(dir_cakehax) clean
@$(MAKE) $(FLAGS) -C $(dir_cakebrah) clean
@$(MAKE) $(FLAGS) -C $(dir_loader) clean
rm -rf $(dir_out) $(dir_build)
.PHONY: $(dir_out)/arm9loaderhax.bin
$(dir_out)/arm9loaderhax.bin: $(dir_build)/main.bin
@mkdir -p "$(dir_out)"
@cp -av $< $@
.PHONY: $(dir_out)/$(name).dat
$(dir_out)/$(name).dat: $(dir_build)/main.bin $(dir_out)/rei/ $(dir_out)/rei/patches/patches.dat
@$(MAKE) $(FLAGS) -C $(dir_cakehax) launcher
dd if=$(dir_build)/main.bin of=$@ bs=512 seek=144
$(dir_out)/rei/: $(dir_data)/firmware.bin $(dir_data)/splashTop.bin $(dir_data)/splashBot.bin
@mkdir -p "$(dir_out)/rei"
@cp -av $^ $@
$(dir_out)/rei/patches/patches.dat: $(wildcard data/patches/*.rnp)
@mkdir -p "$(dir_out)/rei/patches/"
cat $^ > $@
$(dir_out)/rei/loader.cxi: $(dir_loader)
@$(MAKE) $(FLAGS) -C $(dir_loader)
@mv $(dir_loader)/loader.cxi $(dir_out)/rei
$(dir_build)/payloads.h: $(dir_payload)/emunand.s $(dir_payload)/reboot.s
@mkdir $(dir_build)
@armips $(word 1, $^)
@armips $(word 2, $^)
@bin2c -o $@ -n emunand $(dir_build)/emunand.bin -n reboot $(dir_build)/reboot.bin
$(dir_build)/main.bin: $(dir_build)/main.elf
$(OC) -S -O binary $< $@
$(dir_build)/main.elf: $(dir_build)/payloads.h $(objects_cfw)
# FatFs requires libgcc for __aeabi_uidiv
$(CC) -nostartfiles $(LDFLAGS) -T linker.ld $(OUTPUT_OPTION) $^
$(dir_build)/%.o: $(dir_source)/%.c
@mkdir -p "$(@D)"
$(COMPILE.c) $(OUTPUT_OPTION) $<
$(dir_build)/%.o: $(dir_source)/%.s
@mkdir -p "$(@D)"
$(COMPILE.s) $(OUTPUT_OPTION) $<
$(dir_build)/fatfs/%.o: $(dir_source)/fatfs/%.c
@mkdir -p "$(@D)"
$(COMPILE.c) -mthumb -mthumb-interwork -Wno-unused-function $(OUTPUT_OPTION) $<
$(dir_build)/fatfs/%.o: $(dir_source)/fatfs/%.s
@mkdir -p "$(@D)"
$(COMPILE.s) -mthumb -mthumb-interwork $(OUTPUT_OPTION) $<
include $(call rwildcard, $(dir_build), *.d)