This repository has been archived on 2022-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
Luma3DS-3GX/Makefile

104 lines
3.1 KiB
Makefile
Raw Normal View History

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
name := AuReiNand
version := $(shell git describe --abbrev=0 --tags)
2015-08-05 03:57:37 +02:00
dir_source := source
dir_patches := patches
dir_loader := loader
dir_mset := CakeHax
dir_ninjhax := CakeBrah
dir_build := build
dir_out := out
2015-08-05 03:57:37 +02:00
ASFLAGS := -mlittle-endian -mcpu=arm946e-s -march=armv5te
CFLAGS := -Wall -Wextra -MMD -MP -marm $(ASFLAGS) -fno-builtin -fshort-wchar -std=c11 -Wno-main -O2 -ffast-math -DCONFIG_TITLE="\"$(name) $(version) configuration\""
FLAGS := name=$(name).dat dir_out=$(abspath $(dir_out)) ICON=$(abspath icon.png) APP_DESCRIPTION="Noob-friendly 3DS CFW." APP_AUTHOR="Reisyukaku/Aurora Wright" --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-03-23 15:01:28 +01:00
all: launcher a9lh ninjhax
2015-08-05 03:57:37 +02:00
.PHONY: launcher
2016-03-24 00:11:02 +01:00
launcher: $(dir_out)/$(name).dat
2015-08-05 12:31:17 +02:00
.PHONY: a9lh
a9lh: $(dir_out)/arm9loaderhax.bin
2015-08-05 12:31:17 +02:00
.PHONY: ninjhax
ninjhax: $(dir_out)/3ds/$(name)
2015-08-05 03:57:37 +02:00
2016-03-24 00:11:02 +01:00
.PHONY: release
release: $(dir_out)/$(name).zip
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
2016-03-10 14:58:11 +01:00
@rm -rf $(dir_out) $(dir_build)
@$(MAKE) -C $(dir_loader) clean
2015-08-05 03:57:37 +02:00
$(dir_out):
@mkdir -p "$(dir_out)/aurei/payloads"
$(dir_out)/$(name).dat: $(dir_build)/main.bin $(dir_out)
2015-08-05 03:57:37 +02:00
@$(MAKE) $(FLAGS) -C $(dir_mset) launcher
@dd if=$(dir_build)/main.bin of=$@ bs=512 seek=144
$(dir_out)/arm9loaderhax.bin: $(dir_build)/main.bin $(dir_out)
@cp -av $(dir_build)/main.bin $@
$(dir_out)/3ds/$(name): $(dir_out)
@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-03-24 00:11:02 +01:00
$(dir_out)/$(name).zip: launcher a9lh ninjhax
@cd $(dir_out) && zip -9 -r $(name) *
$(dir_build)/patches.h: $(dir_patches)/emunand.s $(dir_patches)/reboot.s
@mkdir -p "$(dir_build)"
2016-02-08 03:37:03 +01:00
@armips $<
@armips $(word 2,$^)
@mv emunand.bin reboot.bin $(dir_build)
@bin2c -o $@ -n emunand $(dir_build)/emunand.bin -n reboot $(dir_build)/reboot.bin
$(dir_build)/loader.h: $(dir_loader)/Makefile
@$(MAKE) -C $(dir_loader)
@mv $(dir_loader)/loader.bin $(dir_build)
@bin2c -o $@ -n loader $(dir_build)/loader.bin
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 $(dir_build)/patches.h $(dir_build)/loader.h
2015-08-05 03:57:37 +02:00
@mkdir -p "$(@D)"
$(COMPILE.c) $(OUTPUT_OPTION) $<
$(dir_build)/%.o: $(dir_source)/%.s
@mkdir -p "$(@D)"
$(COMPILE.s) $(OUTPUT_OPTION) $<
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)