I have written this script to install gcc (here in version 4.9.2) on Centos6.6. I am only interested in C and C++ support.Please comment if this is any good and can I make it better before I get the packages for those.#!/bin/bashLOGFILE=/tmp/gcc_install.log# $1 - package name# $2 - statuserrorIf(){if [ $2 -ne 0 ]; then    echo Something was wrong with $1    exit 1fi}################################################################################################################# SCRIPT START #################################if [[ $EUID -ne 0 ]]; then   echo This script must be run as root 1>&2   exit 1fi# only one param - gcc's source directory absolute locationif [ $# -ne 1 ]; then    echo Please give the gcc source directory as argument    exit 1fiif [ ! -d $1 ]; then    echo gcc's source directory that you have passed doesn't exist!    exit 1fiSOURCE_DIR=$1SOURCE_DIR_NAME=${SOURCE_DIR##*/}cd $SOURCE_DIR/contrib/################################################################################################################# gmp, mpgr, mpc  ############################### this script assumes that you have ran download_prerequisites from gcc's contrib dir# contrib with downloaded gmp, mpgr, mpc (used download_prerequisites)if [ ! -d gmp ] || [ ! -d mpfr ] || [ ! -d mpc ]; then    echo There is no gmp or mpfr or mpc directory in `pwd`. Please run download_prerequisites.    exit 1fiecho Installing gcc and dependencies. You can check the status and results in $LOGFILE#gmpcd gmp && ./configure --enable-shared --enable-static --prefix=/usr/local >$LOGFILE 2>&1 && make >$LOGFILE 2>&1 && make check >$LOGFILE 2>&1 && make install >$LOGFILE 2>&1 && cd ..ret=$?errorIf gmp $retecho gmp Installed!:)#mpfrcd mpfr && ./configure --enable-shared --enable-static --prefix=/usr/local --with-gmp=/usr/local >$LOGFILE 2>&1 && make >$LOGFILE 2>&1 && make check >$LOGFILE 2>&1 && make install >$LOGFILE 2>&1 && cd ..ret=$?errorIf mpfr $retecho mpfr Installed!:)#mpccd mpc && ./configure --enable-shared --enable-static --prefix=/usr/local --with-gmp=/usr/local --with-mpfr=/usr/local >$LOGFILE 2>&1 && make >$LOGFILE 2>&1 && make check >$LOGFILE 2>&1 && make install >$LOGFILE 2>&1 && cd ..ret=$?errorIf mpc $retecho mpc Installed!:)echo /usr/local/lib/ >> /etc/ld.so.confecho /usr/local/lib64/ >> /etc/ld.so.confldconfigcd ../../ulimit -s 32768 # for gcc testsmkdir -p /usr/share/gdb/auto-load/usr/libmkdir -p gcc-buildcd gcc-build# find mv .py command is due to this ldconfig error (gcc copies some .py files into /usr/local/lib64/)# ldconfig: /usr/local/lib/../lib64/libstdc++.so.6.0.20-gdb.py is not an ELF file - it has the wrong magic bytes at the start.../$SOURCE_DIR_NAME/configure --enable-shared --disable-bootstrap --with-system-zlib --enable-languages=c,c++ --enable-libgomp --enable-threads=posix --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local --with-fpmath=sse --disable-multilib >$LOGFILE 2>&1 && make >$LOGFILE 2>&1 && make install >$LOGFILE 2>&1 && find /usr/local/lib64 -iname *.py -exec mv {} /usr/share/gdb/auto-load/usr/lib/ \;  >$LOGFILE 2>&1 && ldconfig >$LOGFILE 2>&1echo gcc from $SOURCE_DIR_NAME Installed!:)
gcc installation script for Centos6.6
bash;linux;shell