mirror of
https://git.planet-casio.com/Lephenixnoir/sh-elf-gcc.git
synced 2024-12-28 04:23:39 +01:00
52 lines
1.4 KiB
Bash
Executable file
52 lines
1.4 KiB
Bash
Executable file
#! /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)"
|
|
|
|
# Symlink as, ld, ar and ranlib, which gcc will not find by itself (we renamed
|
|
# them from sh3eb-elf-* to sh-elf-* with --program-prefix).
|
|
mkdir -p sh3eb-elf/bin
|
|
ln -s $(command -v sh-elf-as) sh3eb-elf/bin/as
|
|
ln -s $(command -v sh-elf-ld) sh3eb-elf/bin/ld
|
|
ln -s $(command -v sh-elf-ar) sh3eb-elf/bin/ar
|
|
ln -s $(command -v sh-elf-ranlib) sh3eb-elf/bin/ranlib
|
|
|
|
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
|