#!/usr/bin/env bash set -e source $(dirname $0)/setup-env.sh cd $LUNA_ROOT mkdir -p toolchain/tarballs mkdir -p toolchain/build if [ ! -f toolchain/tarballs/binutils-$LUNA_BINUTILS_VERSION_REQUIRED.tar.xz ]; then echo Downloading Binutils... wget -Otoolchain/tarballs/binutils-$LUNA_BINUTILS_VERSION_REQUIRED.tar.xz https://ftp.gnu.org/gnu/binutils/binutils-$LUNA_BINUTILS_VERSION_REQUIRED.tar.xz fi rm -rf toolchain/build/binutils-$LUNA_ARCH rm -rf toolchain/build/binutils-$LUNA_BINUTILS_VERSION_REQUIRED echo Extracting Binutils... tar xf toolchain/tarballs/binutils-$LUNA_BINUTILS_VERSION_REQUIRED.tar.xz -C toolchain/build/ echo Patching Binutils... cd toolchain patch -u -i $LUNA_ROOT/tools/binutils.patch -p 1 -d build cd - echo Configuring Binutils... mkdir -p toolchain/build/binutils-$LUNA_ARCH cd toolchain/build/binutils-$LUNA_ARCH unset CC unset CXX unset LD unset AR ../binutils-$LUNA_BINUTILS_VERSION_REQUIRED/configure --prefix="$BUILD_PREFIX" --target=$BUILD_TARGET --disable-nls --with-sysroot=$BUILD_SYSROOT --disable-werror --enable-warn-rwx-segments=no --enable-initfini-array echo Building Binutils... make -j$(nproc) echo Installing Binutils... make install