Skip to content

Instantly share code, notes, and snippets.

@truhlikfredy
Created May 24, 2018 13:48
Show Gist options
  • Save truhlikfredy/19b9f12cde077b72cbbba392a0c5e1c9 to your computer and use it in GitHub Desktop.
Save truhlikfredy/19b9f12cde077b72cbbba392a0c5e1c9 to your computer and use it in GitHub Desktop.
#!/bin/bash
PREFIX=/opt/binutils-2.29
THREADS=4
ARCH=`uname -m`
if [ $ARCH == "x86_64" ]
then
ARCH=x86_64-linux-gnu
else
ARCH=i686-linux-gnu
fi
echo GCC $VERSION building for $ARCH into $PREFIX
clean_install_dir() {
rm -rf $PREFIX 2> /dev/null
sudo mkdir $PREFIX 2> /dev/null
sudo chown -R akrug:akrug $PREFIX
}
clean_downloads() {
echo clean downloads
rm ~/mingw-build/binutils-2.29.tar.xz 2> /dev/null
}
clean_extracted() {
echo clean extracted
rm -rf ~/mingw-build/binutils-2.29 2> /dev/null
}
clean_build() {
echo clean build folders
rm -rf ~/mingw-build/binutils-2.29/build 2> /dev/null
}
download() {
echo download
mkdir ~/binutils-build
cd ~/binutils-build
wget -c --no-check-certificate https://ftp.gnu.org/gnu/binutils/binutils-2.29.tar.xz -O binutils-2.29.tar.xz
echo "Extracting..."
tar -xJf binutils-2.29.tar.xz
}
build() {
echo "------------------- build binutils ------------------"
mkdir -p ~/binutils-build/build
cd ~/binutils-build/build
set -euo pipefail
../binutils-2.29/configure --with-sysroot=$MGW_PREFIX --prefix=$MGW_PREFIX --with-system-zlib
make -j$THREADS
make install
set +euo
}
clean_downloads
clean_extracted
clean_install_dir
clean_build
download
build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment