Created
September 17, 2013 07:35
-
-
Save asandroq/6591141 to your computer and use it in GitHub Desktop.
Script for automating GCC's build.
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/sh | |
set -x | |
set -e | |
PREFIX='/opt/gcc' | |
WGET='wget --tries=3' | |
GCC_URL='http://gcc.cybermirror.org/releases/gcc-4.8.1/gcc-4.8.1.tar.bz2' | |
GMP_URL='http://mirror.switch.ch/ftp/mirror/gnu/gmp/gmp-5.1.2.tar.bz2' | |
MPFR_URL='http://www.mpfr.org/mpfr-current/mpfr-3.1.2.tar.bz2' | |
MPC_URL='http://www.multiprecision.org/mpc/download/mpc-1.0.1.tar.gz' | |
ISL_URL='ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.11.1.tar.bz2' | |
CLOOG_URL='ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-0.18.0.tar.gz' | |
# | |
# This assumes all needed files are in the same directory | |
# | |
get_it() | |
{ | |
file_url="$1" | |
file=`basename $file_url` | |
dirname=`basename $file .tar.bz2` | |
if [ "$file" == "$dirname" ]; then | |
dirname=`basename $file .tar.gz` | |
fi | |
if [ ! -d "$dirname" ]; then | |
if [ ! -f "$file" ]; then | |
$WGET "$file_url" | |
fi | |
tar xf "$file" | |
fi | |
} | |
build_it() | |
{ | |
file_url="$1" | |
test_file="$2" | |
config_flags=$3 | |
get_it "$file_url" | |
if [ ! -f "$PREFIX/$test_file" ]; then | |
pushd "$dirname" | |
CFLAGS="-I$PREFIX/include" LDFLAGS="-L$PREFIX/lib" \ | |
./configure --prefix="$PREFIX" $config_flags | |
make -j 8 | |
if [ $? -eq 0 ]; then | |
sudo make install | |
fi | |
popd | |
fi | |
} | |
build_gcc() | |
{ | |
get_it "$GCC_URL" | |
mkdir -p gcc-build | |
pushd gcc-build | |
GCC_DIR=`basename $GCC_URL .tar.bz2` | |
CFLAGS="-I$PREFIX/include" LDFLAGS="-L$PREFIX/lib" \ | |
"../$GCC_DIR/configure" --prefix="$PREFIX" --enable-threads --with-cpu=core2 \ | |
--enable-languages=c,objc --disable-nls --enable-lto --with-gmp="$PREFIX" --with-mpfr="$PREFIX" \ | |
--with-mpc="$PREFIX" --with-isl="$PREFIX" --with-cloog="$PREFIX" | |
make -j 8 | |
if [ $? -eq 0 ]; then | |
sudo make install | |
fi | |
popd | |
} | |
build_it "$GMP_URL" "include/gmp.h" "--enable-cxx" | |
build_it "$MPFR_URL" "include/mpfr.h" | |
build_it "$MPC_URL" "include/mpc.h" | |
build_it "$ISL_URL" "include/isl/config.h" "--with-gmp=system" | |
build_it "$CLOOG_URL" "bin/cloog" "--with-gmp=system --with-isl=system" | |
build_gcc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment