2017-07-26 06:21:01 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
sudo apt-get install -y curl
|
|
|
|
|
|
|
|
VERSION=$(curl -sSL https://ftpmirror.gnu.org/gcc/ | grep -oE 'gcc-[0-9]+(\.[0-9]+)+' | sort -Vr | head -n1) #'
|
|
|
|
#VERSION=gcc-7.1.0
|
|
|
|
|
2017-07-26 06:24:04 +00:00
|
|
|
VERSION_SHORT=$(echo "$VERSION" | grep -oE '[0-9]' | head -n1)
|
2017-07-26 06:21:01 +00:00
|
|
|
|
|
|
|
echo "Will download ${VERSION} (short version: $VERSION_SHORT)."
|
|
|
|
|
|
|
|
THREADS=$(grep -c ^processor /proc/cpuinfo)
|
|
|
|
|
|
|
|
cd ~
|
2017-07-26 06:25:21 +00:00
|
|
|
mkdir gcc
|
|
|
|
cd gcc
|
2017-07-26 06:21:01 +00:00
|
|
|
|
2017-11-12 14:46:33 +00:00
|
|
|
wget https://ftpmirror.gnu.org/gcc/${VERSION}/${VERSION}.tar.xz
|
|
|
|
tar xf ${VERSION}.tar.xz
|
2017-07-26 06:21:01 +00:00
|
|
|
cd ${VERSION}
|
|
|
|
./contrib/download_prerequisites
|
|
|
|
cd ..
|
|
|
|
mkdir gcc-build
|
|
|
|
cd gcc-build
|
2017-07-26 06:24:04 +00:00
|
|
|
../${VERSION}/configure --enable-languages=c,c++ --disable-multilib
|
2017-07-26 06:21:01 +00:00
|
|
|
make -j $THREADS
|
|
|
|
sudo make install
|
|
|
|
|
2017-07-26 06:53:07 +00:00
|
|
|
sudo ln -sf /usr/local/bin/gcc /usr/local/bin/gcc-${VERSION_SHORT}
|
|
|
|
sudo ln -sf /usr/local/bin/g++ /usr/local/bin/g++-${VERSION_SHORT}
|
|
|
|
sudo ln -sf /usr/local/bin/gcc /usr/local/bin/cc
|
|
|
|
sudo ln -sf /usr/local/bin/g++ /usr/local/bin/c++
|
2017-07-26 06:21:01 +00:00
|
|
|
|
2017-11-14 19:46:11 +00:00
|
|
|
echo "/usr/local/lib64" | sudo tee /etc/ld.so.conf.d/10_local-lib64.conf
|
|
|
|
sudo ldconfig
|
2017-07-26 07:10:21 +00:00
|
|
|
|
2017-07-26 06:21:01 +00:00
|
|
|
hash gcc g++
|
|
|
|
gcc --version
|