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
|
|
|
|
|
2017-06-05 02:02:04 +02:00
|
|
|
ifneq ($(strip $(shell firmtool -v 2>&1 | grep usage)),)
|
|
|
|
$(error "Please install firmtool v1.1 or greater")
|
|
|
|
endif
|
|
|
|
|
2016-11-26 18:00:17 +01:00
|
|
|
include $(DEVKITARM)/base_tools
|
2015-08-05 03:57:37 +02:00
|
|
|
|
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')
|
2017-06-07 22:13:05 +02:00
|
|
|
version_major := $(shell git describe --tags --match v[0-9]* | cut -c2- | cut -f1 -d- | cut -f1 -d.)
|
|
|
|
version_minor := $(shell git describe --tags --match v[0-9]* | cut -c2- | cut -f1 -d- | cut -f2 -d.)
|
|
|
|
version_build := $(shell git describe --tags --match v[0-9]* | cut -c2- | cut -f1 -d- | cut -f3 -d.)
|
2016-08-17 23:47:30 +02:00
|
|
|
commit := $(shell git rev-parse --short=8 HEAD)
|
2017-06-07 22:13:05 +02:00
|
|
|
is_release := 0
|
2016-01-16 13:57:56 +01:00
|
|
|
|
2017-06-05 02:02:04 +02:00
|
|
|
ifeq ($(strip $(revision)),)
|
|
|
|
revision := v0.0.0-0
|
2017-06-07 22:13:05 +02:00
|
|
|
version_major := 0
|
|
|
|
version_minor := 0
|
|
|
|
version_build := 0
|
2017-06-05 02:02:04 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(strip $(commit)),)
|
|
|
|
commit := 0
|
|
|
|
endif
|
|
|
|
|
2017-06-07 22:13:05 +02:00
|
|
|
ifeq ($(strip $(version_build)),)
|
|
|
|
version_build := 0
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(strip $(shell git describe --tags --match v[0-9]* | grep -)),)
|
|
|
|
is_release := 1
|
|
|
|
endif
|
|
|
|
|
2015-08-05 03:57:37 +02:00
|
|
|
dir_source := source
|
2016-03-23 20:23:27 +01:00
|
|
|
dir_patches := patches
|
2017-05-23 02:44:04 +02:00
|
|
|
dir_arm11 := arm11
|
2017-05-29 14:59:02 +02:00
|
|
|
dir_chainloader := chainloader
|
2016-09-08 19:24:10 +02:00
|
|
|
dir_exceptions := exceptions
|
2016-09-11 01:28:57 +02:00
|
|
|
dir_arm9_exceptions := $(dir_exceptions)/arm9
|
2017-05-29 14:59:02 +02:00
|
|
|
dir_sysmodules := sysmodules
|
|
|
|
dir_loader := $(dir_sysmodules)/loader
|
2017-06-05 02:02:04 +02:00
|
|
|
dir_rosalina := $(dir_sysmodules)/rosalina
|
2016-03-23 20:23:27 +01:00
|
|
|
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-12-03 23:22:48 +01:00
|
|
|
CFLAGS := -Wall -Wextra $(ASFLAGS) -fno-builtin -std=c11 -Wno-main -O2 -flto -ffast-math
|
2017-05-23 13:33:32 +02:00
|
|
|
LDFLAGS := -nostartfiles -Wl,--nmagic
|
2015-08-05 03:57:37 +02:00
|
|
|
|
Added region/language emulation feature, thanks to the hard work of @TuxSH
Create a "locales" folder inside aurei, and one .txt for each game, with the title id of the game. The txt must be exactly 6 bytes long: 3 characters for the region ("JPN", "USA", "EUR", "AUS", "CHN", "KOR", "TWN"), a space, and two for the language ("JP", "EN", "FR", "DE", "IT", "ES", "ZH", "KO", "NL", "PT", "RU", "TW"). You can enable the feature globally in the config menu. This should also make DLCs for foreign games work.
2016-04-14 00:46:36 +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
|
|
|
|
2017-06-05 02:02:04 +02:00
|
|
|
bundled = $(dir_build)/reboot.bin.o $(dir_build)/emunand.bin.o $(dir_build)/mmuHook.bin.o $(dir_build)/k11MainHook.bin.o $(dir_build)/svcConnectToPortInitHook.bin.o $(dir_build)/svcCustomBackdoor.bin.o\
|
|
|
|
$(dir_build)/chainloader.bin.o $(dir_build)/arm9_exceptions.bin.o
|
2017-05-23 02:44:04 +02:00
|
|
|
|
2017-06-05 02:02:04 +02:00
|
|
|
modules = $(dir_build)/loader.cxi $(dir_build)/rosalina.cxi
|
2016-09-23 02:06:04 +02:00
|
|
|
|
|
|
|
define bin2o
|
|
|
|
bin2s $< | $(AS) -o $(@)
|
|
|
|
endef
|
2016-04-14 17:10:55 +02:00
|
|
|
|
2015-08-05 03:57:37 +02:00
|
|
|
.PHONY: all
|
2017-05-18 01:05:56 +02:00
|
|
|
all: firm
|
2015-08-05 12:31:17 +02:00
|
|
|
|
2016-09-23 02:25:37 +02:00
|
|
|
.PHONY: release
|
|
|
|
release: $(dir_out)/$(name)$(revision).7z
|
2015-08-05 03:57:37 +02:00
|
|
|
|
2017-05-18 01:05:56 +02:00
|
|
|
.PHONY: firm
|
|
|
|
firm: $(dir_out)/boot.firm
|
2016-04-11 05:15:44 +02:00
|
|
|
|
2015-08-05 03:57:37 +02:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
2017-05-23 02:44:04 +02:00
|
|
|
@$(MAKE) -C $(dir_arm11) clean
|
2017-05-29 14:59:02 +02:00
|
|
|
@$(MAKE) -C $(dir_chainloader) clean
|
2016-04-26 22:06:19 +02:00
|
|
|
@$(MAKE) -C $(dir_arm9_exceptions) clean
|
2017-05-29 14:59:02 +02:00
|
|
|
@$(MAKE) -C $(dir_loader) clean
|
2017-06-05 02:02:04 +02:00
|
|
|
@$(MAKE) -C $(dir_rosalina) clean
|
Added region/language emulation feature, thanks to the hard work of @TuxSH
Create a "locales" folder inside aurei, and one .txt for each game, with the title id of the game. The txt must be exactly 6 bytes long: 3 characters for the region ("JPN", "USA", "EUR", "AUS", "CHN", "KOR", "TWN"), a space, and two for the language ("JP", "EN", "FR", "DE", "IT", "ES", "ZH", "KO", "NL", "PT", "RU", "TW"). You can enable the feature globally in the config menu. This should also make DLCs for foreign games work.
2016-04-14 00:46:36 +02:00
|
|
|
@rm -rf $(dir_out) $(dir_build)
|
2015-08-05 03:57:37 +02:00
|
|
|
|
2017-05-17 20:30:20 +02:00
|
|
|
.PRECIOUS: $(dir_build)/%.bin
|
2016-09-23 02:06:04 +02:00
|
|
|
|
2017-05-23 02:44:04 +02:00
|
|
|
.PHONY: $(dir_arm11)
|
2017-05-29 14:59:02 +02:00
|
|
|
.PHONY: $(dir_chainloader)
|
2017-04-11 14:45:17 +02:00
|
|
|
.PHONY: $(dir_arm9_exceptions)
|
2017-05-29 14:59:02 +02:00
|
|
|
.PHONY: $(dir_loader)
|
2017-06-05 02:02:04 +02:00
|
|
|
.PHONY: $(dir_rosalina)
|
2017-04-11 14:45:17 +02:00
|
|
|
|
2016-09-23 02:06:04 +02:00
|
|
|
$(dir_out)/$(name)$(revision).7z: all
|
2017-05-17 20:28:46 +02:00
|
|
|
@mkdir -p "$(@D)"
|
2016-09-23 02:06:04 +02:00
|
|
|
@7z a -mx $@ ./$(@D)/* ./$(dir_exceptions)/exception_dump_parser.py
|
|
|
|
|
2017-05-23 02:44:04 +02:00
|
|
|
$(dir_out)/boot.firm: $(dir_build)/modules.bin $(dir_build)/arm11.elf $(dir_build)/main.elf
|
|
|
|
@mkdir -p "$(@D)"
|
2017-06-05 02:02:04 +02:00
|
|
|
@firmtool build $@ -D $^ -A 0x1FF60000 -C XDMA XDMA NDMA
|
2017-05-23 02:44:04 +02:00
|
|
|
|
|
|
|
$(dir_build)/modules.bin: $(modules)
|
2017-05-17 20:28:46 +02:00
|
|
|
@mkdir -p "$(@D)"
|
2017-05-23 02:44:04 +02:00
|
|
|
cat $^ > $@
|
|
|
|
|
|
|
|
$(dir_build)/arm11.elf: $(dir_arm11)
|
|
|
|
@mkdir -p "$(@D)"
|
|
|
|
@$(MAKE) -C $<
|
2016-04-14 17:10:55 +02:00
|
|
|
|
2016-09-23 02:06:04 +02:00
|
|
|
$(dir_build)/main.elf: $(bundled) $(objects)
|
2016-04-19 20:51:00 +02:00
|
|
|
$(LINK.o) -T linker.ld $(OUTPUT_OPTION) $^
|
2016-04-14 17:10:55 +02:00
|
|
|
|
2017-05-29 14:59:02 +02:00
|
|
|
$(dir_build)/loader.cxi: $(dir_loader)
|
2017-05-17 20:28:46 +02:00
|
|
|
@mkdir -p "$(@D)"
|
2016-09-23 18:07:45 +02:00
|
|
|
@$(MAKE) -C $<
|
2016-03-08 15:13:55 +01:00
|
|
|
|
2017-06-05 02:02:04 +02:00
|
|
|
$(dir_build)/rosalina.cxi: $(dir_rosalina)
|
|
|
|
@mkdir -p "$(@D)"
|
|
|
|
@$(MAKE) -C $<
|
|
|
|
|
2017-05-23 02:44:04 +02:00
|
|
|
$(dir_build)/%.bin.o: $(dir_build)/%.bin
|
|
|
|
@$(bin2o)
|
|
|
|
|
2017-05-29 14:59:02 +02:00
|
|
|
$(dir_build)/chainloader.bin: $(dir_chainloader)
|
2017-05-17 20:28:46 +02:00
|
|
|
@mkdir -p "$(@D)"
|
2016-09-23 18:07:45 +02:00
|
|
|
@$(MAKE) -C $<
|
2015-08-05 03:57:37 +02:00
|
|
|
|
2017-05-17 20:28:46 +02:00
|
|
|
$(dir_build)/arm9_exceptions.bin: $(dir_arm9_exceptions)
|
|
|
|
@mkdir -p "$(@D)"
|
2016-09-23 18:07:45 +02:00
|
|
|
@$(MAKE) -C $<
|
2016-04-26 22:06:19 +02:00
|
|
|
|
2017-05-17 20:28:46 +02:00
|
|
|
$(dir_build)/%.bin: $(dir_patches)/%.s
|
|
|
|
@mkdir -p "$(@D)"
|
2016-09-23 02:06:04 +02:00
|
|
|
@armips $<
|
2016-08-30 21:02:45 +02:00
|
|
|
|
2016-08-30 19:48:21 +02:00
|
|
|
$(dir_build)/memory.o $(dir_build)/strings.o: CFLAGS += -O3
|
2016-09-19 14:03:55 +02:00
|
|
|
$(dir_build)/config.o: CFLAGS += -DCONFIG_TITLE="\"$(name) $(revision) configuration\""
|
2017-06-07 22:13:05 +02:00
|
|
|
$(dir_build)/patches.o: CFLAGS += -DVERSION_MAJOR="$(version_major)" -DVERSION_MINOR="$(version_minor)"\
|
|
|
|
-DVERSION_BUILD="$(version_build)" -DISRELEASE="$(is_release)" -DCOMMIT_HASH="0x$(commit)"
|
2017-05-23 02:44:04 +02:00
|
|
|
$(dir_build)/firm.o: $(dir_build)/modules.bin
|
|
|
|
$(dir_build)/firm.o: CFLAGS += -DLUMA_SECTION0_SIZE="$(shell du -b $(dir_build)/modules.bin | cut -f1)"
|
2016-04-02 17:58:06 +02:00
|
|
|
|
2017-02-23 19:07:53 +01:00
|
|
|
$(dir_build)/bundled.h: $(bundled)
|
|
|
|
@$(foreach f, $(bundled),\
|
|
|
|
echo "extern const u8" `(echo $(basename $(notdir $(f))) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> $@;\
|
|
|
|
echo "extern const u32" `(echo $(basename $(notdir $(f)))| sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> $@;\
|
|
|
|
)
|
|
|
|
|
|
|
|
$(dir_build)/%.o: $(dir_source)/%.c $(dir_build)/bundled.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) $<
|