-
Notifications
You must be signed in to change notification settings - Fork 62
/
butano_dka.mak
97 lines (77 loc) · 4.72 KB
/
butano_dka.mak
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#---------------------------------------------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
BN_TOOLS := $(LIBBUTANOABS)/tools
include $(DEVKITARM)/gba_rules
BN_TOOLCHAIN_CFLAGS := -DBN_EWRAM_BSS_SECTION=\".sbss\" -DBN_IWRAM_START=__iwram_start__ \
-DBN_IWRAM_TOP=__iwram_top -DBN_IWRAM_END=__fini_array_end -DBN_ROM_START=__text_start \
-DBN_ROM_END=__rom_end__ -DBN_TOOLCHAIN_TAG=\"DKA\"
BN_GRIT := grit
BN_MMUTIL := mmutil
#---------------------------------------------------------------------------------------------------------------------
# Butano custom base rules without flto:
#---------------------------------------------------------------------------------------------------------------------
include $(BN_TOOLS)/custom_base_rules.mak
#---------------------------------------------------------------------------------------------------------------------
# Butano custom .gba rule with spaces allowed:
#---------------------------------------------------------------------------------------------------------------------
%.gba: %.elf
$(SILENTCMD)$(OBJCOPY) -O binary $< $@
@echo Fixing $(notdir $@)...
$(SILENTCMD)gbafix -t"$(ROMTITLE)" -c"$(ROMCODE)" $@
#---------------------------------------------------------------------------------------------------------------------
# Butano custom link rules for avoiding issues when linking too many object files:
#---------------------------------------------------------------------------------------------------------------------
%_mb.elf:
$(SILENTMSG) Linking multiboot...
ifdef ADD_COMPILE_COMMAND
$(ADD_COMPILE_COMMAND) end
endif
@echo $(OFILES) > bn_ofiles.txt
$(SILENTCMD)$(LD) $(LDFLAGS) -specs=gba_mb.specs @bn_ofiles.txt $(LIBPATHS) $(LIBS) -o $@
%.elf:
$(SILENTMSG) Linking ROM...
ifdef ADD_COMPILE_COMMAND
$(ADD_COMPILE_COMMAND) end
endif
@echo $(OFILES) > bn_ofiles.txt
$(SILENTCMD)$(LD) $(LDFLAGS) -specs=gba.specs @bn_ofiles.txt $(LIBPATHS) $(LIBS) -o $@
#---------------------------------------------------------------------------------------------------------------------
# Options for code generation:
#---------------------------------------------------------------------------------------------------------------------
include $(BN_TOOLS)/codegen_options.mak
LDFLAGS = -gdwarf-4 $(ARCH) $(BN_NODEFAULT_LIBS) -Wl,-Map,$(notdir $*.map) $(USERLDFLAGS)
#---------------------------------------------------------------------------------------------------------------------
# Sources setup:
#---------------------------------------------------------------------------------------------------------------------
include $(BN_TOOLS)/sources_setup.mak
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------------------------------------------
# Common setup:
#---------------------------------------------------------------------------------------------------------------------
include $(BN_TOOLS)/common_setup.mak
#---------------------------------------------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------------------------------------------
# Main targets:
#---------------------------------------------------------------------------------------------------------------------
$(OUTPUT).gba : $(OUTPUT).elf
$(OUTPUT).elf : $(OFILES)
$(OFILES_SOURCES) : $(HFILES)
#---------------------------------------------------------------------------------------------------------------------
# The bin2o rule should be copied and modified for each extension used in the data directories:
#---------------------------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------------------------
# This rule links in binary data with the .bin extension:
#---------------------------------------------------------------------------------------------------------------------
%.bin.o %_bin.h : %.bin
#---------------------------------------------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-include $(DEPSDIR)/*.d
#---------------------------------------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------------------------------------