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

146 lines
4.4 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))
2016-04-08 19:52:37 +02:00
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
include $(DEVKITARM)/3ds_rules
2015-08-05 03:57:37 +02:00
CC := arm-none-eabi-gcc
AS := arm-none-eabi-as
LD := arm-none-eabi-ld
OC := arm-none-eabi-objcopy
2016-04-23 02:38:29 +02:00
name := Luma3DS
2016-05-21 22:59:14 +02:00
revision := $(shell git describe --tags --match v[0-9]* --abbrev=8 | sed 's/-[0-9]*-g/-/i')
commit := $(shell git rev-parse --short=8 HEAD)
2015-08-05 03:57:37 +02:00
dir_source := source
dir_patches := patches
dir_loader := loader
dir_arm9_exceptions := exceptions/arm9
dir_arm11_exceptions := exceptions/arm11
dir_injector := injector
dir_mset := CakeHax
dir_ninjhax := CakeBrah
dir_build := build
dir_out := out
2015-08-05 03:57:37 +02:00
2016-04-19 20:51:00 +02:00
ASFLAGS := -mcpu=arm946e-s
2016-04-11 15:53:59 +02:00
CFLAGS := -Wall -Wextra -MMD -MP -marm $(ASFLAGS) -fno-builtin -fshort-wchar -std=c11 -Wno-main -O2 -flto -ffast-math
LDFLAGS := -nostartfiles
2016-05-27 14:08:06 +02:00
FLAGS := name=$(name).dat dir_out=$(abspath $(dir_out)) ICON=$(abspath icon.png) APP_DESCRIPTION="Noob-friendly 3DS CFW." APP_AUTHOR="Aurora Wright/TuxSH" --no-print-directory
2015-08-05 03:57:37 +02:00
objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
$(call rwildcard, $(dir_source), *.s *.c)))
2015-08-05 03:57:37 +02:00
2016-09-08 18:47:13 +02:00
bundled = $(dir_build)/rebootpatch.h $(dir_build)/emunandpatch.h $(dir_build)/svcGetCFWInfopatch.h $(dir_build)/injector.h $(dir_build)/loader.h
ifeq ($(strip $(BUILD)),DEV)
CFLAGS += -DDEV
bundled += $(dir_build)/k11modulespatch.h $(dir_build)/arm9_exceptions.h $(dir_build)/arm11_exceptions.h
title := \"$(name) $(revision) (dev) configuration\"
else
title := \"$(name) $(revision) configuration\"
endif
2016-04-14 17:10:55 +02:00
2015-08-05 03:57:37 +02:00
.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
2016-05-27 16:29:39 +02:00
release: $(dir_out)/$(name)$(revision).7z
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
@$(MAKE) -C $(dir_loader) clean
@$(MAKE) -C $(dir_arm9_exceptions) clean
@$(MAKE) -C $(dir_arm11_exceptions) clean
@$(MAKE) -C $(dir_injector) clean
@rm -rf $(dir_out) $(dir_build)
2015-08-05 03:57:37 +02:00
$(dir_out):
@mkdir -p "$(dir_out)"
$(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 -a $(dir_build)/main.bin $@
$(dir_out)/3ds/$(name): $(dir_out)
@mkdir -p "$@"
@$(MAKE) $(FLAGS) -C $(dir_ninjhax)
@mv $(dir_out)/$(name).3dsx $(dir_out)/$(name).smdh $@
2016-02-08 03:37:03 +01:00
2016-05-27 16:29:39 +02:00
$(dir_out)/$(name)$(revision).7z: launcher a9lh ninjhax
2016-04-21 04:06:40 +02:00
@7z a -mx $@ ./$(@D)/*
2016-03-24 00:11:02 +01:00
2016-04-14 17:10:55 +02:00
$(dir_build)/main.bin: $(dir_build)/main.elf
$(OC) -S -O binary $< $@
$(dir_build)/main.elf: $(objects)
2016-04-19 20:51:00 +02:00
$(LINK.o) -T linker.ld $(OUTPUT_OPTION) $^
2016-04-14 17:10:55 +02:00
$(dir_build)/emunandpatch.h: $(dir_patches)/emunand.s $(dir_injector)/Makefile
@mkdir -p "$(@D)"
2016-02-08 03:37:03 +01:00
@armips $<
@bin2c -o $@ -n emunand $(@D)/emunand.bin
$(dir_build)/rebootpatch.h: $(dir_patches)/reboot.s
@mkdir -p "$(@D)"
2016-02-08 03:37:03 +01:00
@armips $<
@bin2c -o $@ -n reboot $(@D)/reboot.bin
$(dir_build)/k11modulespatch.h: $(dir_patches)/k11modules.s
@mkdir -p "$(@D)"
@armips $<
@bin2c -o $@ -n k11modules $(@D)/k11modules.bin
$(dir_build)/svcGetCFWInfopatch.h: $(dir_patches)/svcGetCFWInfo.s
@mkdir -p "$(@D)"
@armips $<
@bin2c -o $@ -n svcGetCFWInfo $(@D)/svcGetCFWInfo.bin
$(dir_build)/injector.h: $(dir_injector)/Makefile
@mkdir -p "$(@D)"
2016-09-08 18:47:13 +02:00
@$(MAKE) -C $(dir_injector) BUILD=$(BUILD)
@bin2c -o $@ -n injector $(@D)/injector.cxi
$(dir_build)/loader.h: $(dir_loader)/Makefile
@$(MAKE) -C $(dir_loader)
@bin2c -o $@ -n loader $(@D)/loader.bin
2015-08-05 03:57:37 +02:00
$(dir_build)/arm9_exceptions.h: $(dir_arm9_exceptions)/Makefile
@$(MAKE) -C $(dir_arm9_exceptions)
@bin2c -o $@ -n arm9_exceptions $(@D)/arm9_exceptions.bin
$(dir_build)/arm11_exceptions.h: $(dir_arm11_exceptions)/Makefile
@$(MAKE) -C $(dir_arm11_exceptions)
@bin2c -o $@ -n arm11_exceptions $(@D)/arm11_exceptions.bin
$(dir_build)/memory.o $(dir_build)/strings.o: CFLAGS += -O3
2016-09-08 18:47:13 +02:00
$(dir_build)/config.o: CFLAGS += -DCONFIG_TITLE="$(title)"
$(dir_build)/patches.o: CFLAGS += -DREVISION=\"$(revision)\" -DCOMMIT_HASH="0x$(commit)"
2016-04-14 17:10:55 +02:00
$(dir_build)/%.o: $(dir_source)/%.c $(bundled)
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) $<
include $(call rwildcard, $(dir_build), *.d)