Created
March 23, 2014 11:57
-
-
Save centminmod/9722104 to your computer and use it in GitHub Desktop.
gcc 4.7.3 compile for centminmod.com builds
This file contains hidden or 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
| #/bin/bash | |
| ####################################################### | |
| # gcc 4.7.3 install for Centminmod.com | |
| ####################################################### | |
| GCC_VERSION='4.7.3' | |
| GCC_CONF='n' | |
| GMP_VER='5.1.3' | |
| MPC_VER='1.0.1' | |
| MPFR_VER='3.1.2' | |
| DIR_TMP='/svr-setup' | |
| DIRTMP="${DIR_TMP}/hhvm" | |
| if [[ ! -d "$DIRTMP" ]]; then | |
| mkdir -p $DIRTMP | |
| fi | |
| if [ -f /proc/user_beancounters ]; then | |
| CPUS='1' | |
| MAKETHREADS=" -j$CPUS" | |
| else | |
| # speed up make | |
| CPUS=`cat "/proc/cpuinfo" | grep "processor"|wc -l` | |
| MAKETHREADS=" -j$CPUS" | |
| fi | |
| ####################################################### | |
| # Setup Colours | |
| black='\E[30;40m' | |
| red='\E[31;40m' | |
| green='\E[32;40m' | |
| yellow='\E[33;40m' | |
| blue='\E[34;40m' | |
| magenta='\E[35;40m' | |
| cyan='\E[36;40m' | |
| white='\E[37;40m' | |
| boldblack='\E[1;30;40m' | |
| boldred='\E[1;31;40m' | |
| boldgreen='\E[1;32;40m' | |
| boldyellow='\E[1;33;40m' | |
| boldblue='\E[1;34;40m' | |
| boldmagenta='\E[1;35;40m' | |
| boldcyan='\E[1;36;40m' | |
| boldwhite='\E[1;37;40m' | |
| Reset="tput sgr0" # Reset text attributes to normal | |
| #+ without clearing screen. | |
| cecho () # Coloured-echo. | |
| # Argument $1 = message | |
| # Argument $2 = color | |
| { | |
| message=$1 | |
| color=$2 | |
| echo -e "$color$message" ; $Reset | |
| return | |
| } | |
| ####################################################### | |
| if [[ ! -f /usr/bin/cmake28 ]]; then | |
| echo "Install cmake28" | |
| yum -q -y install cmake28 | |
| fi | |
| if [[ "$GCC_CONF" = [yY] ]]; then | |
| cd $DIRTMP | |
| cecho "Download gcc.${GCC_VERSION}.conf..." $boldyellow | |
| if [ -s gcc.${GCC_VERSION}.conf ]; then | |
| cecho "gcc.${GCC_VERSION}.conf Archive found, skipping download..." $boldgreen | |
| else | |
| wget -c --progress=bar http://centminmod.com/facebook/hhvm/rebuild_gcc/gcc.${GCC_VERSION}.conf --tries=3 | |
| ERROR=$? | |
| if [[ "$ERROR" != '0' ]]; then | |
| cecho "Error: gcc.${GCC_VERSION}.conf download failed." $boldgreen | |
| exit $ERROR | |
| else | |
| cecho "Download done." $boldyellow | |
| #echo "" | |
| fi | |
| fi | |
| fi | |
| cd $DIRTMP | |
| cecho "Download gmp-${GMP_VER}.tar.bz2..." $boldyellow | |
| if [ -s gmp-${GMP_VER}.tar.bz2 ]; then | |
| cecho "gmp-${GMP_VER}.tar.bz2 Archive found, skipping download..." $boldgreen | |
| else | |
| wget -c --progress=bar https://gmplib.org/download/gmp/gmp-${GMP_VER}.tar.bz2 --tries=3 | |
| ERROR=$? | |
| if [[ "$ERROR" != '0' ]]; then | |
| cecho "Error: gmp-${GMP_VER}.tar.bz2 download failed." $boldgreen | |
| exit $ERROR | |
| else | |
| cecho "Download done." $boldyellow | |
| #echo "" | |
| fi | |
| fi | |
| tar xjf gmp-${GMP_VER}.tar.bz2 | |
| ERROR=$? | |
| if [[ "$ERROR" != '0' ]]; then | |
| cecho "Error: gmp-${GMP_VER}.tar.bz2 extraction failed." $boldgreen | |
| exit $ERROR | |
| else | |
| cecho "gmp-${GMP_VER}.tar.bz2 valid file." $boldyellow | |
| echo "" | |
| fi | |
| cd $DIRTMP | |
| cecho "Download mpc-${MPC_VER}.tar.gz..." $boldyellow | |
| if [ -s mpc-${MPC_VER}.tar.gz ]; then | |
| cecho "mpc-${MPC_VER}.tar.gz Archive found, skipping download..." $boldgreen | |
| else | |
| wget -c --progress=bar http://www.multiprecision.org/mpc/download/mpc-${MPC_VER}.tar.gz --tries=3 | |
| ERROR=$? | |
| if [[ "$ERROR" != '0' ]]; then | |
| cecho "Error: mpc-${MPC_VER}.tar.gz download failed." $boldgreen | |
| exit $ERROR | |
| else | |
| cecho "Download done." $boldyellow | |
| #echo "" | |
| fi | |
| fi | |
| tar xzf mpc-${MPC_VER}.tar.gz | |
| ERROR=$? | |
| if [[ "$ERROR" != '0' ]]; then | |
| cecho "Error: mpc-${MPC_VER}.tar.gz extraction failed." $boldgreen | |
| exit $ERROR | |
| else | |
| cecho "mpc-${MPC_VER}.tar.gz valid file." $boldyellow | |
| echo "" | |
| fi | |
| cd $DIRTMP | |
| cecho "Download mpfr-${MPFR_VER}.tar.bz2..." $boldyellow | |
| if [ -s mpfr-${MPFR_VER}.tar.bz2 ]; then | |
| cecho "mpfr-${MPFR_VER}.tar.bz2 Archive found, skipping download..." $boldgreen | |
| else | |
| wget -c --progress=bar http://www.mpfr.org/mpfr-current/mpfr-${MPFR_VER}.tar.bz2 --tries=3 | |
| ERROR=$? | |
| if [[ "$ERROR" != '0' ]]; then | |
| cecho "Error: mpfr-${MPFR_VER}.tar.bz2 download failed." $boldgreen | |
| exit $ERROR | |
| else | |
| cecho "Download done." $boldyellow | |
| #echo "" | |
| fi | |
| fi | |
| tar xjf mpfr-${MPFR_VER}.tar.bz2 | |
| ERROR=$? | |
| if [[ "$ERROR" != '0' ]]; then | |
| cecho "Error: mpfr-${MPFR_VER}.tar.bz2 extraction failed." $boldgreen | |
| exit $ERROR | |
| else | |
| cecho "mpfr-${MPFR_VER}.tar.bz2 valid file." $boldyellow | |
| echo "" | |
| fi | |
| cd $DIRTMP | |
| cecho "Download gcc-${GCC_VERSION}.tar.bz2..." $boldyellow | |
| if [ -s gcc-${GCC_VERSION}.tar.bz2 ]; then | |
| cecho "gcc-${GCC_VERSION}.tar.bz2 Archive found, skipping download..." $boldgreen | |
| else | |
| wget -c --progress=bar http://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.bz2 --tries=3 | |
| ERROR=$? | |
| if [[ "$ERROR" != '0' ]]; then | |
| cecho "Error: gcc-${GCC_VERSION}.tar.bz2 download failed." $boldgreen | |
| exit $ERROR | |
| else | |
| cecho "Download done." $boldyellow | |
| #echo "" | |
| fi | |
| fi | |
| tar xjf gcc-${GCC_VERSION}.tar.bz2 | |
| ERROR=$? | |
| if [[ "$ERROR" != '0' ]]; then | |
| cecho "Error: gcc-${GCC_VERSION}.tar.bz2 extraction failed." $boldgreen | |
| exit $ERROR | |
| else | |
| cecho "gcc-${GCC_VERSION}.tar.bz2 valid file." $boldyellow | |
| echo "" | |
| fi | |
| ####################################################### | |
| #tar jxf gmp-${GMP_VER}.tar.bz2 | |
| cd gmp-${GMP_VER}/ | |
| ./configure --prefix=/usr/local/gmp | |
| make${MAKETHREADS} && make install | |
| cd .. | |
| #tar jxf mpfr-${MPFR_VER}.tar.bz2 | |
| cd mpfr-${MPFR_VER}/ | |
| ./configure --prefix=/usr/local/mpfr -with-gmp=/usr/local/gmp | |
| make${MAKETHREADS} && make install | |
| cd .. | |
| #tar xzf mpc-${MPC_VER}.tar.gz | |
| cd mpc-${MPC_VER} | |
| ./configure --prefix=/usr/local/mpc -with-mpfr=/usr/local/mpfr -with-gmp=/usr/local/gmp | |
| make${MAKETHREADS} && make install | |
| cd .. | |
| #tar jxf gcc-${GCC_VERSION}.tar.bz2 | |
| cd gcc-${GCC_VERSION} | |
| ./configure --prefix=/usr/local/gcc -enable-threads=posix -disable-checking -disable-multilib -enable-languages=c,c++ -with-gmp=/usr/local/gmp -with-mpfr=/usr/local/mpfr/ -with-mpc=/usr/local/mpc/ | |
| if [ $? -eq 0 ];then | |
| echo "this gcc configure is success" | |
| else | |
| echo "this gcc configure is failed" | |
| fi | |
| export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc/lib:/usr/local/gmp/lib:/usr/local/mpfr/lib/ | |
| make${MAKETHREADS} && make install | |
| [ $? -eq 0 ] && echo install success | |
| if [[ "$GCC_CONF" = [yY] ]]; then | |
| cp gcc.4.6.3.conf /etc/ld.so.conf.d/gcc.4.6.3.conf | |
| fi | |
| cat > "/etc/ld.so.conf.d/gcc.${GCC_VERSION}.conf"<<EOF | |
| /usr/local/gcc/lib/ | |
| /usr/local/mpc/lib/ | |
| /usr/local/gmp/lib/ | |
| /usr/local/mpfr/lib/ | |
| EOF | |
| ldconfig | |
| mv /usr/bin/gcc /usr/bin/gcc_old | |
| mv /usr/bin/g++ /usr/bin/g++_old | |
| mv /usr/bin/c++ /usr/bin/c++_old | |
| ln -s -f /usr/local/gcc/bin/gcc /usr/bin/gcc | |
| ln -s -f /usr/local/gcc/bin/g++ /usr/bin/g++ | |
| ln -s -f /usr/local/gcc/bin/c++ /usr/bin/c++ | |
| if [ "$(uname -m)" == 'x86_64' ]; then | |
| cp /usr/local/gcc/lib64/libstdc++.so.6.0.17 /usr/lib64/. | |
| mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.bak | |
| ln -s -f /usr/lib64/libstdc++.so.6.0.17 /usr/lib64/libstdc++.so.6 | |
| else | |
| cp /usr/local/gcc/lib/libstdc++.so.6.0.17 /usr/lib/. | |
| mv /usr/lib/libstdc++.so.6 /usr/lib/libstdc++.so.6.bak | |
| ln -s -f /usr/lib/libstdc++.so.6.0.17 /usr/lib/libstdc++.so.6 | |
| fi | |
| ####################################################### | |
| /usr/bin/gcc --version | |
| /usr/bin/g++ --version | |
| ####################################################### | |
| exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment