2020-12-30 23:03:15 +01:00
|
|
|
#! /usr/bin/env bash
|
|
|
|
|
|
|
|
binutils_version=$1
|
|
|
|
gcc_version=$2
|
|
|
|
tag="<sh-elf-gcc>"
|
|
|
|
root=$(pwd)
|
|
|
|
|
|
|
|
run_with_guard() {
|
|
|
|
out="$1"
|
|
|
|
shift 1
|
|
|
|
"$@" >$out 2>&1
|
|
|
|
if [[ "$?" != 0 ]]; then
|
|
|
|
echo "$tag error: build failed, please check $(pwd)/$out o(x_x)o"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Configure binutils
|
|
|
|
|
|
|
|
echo "$tag Configuring binutils..."
|
|
|
|
cd build-binutils
|
|
|
|
|
2021-01-01 15:32:47 +01:00
|
|
|
run_with_guard giteapc-configure.log \
|
2020-12-30 23:03:15 +01:00
|
|
|
../binutils-$binutils_version/configure --prefix="$root" --target=sh3eb-elf --with-multilib-list=m3,m4-nofpu --program-prefix=sh-elf- --enable-libssp --enable-lto
|
|
|
|
|
|
|
|
# Build binutils
|
|
|
|
|
|
|
|
echo "$tag Compiling binutils (can take a couple of minutes)..."
|
|
|
|
|
2021-01-01 15:32:47 +01:00
|
|
|
run_with_guard giteapc-build.log \
|
2020-12-30 23:03:15 +01:00
|
|
|
make -j$(nproc)
|
|
|
|
|
2021-01-01 15:32:47 +01:00
|
|
|
run_with_guard giteapc-install.log \
|
2020-12-30 23:03:15 +01:00
|
|
|
make install
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
# Configure GCC
|
|
|
|
|
|
|
|
echo "$tag Configuring gcc..."
|
|
|
|
cd build-gcc
|
|
|
|
|
2021-01-01 15:32:47 +01:00
|
|
|
run_with_guard giteapc-configure.log \
|
2020-12-30 23:03:15 +01:00
|
|
|
../gcc-$gcc_version/configure --prefix="$root" --target=sh3eb-elf --with-multilib-list=m3,m4-nofpu --enable-languages=c,c++ --without-headers --with-newlib --program-prefix=sh-elf- --enable-libssp --enable-lto
|
|
|
|
|
|
|
|
# Build GCC
|
|
|
|
|
|
|
|
echo "$tag Compiling gcc (often takes 10-20 minutes)..."
|
|
|
|
|
2021-01-01 15:32:47 +01:00
|
|
|
run_with_guard giteapc-build.log \
|
2020-12-30 23:03:15 +01:00
|
|
|
make -j$(nproc) all-gcc all-target-libgcc
|
|
|
|
|
2021-01-01 15:32:47 +01:00
|
|
|
run_with_guard giteapc-install.log \
|
2020-12-30 23:03:15 +01:00
|
|
|
make install-gcc install-target-libgcc
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
# Cleaning up everything
|
|
|
|
|
|
|
|
echo "$tag Cleaning up..."
|
|
|
|
|
|
|
|
rm -rf binutils-$binutils_version/ build-binutils/
|
|
|
|
rm -rf gcc-$gcc_version/ build-gcc
|
2020-12-30 23:25:05 +01:00
|
|
|
|
|
|
|
strip bin/*
|