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

116 lines
3.3 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)/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')
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
2016-09-08 22:33:25 +02:00
dir_injector := injector
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
dir_arm11_exceptions := $(dir_exceptions)/arm11
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
LDFLAGS := -nostartfiles
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
bundled = $(dir_build)/reboot.bin.o $(dir_build)/emunand.bin.o $(dir_build)/svcGetCFWInfo.bin.o $(dir_build)/k11modules.bin.o \
$(dir_build)/injector.bin.o $(dir_build)/loader.bin.o $(dir_build)/arm9_exceptions.bin.o $(dir_build)/arm11_exceptions.bin.o
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-17 14:53:29 +02:00
all: a9lh
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
2016-09-23 02:25:37 +02:00
.PHONY: a9lh
a9lh: $(dir_out)/arm9loaderhax.bin
2015-08-05 03:57:37 +02:00
.PHONY: clean
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
2017-05-17 20:30:20 +02:00
.PRECIOUS: $(dir_build)/%.bin
2016-09-23 02:06:04 +02:00
2017-04-11 14:45:17 +02:00
.PHONY: $(dir_loader)
.PHONY: $(dir_arm9_exceptions)
.PHONY: $(dir_arm11_exceptions)
.PHONY: $(dir_injector)
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-17 20:28:46 +02:00
$(dir_out)/arm9loaderhax.bin: $(dir_build)/main.bin
@mkdir -p "$(@D)"
2016-09-23 02:06:04 +02:00
@cp -a $(dir_build)/main.bin $@
2016-09-08 19:24:10 +02:00
2016-04-14 17:10:55 +02:00
$(dir_build)/main.bin: $(dir_build)/main.elf
$(OBJCOPY) -S -O binary $< $@
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
2016-09-23 02:06:04 +02:00
$(dir_build)/%.bin.o: $(dir_build)/%.bin
@$(bin2o)
2017-05-17 20:28:46 +02:00
$(dir_build)/injector.bin: $(dir_injector)
@mkdir -p "$(@D)"
2016-09-23 18:07:45 +02:00
@$(MAKE) -C $<
2017-05-17 20:28:46 +02:00
$(dir_build)/loader.bin: $(dir_loader)
@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 $<
2017-05-17 20:28:46 +02:00
$(dir_build)/arm11_exceptions.bin: $(dir_arm11_exceptions)
@mkdir -p "$(@D)"
2016-09-23 18:07:45 +02:00
@$(MAKE) -C $<
2016-09-23 02:06:04 +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 $<
$(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\""
$(dir_build)/patches.o: CFLAGS += -DREVISION=\"$(revision)\" -DCOMMIT_HASH="0x$(commit)"
$(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) $<