sh-elf-gcc/build.sh

65 lines
1.4 KiB
Bash
Executable file

#! /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
run_with_guard giteapc-configure.log \
../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)..."
run_with_guard giteapc-build.log \
make -j$(nproc)
run_with_guard giteapc-install.log \
make install
cd ..
# Configure GCC
echo "$tag Configuring gcc..."
cd build-gcc
run_with_guard giteapc-configure.log \
../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)..."
run_with_guard giteapc-build.log \
make -j$(nproc) all-gcc all-target-libgcc
run_with_guard giteapc-install.log \
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
strip bin/*