#! /usr/bin/env bash source util.sh VERSION=$1 URL="https://ftp.gnu.org/gnu/gcc/gcc-$VERSION/gcc-$VERSION.tar.xz" ARCHIVE=$(basename "$URL") # Download archive if [[ -f "$ARCHIVE" ]]; then echo "$TAG Found $ARCHIVE, skipping download" else echo "$TAG Downloading $URL..." if command -v curl >/dev/null 2>&1; then curl $URL -o $ARCHIVE elif command -v wget >/dev/null 2>&1; then wget -q --show-progress $URL -O $ARCHIVE else echo "$TAG error: no curl or wget; install one or download archive yourself" >&2 exit 1 fi fi # Extract archive echo "$TAG Extracting $ARCHIVE..." tar -xJf $ARCHIVE # Create build folder [[ -d "build" ]] && rm -rf build mkdir build # Configure. GCC does not support make uninstall so we install in this # directory and later symlink executables to $PREFIX/bin. PREFIX="$(pwd)" cd build echo "$TAG Configuring gcc..." run_quietly giteapc-configure.log \ ../gcc-$VERSION/configure --prefix="$PREFIX" --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