Skip to content

Commit

Permalink
Install binutils alongside agbcc
Browse files Browse the repository at this point in the history
Remove the need for devkitarm
  • Loading branch information
mid-kid committed Oct 31, 2021
1 parent 1cff637 commit fc283d8
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 59 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@ gcc_arm/s-peep
gcc_arm/s-recog
gcc_arm/tree-check.h

binutils/binutils-*.tar.xz
binutils/binutils-*/
binutils/build/
30 changes: 30 additions & 0 deletions binutils/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh
set -e

version=2.37
shasum=820d9724f020a3e69cb337893a0b63c2db161dadcb0e06fc11dc29eb1e84a32c
src=binutils-$version
tarball=binutils-$version.tar.xz

checksum() {
test -f "$1" || return 1
sha="$(sha256sum "$1" | cut -d ' ' -f 1)"
test "$sha" = "$2" || return 1
return 0
}

checksum "$tarball" "$shasum" || wget -c "https://ftp.gnu.org/gnu/binutils/$tarball"
if ! checksum "$tarball" "$shasum"; then
sha256sum "$tarball" 1>&2
echo "Checksum failed!" 1>&2
rm -f "$tarball"
fi

test -d "$src" || tar xf "$tarball"
mkdir -p build
cd build
"../$src/configure" \
--prefix= \
--target=arm-none-eabi \
--disable-nls
MAKEINFO=false make -j "${NPROC:-$(nproc)}"
4 changes: 4 additions & 0 deletions binutils/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

rm -rf binutils-*/
rm -rf build
23 changes: 13 additions & 10 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
#!/bin/sh
set -e
CCOPT=
CXXOPT=

if [ ! -z "$CC" ]; then CCOPT=CC=$CC; fi
if [ ! -z "$CXX" ]; then CXXOPT=CXX=$CXX; fi
(cd binutils
./clean.sh
./build.sh
)
make -C gcc clean
make -C gcc old $CCOPT $CXXOPT
make -C gcc old
mv gcc/old_agbcc .
make -C gcc clean
make -C gcc $CCOPT $CXXOPT
make -C gcc
mv gcc/agbcc .
# not sure if the ARM compiler is the old one or the new one (-DOLD_COMPILER)
rm -f gcc_arm/config.status gcc_arm/config.cache
cd gcc_arm && ./configure --target=arm-elf --host=i386-linux-gnu && make cc1 && cd ..
( cd gcc_arm
rm -f config.status config.cache
./configure --target=arm-elf --host=i386-linux-gnu
make cc1
)
mv gcc_arm/cc1 agbcc_arm
make -C libgcc clean
make -C libgcc $CCOPT $CXXOPT
make -C libgcc
mv libgcc/libgcc.a .
make -C libc clean
make -C libc $CCOPT $CXXOPT
make -C libc
mv libc/libc.a .
2 changes: 1 addition & 1 deletion gcc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
srcdir = .
VPATH = $(srcdir)

CC = gcc
CC ?= gcc

BASE_CFLAGS = -g -std=gnu11 -Werror-implicit-function-declaration

Expand Down
17 changes: 6 additions & 11 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
#!/bin/sh
set -e
if [ "$1" != "" ]; then
mkdir -p $1/tools/agbcc
mkdir -p $1/tools/agbcc/bin
mkdir -p $1/tools/agbcc/include
mkdir -p $1/tools/agbcc/lib
cp agbcc $1/tools/agbcc/bin/
cp old_agbcc $1/tools/agbcc/bin/
cp agbcc_arm $1/tools/agbcc/bin/
cp -R libc/include $1/tools/agbcc/ #drop include, because we don't want include/include
cp ginclude/* $1/tools/agbcc/include/
cp libgcc.a $1/tools/agbcc/lib/
cp libc.a $1/tools/agbcc/lib/
dest="$(realpath "$1/tools/agbcc")"
install -Dm755 -t "$dest/bin" agbcc old_agbcc agbcc_arm
install -Dm644 -t "$dest/lib" libgcc.a libc.a
install -Dm644 -t "$dest/include" ginclude/*
cp -R libc/include "$dest/" #drop include, because we don't want include/include
make -C binutils/build DESTDIR="$dest" install
else
echo "Usage: install.sh PATH"
fi
21 changes: 3 additions & 18 deletions libc/Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
ifneq (,$(DEVKITARM))
ifneq (,$(wildcard $(DEVKITARM)/bin))
include $(DEVKITARM)/base_tools
DKA_EXISTS=1
else
DKA_EXISTS=0
endif
else
DKA_EXISTS=0
endif

ifneq ($(DKA_EXISTS),1)
PREFIX := arm-none-eabi-
export AR := $(PREFIX)ar
export AS := $(PREFIX)as
endif

SHELL := /bin/bash -o pipefail

ASFLAGS := -mcpu=arm7tdmi

CC1 := ../old_agbcc
AR := ../binutils/build/binutils/ar
AS := ../binutils/build/gas/as-new
CC1 := ../old_agbcc
CFLAGS := -O2 -fno-builtin

CPPFLAGS := -I ../ginclude -I include -nostdinc -undef \
Expand Down
23 changes: 4 additions & 19 deletions libgcc/Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
ifneq (,$(DEVKITARM))
ifneq (,$(wildcard $(DEVKITARM)/bin))
include $(DEVKITARM)/base_tools
DKA_EXISTS=1
else
DKA_EXISTS=0
endif
else
DKA_EXISTS=0
endif

ifneq ($(DKA_EXISTS),1)
PREFIX := arm-none-eabi-
export AR := $(PREFIX)ar
export AS := $(PREFIX)as
endif

CC1 = ../old_agbcc
AR := ../binutils/build/binutils/ar
AS := ../binutils/build/gas/as-new
CC1 := ../old_agbcc

libgcc.a: libgcc1.a libgcc2.a fp-bit.o dp-bit.o
$(AR) -x libgcc1.a;
Expand Down Expand Up @@ -94,4 +79,4 @@ dp-bit.c: fp-bit-base.c
.PHONY: clean

clean:
rm -f *.o *.a *.s *.i
rm -f *.o *.a *.s *.i

0 comments on commit fc283d8

Please sign in to comment.