AdaCasio/build-gcc.sh
2026-04-05 22:21:03 +02:00

65 lines
1.8 KiB
Bash
Executable file

#!/usr/bin/env bash
set -e
# Definitions
ADACASIO_BINUTILS_VERSION="2.46.0"
ADACASIO_GCC_VERSION="15.2.0"
ADACASIO_BINUTILS_URL="https://ftp.gnu.org/gnu/binutils/binutils-$ADACASIO_BINUTILS_VERSION.tar.gz"
ADACASIO_GCC_URL="https://ftp.gnu.org/gnu/gcc/gcc-15.2.0/gcc-$ADACASIO_GCC_VERSION.tar.gz"
ADACASIO_PREFIX="$(pwd)/sysroot"
ADACASIO_TARGET="sh-elf"
# Install dependencies
# For now I have only tested Fedora 43. YMMV
sudo -i
dnf install mg
dnf upgrade
dnf install @c-development gnat gprbuild gmp-devel mpfr-devel libmpc-devel git
# prepare configure and build enviornment
wget -O binutils.tar.gz $ADACASIO_BINUTILS_URL
wget -O gcc.tar.gz $ADACASIO_GCC_URL
tar -xf binutils.tar.gz
tar -xf gcc.tar.gz
# Got the command list from https://git.planet-casio.com/Lephenixnoir/sh-elf-binutils Method 3
# Step 2. configure and build GCC and binutils
mkdir build-binutils build-gcc $ADACASIO_PREFIX
cd build-binutils
../binutils-*/configure \
--prefix="$ADACASIO_PREFIX" \
--target="sh3eb-elf" \
--with-multilib-list="m3,m4-nofpu" \
--program-prefix="$ADACASIO_TARGET-" \
--enable-libssp \
--enable-lto
make -j$(nproc)
make install-strip
# Build GCC the same way as Lephenixnoir does but also add ada
# https://git.planet-casio.com/Lephenixnoir/sh-elf-gcc
cd ../build-gcc/
../gcc-$VERSION/configure \
--prefix="$SYSROOT" \
--target="sh3eb-elf" \
--with-multilib-list="m3,m4-nofpu" \
--enable-languages="c,c++,ada" \
--disable-libada \
--without-headers \
--program-prefix="sh-elf-" \
--enable-libssp \
--enable-lto \
--enable-clocale="generic" \
--enable-libstdcxx-allocator \
--disable-threads \
--disable-libstdcxx-verbose \
--enable-cxx-flags="-fno-exceptions"
make -j$(nproc) all-gcc all-target-libgcc
make install-strip-gcc install-strip-target-libgcc
# TODO:
# install openlibm and fxlibc for C++ support later on