forked from b1l1s/2xrsa
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
74 lines (55 loc) · 1.99 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
rwildcard = $(foreach d, $(wildcard $1*), $(filter $(subst *, %, $2), $d) $(call rwildcard, $d/, $2))
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
include $(DEVKITARM)/3ds_rules
CC := arm-none-eabi-gcc
AS := arm-none-eabi-as
LD := arm-none-eabi-ld
OC := arm-none-eabi-objcopy
dir_source := source
dir_arm9 := arm9
dir_arm11_firmlaunch_stub := arm11_firmlaunch_stub
dir_build := build
dir_out := bin
ASFLAGS := -mcpu=mpcore -mlittle-endian
CFLAGS := -Wall -Wextra -MMD -MP -marm -mword-relocations $(ASFLAGS) -fno-builtin -std=c11 -Wno-main -Os -g -flto -fPIC -ffast-math -ffunction-sections -fdata-sections
LDFLAGS := -nostartfiles -Wl,--nmagic,--gc-sections
objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
$(call rwildcard, $(dir_source), *.s *.c)))
.PHONY: all
all: bin/arm11.bin
.PHONY: clean
clean:
@$(MAKE) -C $(dir_arm11_firmlaunch_stub) clean
@$(MAKE) -C $(dir_arm9) clean
@rm -rf $(dir_out) $(dir_build)
.PHONY: $(dir_arm9)
.PHONY: $(dir_arm11_firmlaunch_stub)
.PRECIOUS: $(dir_build)/%.bin
$(dir_out)/arm11.bin: $(dir_build)/main.bin
@mkdir -p "$(@D)"
@cp -a $(dir_build)/main.bin $@
$(dir_build)/main.bin: $(dir_build)/main.elf
@mkdir -p "$(@D)"
$(OC) -S -O binary $< $@
$(dir_build)/main.elf: $(bundled) $(objects)
@mkdir -p "$(@D)"
$(LINK.o) -T linker.ld $(OUTPUT_OPTION) $^
$(dir_build)/arm11_hook.bin: $(dir_arm11_hook)
@mkdir -p "$(@D)"
@$(MAKE) -C $<
$(dir_build)/arm11_firmlaunch_stub.bin: $(dir_arm11_firmlaunch_stub)
@mkdir -p "$(@D)"
@$(MAKE) -C $<
$(dir_build)/arm9.bin: $(dir_arm9) $(dir_build)/arm11_firmlaunch_stub.bin
@mkdir -p "$(@D)"
@$(MAKE) -C $<
$(dir_build)/%.o: $(dir_source)/%.c $(dir_build)/arm9.bin
@mkdir -p "$(@D)"
$(COMPILE.c) $(OUTPUT_OPTION) $<
$(dir_build)/%.o: $(dir_source)/%.s $(dir_build)/arm9.bin
@mkdir -p "$(@D)"
$(COMPILE.s) $(OUTPUT_OPTION) $<
include $(call rwildcard, $(dir_build), *.d)