2015-08-05 03:57:37 +02:00
|
|
|
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
|
|
|
|
OPENSSL := openssl
|
|
|
|
|
|
|
|
PYTHON3 := python
|
|
|
|
PYTHON_VER_MAJOR := $(word 2, $(subst ., , $(shell python --version 2>&1)))
|
|
|
|
ifneq ($(PYTHON_VER_MAJOR), 3)
|
|
|
|
PYTHON3 := py -3
|
|
|
|
endif
|
|
|
|
|
2016-01-16 13:57:56 +01:00
|
|
|
name := ReiNand
|
|
|
|
|
2015-08-05 03:57:37 +02:00
|
|
|
dir_source := source
|
|
|
|
dir_data := data
|
|
|
|
dir_build := build
|
2016-01-16 13:57:56 +01:00
|
|
|
dir_mset := CakeHax
|
2015-08-05 03:57:37 +02:00
|
|
|
dir_out := out
|
|
|
|
dir_emu := emunand
|
2016-02-08 03:37:03 +01:00
|
|
|
dir_reboot := reboot
|
2016-01-16 13:57:56 +01:00
|
|
|
dir_ninjhax := CakeBrah
|
2015-08-05 03:57:37 +02:00
|
|
|
|
|
|
|
ASFLAGS := -mlittle-endian -mcpu=arm946e-s -march=armv5te
|
2016-02-19 01:29:53 +01:00
|
|
|
CFLAGS := -Wall -Wextra -MMD -MP -marm $(ASFLAGS) -fno-builtin -fshort-wchar -std=c11 -Wno-main -O2
|
2016-01-16 13:57:56 +01:00
|
|
|
FLAGS := name=$(name).dat dir_out=$(abspath $(dir_out)) ICON=$(abspath icon.png) --no-print-directory
|
2015-08-05 03:57:37 +02:00
|
|
|
|
|
|
|
objects_cfw = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
|
|
|
|
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
|
|
|
|
$(call rwildcard, $(dir_source), *.s *.c)))
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: all
|
2016-02-19 21:32:07 +01:00
|
|
|
all: launcher a9lh emunand emunando3ds reboot rebootntr ninjhax
|
2015-08-05 03:57:37 +02:00
|
|
|
|
|
|
|
.PHONY: launcher
|
2016-01-16 13:57:56 +01:00
|
|
|
launcher: $(dir_out)/$(name).dat
|
2015-08-05 12:31:17 +02:00
|
|
|
|
2016-02-19 01:29:53 +01:00
|
|
|
.PHONY: a9lh
|
|
|
|
a9lh: $(dir_out)/arm9loaderhax.bin
|
|
|
|
|
2015-08-05 12:31:17 +02:00
|
|
|
.PHONY: emunand
|
2016-02-20 15:29:32 +01:00
|
|
|
emunand: $(dir_out)/rei-n3ds/emunand/emunand.bin
|
2015-08-05 12:31:17 +02:00
|
|
|
|
2016-02-08 03:37:03 +01:00
|
|
|
.PHONY: emunando3ds
|
2016-02-19 01:29:53 +01:00
|
|
|
emunando3ds: $(dir_out)/rei-o3ds/emunand/emunand.bin
|
2016-02-08 03:37:03 +01:00
|
|
|
|
|
|
|
.PHONY: reboot
|
2016-02-20 15:29:32 +01:00
|
|
|
reboot: $(dir_out)/rei-o3ds/reboot/reboot1.bin $(dir_out)/rei-o3ds/reboot/reboot2.bin $(dir_out)/rei-o3ds/reboot/reboot190.bin
|
2016-02-08 03:37:03 +01:00
|
|
|
|
|
|
|
.PHONY: rebootntr
|
2016-02-19 01:29:53 +01:00
|
|
|
rebootntr: $(dir_out)/ntr-o3ds/reboot/reboot1.bin $(dir_out)/ntr-o3ds/reboot/reboot2.bin
|
2015-08-05 12:31:17 +02:00
|
|
|
|
|
|
|
.PHONY: ninjhax
|
2016-01-16 13:57:56 +01:00
|
|
|
ninjhax: $(dir_out)/3ds/$(name)
|
2015-08-05 03:57:37 +02:00
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
@$(MAKE) $(FLAGS) -C $(dir_mset) clean
|
2015-08-05 12:31:17 +02:00
|
|
|
@$(MAKE) $(FLAGS) -C $(dir_ninjhax) clean
|
2015-08-05 03:57:37 +02:00
|
|
|
rm -rf $(dir_out) $(dir_build)
|
|
|
|
|
2016-02-08 03:37:03 +01:00
|
|
|
$(dir_out)/$(name).dat: $(dir_build)/main.bin $(dir_out)/rei-n3ds/ $(dir_out)/rei-o3ds/
|
2015-08-05 03:57:37 +02:00
|
|
|
@$(MAKE) $(FLAGS) -C $(dir_mset) launcher
|
2015-08-06 07:17:10 +02:00
|
|
|
dd if=$(dir_build)/main.bin of=$@ bs=512 seek=144
|
2016-02-19 01:29:53 +01:00
|
|
|
|
|
|
|
$(dir_out)/arm9loaderhax.bin: $(dir_build)/main.bin $(dir_out)/rei-n3ds/ $(dir_out)/rei-o3ds/
|
2016-02-19 21:32:07 +01:00
|
|
|
@cp -av $(dir_build)/main.bin $(dir_out)/arm9loaderhax.bin
|
2016-02-19 01:29:53 +01:00
|
|
|
|
2016-01-16 13:57:56 +01:00
|
|
|
$(dir_out)/3ds/$(name):
|
|
|
|
@mkdir -p "$(dir_out)/3ds/$(name)"
|
|
|
|
@$(MAKE) $(FLAGS) -C $(dir_ninjhax)
|
|
|
|
@mv $(dir_out)/$(name).3dsx $@
|
|
|
|
@mv $(dir_out)/$(name).smdh $@
|
2016-02-08 03:37:03 +01:00
|
|
|
|
2016-02-20 15:29:32 +01:00
|
|
|
$(dir_out)/rei-n3ds/:
|
2016-02-08 03:37:03 +01:00
|
|
|
@mkdir -p "$(dir_out)/rei-n3ds"
|
|
|
|
|
2016-02-20 15:29:32 +01:00
|
|
|
$(dir_out)/rei-o3ds/:
|
2016-02-08 03:37:03 +01:00
|
|
|
@mkdir -p "$(dir_out)/rei-o3ds"
|
2015-08-05 12:31:17 +02:00
|
|
|
|
2016-02-08 03:37:03 +01:00
|
|
|
$(dir_out)/rei-n3ds/emunand/emunand.bin: $(dir_emu)/emuCode.s
|
2015-08-05 03:57:37 +02:00
|
|
|
@armips $<
|
2016-02-08 03:37:03 +01:00
|
|
|
@mkdir -p "$(dir_out)/rei-n3ds/emunand"
|
2016-02-20 15:29:32 +01:00
|
|
|
@cp -av emunand.bin $(dir_out)/rei-n3ds/emunand
|
2016-02-08 03:37:03 +01:00
|
|
|
|
2016-02-20 15:29:32 +01:00
|
|
|
$(dir_out)/rei-o3ds/emunand/emunand.bin: emunand.bin
|
2016-02-08 03:37:03 +01:00
|
|
|
@mkdir -p "$(dir_out)/rei-o3ds/emunand"
|
2016-02-20 15:29:32 +01:00
|
|
|
@mv emunand.bin $(dir_out)/rei-o3ds/emunand
|
2016-02-08 03:37:03 +01:00
|
|
|
|
|
|
|
$(dir_out)/rei-o3ds/reboot/reboot1.bin: $(dir_reboot)/rebootCode.s
|
|
|
|
@armips $<
|
|
|
|
@mkdir -p "$(dir_out)/rei-o3ds/reboot"
|
|
|
|
@mv reboot1.bin $(dir_out)/rei-o3ds/reboot
|
|
|
|
|
2016-02-19 01:29:53 +01:00
|
|
|
$(dir_out)/rei-o3ds/reboot/reboot2.bin: reboot2.bin
|
|
|
|
@cp -av reboot2.bin $(dir_out)/rei-o3ds/reboot
|
2016-02-08 03:37:03 +01:00
|
|
|
|
2016-02-20 15:29:32 +01:00
|
|
|
$(dir_out)/rei-o3ds/reboot/reboot190.bin: $(dir_reboot)/rebootCode90.s
|
|
|
|
@armips $<
|
|
|
|
@mv reboot1.bin $(dir_out)/rei-o3ds/reboot/reboot190.bin
|
|
|
|
|
2016-02-08 03:37:03 +01:00
|
|
|
$(dir_out)/ntr-o3ds/reboot/reboot1.bin: $(dir_reboot)/rebootCodeNtr.s
|
|
|
|
@armips $<
|
|
|
|
@mkdir -p "$(dir_out)/ntr-o3ds/reboot"
|
|
|
|
@mv reboot1.bin $(dir_out)/ntr-o3ds/reboot
|
|
|
|
|
2016-02-19 01:29:53 +01:00
|
|
|
$(dir_out)/ntr-o3ds/reboot/reboot2.bin: reboot2.bin
|
2016-02-08 03:37:03 +01:00
|
|
|
@mv reboot2.bin $(dir_out)/ntr-o3ds/reboot
|
2015-08-05 03:57:37 +02:00
|
|
|
|
|
|
|
$(dir_build)/main.bin: $(dir_build)/main.elf
|
|
|
|
$(OC) -S -O binary $< $@
|
|
|
|
|
|
|
|
$(dir_build)/main.elf: $(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) $<
|
2016-02-19 01:29:53 +01:00
|
|
|
|
2015-08-05 03:57:37 +02:00
|
|
|
$(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)
|