summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2019-07-03 09:30:05 -0400
committerPikalaxALT <pikalaxalt@gmail.com>2019-07-03 09:30:05 -0400
commitf9c6d3bbb80fa8eba8122c3af0b583cee3b1dfc1 (patch)
tree102220b878f621275136708e6b40bb56063d6c82
parent48d2923bc693a41ec9b7b9fad2728262415c2cd7 (diff)
Link modern libs and allow custom toolchain
-rw-r--r--Makefile24
-rw-r--r--ld_script.txt105
2 files changed, 76 insertions, 53 deletions
diff --git a/Makefile b/Makefile
index 115e7c4bd..de45667f3 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,12 @@
+TOOLCHAIN ?= $(DEVKITARM)
+ifneq (,$(wildcard $(TOOLCHAIN)/base_tools))
include $(DEVKITARM)/base_tools
+else
+PREFIX := $(TOOLCHAIN)/bin/arm-none-eabi-
+OBJCOPY := $(PREFIX)objcopy
+CC := $(PREFIX)gcc
+AS := $(PREFIX)as
+endif
include config.mk
ifeq ($(OS),Windows_NT)
@@ -11,7 +19,6 @@ endif
#### Tools ####
SHELL := /bin/bash -o pipefail
-AS := $(PREFIX)as
ifeq ($(MODERN),0)
CC1 := tools/agbcc/bin/agbcc$(EXE)
else
@@ -19,7 +26,6 @@ CC1 := $(shell $(PREFIX)gcc --print-prog-name=cc1)
endif
CPP := $(PREFIX)cpp
LD := $(PREFIX)ld
-OBJCOPY := $(PREFIX)objcopy
SHA1SUM := sha1sum -c
GBAGFX := tools/gbagfx/gbagfx$(EXE)
RSFONT := tools/rsfont/rsfont$(EXE)
@@ -56,9 +62,16 @@ ALL_OBJECTS := $(C_OBJECTS) $(ASM_OBJECTS)
SUBDIRS := $(sort $(dir $(ALL_OBJECTS)))
-LIBC := tools/agbcc/lib/libc.a
-LIBGCC := tools/agbcc/lib/libgcc.a
-LDFLAGS := -L ../../tools/agbcc/lib -lgcc -lc
+GCC_VER = $(shell $(CC) -dumpversion)
+
+ifeq ($(MODERN),0)
+LIBDIRS := ../../tools/agbcc/lib
+else
+LIBDIRS := \
+ $(TOOLCHAIN)/lib/gcc/arm-none-eabi/$(GCC_VER)/thumb \
+ $(TOOLCHAIN)/arm-none-eabi/lib/thumb
+endif
+LDFLAGS := $(LIBDIRS:%=-L %) -lgcc -lc
LD_SCRIPT := $(BUILD_DIR)/ld_script.ld
@@ -149,6 +162,7 @@ tools:
tidy:
$(RM) $(ALL_BUILDS:%=poke%{.gba,.elf,.map})
+ $(RM) $(MODERN_BUILDS:%=poke%{.gba,.elf,.map})
$(RM) -r build
$(ROM): %.gba: %.elf
diff --git a/ld_script.txt b/ld_script.txt
index 66acb7c7a..f272dc63c 100644
--- a/ld_script.txt
+++ b/ld_script.txt
@@ -402,54 +402,63 @@ SECTIONS {
src/libs/agb_flash_mx.o(.text);
src/libs/siirtc.o(.text);
src/libs/libagbsyscall.o(.text);
- *libgcc.a:_call_via_rX.o(.text);
- *libgcc.a:_divsi3.o(.text);
- *libgcc.a:_dvmd_tls.o(.text);
- *libgcc.a:_fixunsdfsi.o(.text);
- *libgcc.a:_fixunssfsi.o(.text);
- *libgcc.a:_modsi3.o(.text);
- *libgcc.a:_muldi3.o(.text);
- *libgcc.a:_udivdi3.o(.text);
- *libgcc.a:_udivsi3.o(.text);
- *libgcc.a:_umodsi3.o(.text);
- *libgcc.a:dp-bit.o(.text);
- *libgcc.a:fp-bit.o(.text);
- *libgcc.a:_lshrdi3.o(.text);
- *libgcc.a:_negdi2.o(.text);
- *libc.a:memcpy.o(.text);
- *libc.a:memset.o(.text);
- *libc.a:strcmp.o(.text);
- *libc.a:vfprintf.o(.text);
- *libc.a:vsprintf.o(.text);
- *libc.a:fvwrite.o(.text);
- *libc.a:locale.o(.text);
- *libc.a:findfp.o(.text);
- *libc.a:fflush.o(.text);
- *libc.a:wsetup.o(.text);
- *libc.a:mbtowc_r.o(.text);
- *libc.a:s_isinf.o(.text);
- *libc.a:s_isnan.o(.text);
- *libc.a:memchr.o(.text);
- *libc.a:strlen.o(.text);
- *libc.a:dtoa.o(.text);
- *libc.a:memmove.o(.text);
- *libc.a:stdio.o(.text);
- *libc.a:mprec.o(.text);
- *libc.a:mallocr.o(.text);
- *libc.a:fwalk.o(.text);
- *libc.a:freer.o(.text);
- *libc.a:makebuf.o(.text);
- *libc.a:readr.o(.text);
- *libc.a:writer.o(.text);
- *libc.a:lseekr.o(.text);
- *libc.a:closer.o(.text);
- *libc.a:callocr.o(.text);
- *libc.a:sbrkr.o(.text);
- *libc.a:mlock.o(.text);
- *libc.a:fstatr.o(.text);
- *libc.a:libcfunc.o(.text);
- *libc.a:syscalls.o(.text);
- *libc.a:errno.o(.text);
+ *libgcc.a:*_call_via_rX*.o(.text*);
+ *libgcc.a:*_divsi3*.o(.text*);
+ *libgcc.a:*_dvmd_tls*.o(.text*);
+ *libgcc.a:*_fixunsdfsi*.o(.text*);
+ *libgcc.a:*_fixunssfsi*.o(.text*);
+ *libgcc.a:*_modsi3*.o(.text*);
+ *libgcc.a:*_muldi3*.o(.text*);
+ *libgcc.a:*_udivdi3*.o(.text*);
+ *libgcc.a:*_udivsi3*.o(.text*);
+ *libgcc.a:*_umodsi3*.o(.text*);
+ *libgcc.a:*dp-bit*.o(.text);
+ *libgcc.a:*fp-bit*.o(.text);
+ *libgcc.a:*_lshrdi3*.o(.text*);
+ *libgcc.a:*_negdi2*.o(.text*);
+ *libgcc.a:*_arm_addsubdf3.o*(.text*);
+ *libgcc.a:*_arm_addsubsf3.o*(.text*);
+ *libgcc.a:*_arm_cmpsf2.o*(.text*);
+ *libgcc.a:*_arm_fixsfsi.o*(.text*);
+ *libgcc.a:*_arm_muldivdf3.o*(.text*);
+ *libgcc.a:*_arm_muldivsf3.o*(.text*);
+ *libgcc.a:*_arm_truncdfsf2.o*(.text*);
+ *libgcc.a:*_clzdi2.o*(.text*);
+ *libgcc.a:*_clzsi2.o*(.text*);
+ *libc.a:*memcpy*.o(.text*);
+ *libc.a:*memset*.o(.text*);
+ *libc.a:*strcmp*.o(.text*);
+ *libc.a:*vfprintf*.o(.text*);
+ *libc.a:*vsprintf*.o(.text*);
+ *libc.a:*fvwrite*.o(.text*);
+ *libc.a:*locale*.o(.text*);
+ *libc.a:*findfp*.o(.text*);
+ *libc.a:*fflush*.o(.text*);
+ *libc.a:*wsetup*.o(.text*);
+ *libc.a:*mbtowc_r*.o(.text*);
+ *libc.a:*s_isinf*.o(.text*);
+ *libc.a:*s_isnan*.o(.text*);
+ *libc.a:*memchr*.o(.text*);
+ *libc.a:*strlen*.o(.text*);
+ *libc.a:*dtoa*.o(.text*);
+ *libc.a:*memmove*.o(.text*);
+ *libc.a:*stdio*.o(.text*);
+ *libc.a:*mprec*.o(.text*);
+ *libc.a:*mallocr*.o(.text*);
+ *libc.a:*fwalk*.o(.text*);
+ *libc.a:*freer*.o(.text*);
+ *libc.a:*makebuf*.o(.text*);
+ *libc.a:*readr*.o(.text*);
+ *libc.a:*writer*.o(.text*);
+ *libc.a:*lseekr*.o(.text*);
+ *libc.a:*closer*.o(.text*);
+ *libc.a:*callocr*.o(.text*);
+ *libc.a:*sbrkr*.o(.text*);
+ *libc.a:*mlock*.o(.text*);
+ *libc.a:*fstatr*.o(.text*);
+ *libc.a:*libcfunc*.o(.text*);
+ *libc.a:*syscalls*.o(.text*);
+ *libc.a:*errno*.o(.text*);
src/libs/libisagbprn.o(.text);
} =0