Created
March 10, 2016 12:32
-
-
Save Gekkio/2330756cc2c9f6b91bab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Based on: | |
# http://en.librehat.com/blog/build-gcc-5-dot-2-on-rhel-6/ | |
set -euo pipefail | |
GCC_VERSION=5.3.0 | |
GMP_VERSION=6.1.0 | |
MPC_VERSION=1.0.3 | |
MPFR_VERSION=3.1.4 | |
JOBS=$(expr $(nproc) + $(nproc)) | |
PREFIX=/opt/gcc5 | |
set -x | |
### Install packages | |
sudo yum -q install gcc gcc-c++ make texinfo wget zlib-devel | |
### Download archives | |
wget -qN "ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.bz2" -P . | |
wget -qN "https://gmplib.org/download/gmp/gmp-${GMP_VERSION}.tar.bz2" -P . | |
wget -qN "ftp://ftp.gnu.org/gnu/mpc/mpc-${MPC_VERSION}.tar.gz" -P . | |
wget -qN "http://www.mpfr.org/mpfr-current/mpfr-${MPFR_VERSION}.tar.bz2" -P . | |
### Unpack GCC and create subdirectories | |
[ ! -e "./gcc-${GCC_VERSION}" ] && tar xaf "gcc-${GCC_VERSION}".tar.bz2 | |
mkdir -p "./gcc-${GCC_VERSION}/gmp" | |
mkdir -p "./gcc-${GCC_VERSION}/mpc" | |
mkdir -p "./gcc-${GCC_VERSION}/mpfr" | |
mkdir -p "./gcc-${GCC_VERSION}/gcc-build" | |
### Unpack dependencies | |
tar xaf "gmp-${GMP_VERSION}.tar.bz2" -C "./gcc-${GCC_VERSION}/gmp" --strip-components=1 | |
tar xaf "mpc-${MPC_VERSION}.tar.gz" -C "./gcc-${GCC_VERSION}/mpc" --strip-components=1 | |
tar xaf "mpfr-${MPFR_VERSION}.tar.bz2" -C "./gcc-${GCC_VERSION}/mpfr" --strip-components=1 | |
cd "gcc-${GCC_VERSION}/gcc-build" | |
### Configure | |
../configure\ | |
--prefix="${PREFIX}"\ | |
--enable-bootstrap\ | |
--enable-shared\ | |
--enable-threads=posix\ | |
--enable-checking=release\ | |
--with-system-zlib\ | |
--enable-__cxa_atexit\ | |
--disable-libunwind-exceptions\ | |
--enable-gnu-unique-object\ | |
--enable-languages=c,c++\ | |
--disable-dssi\ | |
--with-ppl\ | |
--with-cloog\ | |
--with-tune=generic\ | |
--with-arch_32=i686\ | |
--build x86_64-redhat-linux-gnu\ | |
--host x86_64-redhat-linux-gnu\ | |
--disable-multilib\ | |
--enable-libstdcxx-threads\ | |
--enable-libstdcxx-time\ | |
--disable-libada\ | |
--with-default-libstdcxx-abi=gcc4-compatible | |
### Build | |
make -j "${JOBS}" | |
### Install | |
mkdir -p "${PREFIX}" | |
cat << EOF > "${PREFIX}/activate.sh" | |
export PATH=${PREFIX}/bin:\$PATH | |
export MANPATH=${PREFIX}/share/man:\$MANPATH | |
export INFOPATH=${PREFIX}/share/info:\$INFOPATH | |
export LD_LIBRARY_PATH=${PREFIX}/lib64:${PREFIX}/lib:\$LD_LIBRARY_PATH | |
export LD_RUN_PATH=${PREFIX}/lib64:${PREFIX}/lib:\$LD_RUN_PATH | |
export LIBRARY_PATH=${PREFIX}/lib64:${PREFIX}/lib:\$LIBRARY_PATH | |
export INCLUDE_PATH=${PREFIX}/include:\$INCLUDE_PATH | |
export CPLUS_INCLUDE_PATH=${PREFIX}/include:\$CPLUS_INCLUDE_PATH | |
export C_INCLUDE_PATH=${PREFIX}/include:\$C_INCLUDE_PATH | |
EOF | |
make install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment