Created
April 22, 2013 20:38
-
-
Save erincandescent/5438328 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
ARCH=$1 | |
PREFIX="$2" | |
IFS=. read -a TRIPLE <<< "$IP" | |
GMP="gmp-5.0.5" | |
MPFR="mpfr-3.1.1" | |
MPC="mpc-0.9" | |
BINUTILS="binutils-2.22" | |
GCC="gcc-4.7.1" | |
LLVM="llvm-3.1" | |
CLANG="clang-3.1" | |
COMPILER_RT="compiler-rt-3.1" | |
GDB="gdb-7.4.1" | |
NEWLIB=newlib-1.20.0 | |
GMP_BUILD="$GMP-$ARCH-build" | |
MPFR_BUILD="$MPFR-$ARCH-build" | |
MPC_BUILD="$MPC-$ARCH-build" | |
BINUTILS_BUILD="$BINUTILS-$ARCH-build" | |
GCC_BUILD="$GCC-$ARCH-build" | |
LLVM_BUILD="$LLVM-$ARCH-build" | |
GDB_BUILD="$GDB-$ARCH-build" | |
CPPFLAGS="$CPP -I$PREFIX/include" | |
LDFLAGS="$LDFLAGS -L$PREFIX/lib" | |
WD=$(pwd) | |
function get { | |
if [ ! -e "$2$3" ]; then | |
wget $1$2$3 | |
fi | |
} | |
function build { | |
echo "Build $1, from $2" | |
mkdir -p $3 | |
if [ ! -e $3/.config.done ]; then | |
echo "-- Configure $2" | |
cd $3 && ../$2/configure --prefix=$PREFIX $4 && touch .config.done && cd $WD || exit 1 | |
fi | |
if [ ! -e $3/.build.done ]; then | |
echo "-- Build $2" | |
cd $3 && make -j4 && touch .build.done && cd $WD || exit 1 | |
fi | |
if [ ! -e "$PREFIX/$1" ]; then | |
echo "-- Install $2" | |
cd $3 && make install && cd $WD || exit 1 | |
fi | |
} | |
if [ -z "$ARCH" ]; then | |
echo "Must specify target" | |
exit 1 | |
fi | |
if [ -z "$PREFIX" ]; then | |
PREFIX="/usr/lib/fusion-$ARCH" | |
fi | |
get http://ftp.gnu.org/gnu/gmp/ $GMP .tar.bz2 | |
get http://ftp.gnu.org/gnu/mpfr/ $MPFR .tar.bz2 | |
get http://www.multiprecision.org/mpc/download/ $MPC .tar.gz | |
get http://ftp.gnu.org/gnu/binutils/ $BINUTILS .tar.bz2 | |
get http://ftp.gnu.org/gnu/gcc/gcc-4.7.1/ $GCC .tar.bz2 | |
get ftp://sources.redhat.com/pub/newlib/ $NEWLIB .tar.gz | |
get http://www.llvm.org/releases/3.1/ $LLVM .src.tar.gz | |
get http://www.llvm.org/releases/3.1/ $CLANG .src.tar.gz | |
get http://www.llvm.org/releases/3.1/ $COMPILER_RT .src.tar.gz | |
get http://ftp.gnu.org/gnu/gdb/ $GDB .tar.bz2 | |
if [ ! -e "./$GMP" ]; then | |
tar xjf $GMP.tar.bz2 | |
fi | |
if [ ! -e "./$MPFR" ]; then | |
tar xjf $MPFR.tar.bz2 | |
fi | |
if [ ! -e "./$MPC" ]; then | |
tar xzf $MPC.tar.gz | |
fi | |
if [ ! -e "./$BINUTILS" ]; then | |
tar xjf $BINUTILS.tar.bz2 | |
fi | |
if [ ! -e "./$GCC" ]; then | |
tar xjf $GCC.tar.bz2 | |
fi | |
if [ ! -e "./$GCC/newlib" ]; then | |
tar xzf $NEWLIB.tar.gz | |
cd $GCC | |
./symlink-tree $WD/$NEWLIB | |
cd $WD | |
fi | |
if [ ! -e "./$LLVM" ]; then | |
tar xzf $LLVM.src.tar.gz | |
mv $LLVM.src $LLVM | |
fi | |
if [ ! -e "./$LLVM/projects/compiler-rt" ]; then | |
cd $LLVM/projects | |
tar xzf $WD/$COMPILER_RT.src.tar.gz | |
mv $COMPILER_RT.src compiler-rt | |
cd $WD | |
fi | |
if [ ! -e "./$LLVM/tools/clang" ]; then | |
cd $LLVM/tools | |
tar xzf $WD/$CLANG.src.tar.gz | |
mv $CLANG.src clang | |
cd $WD | |
fi | |
if [ ! -e "./$GDB" ]; then | |
tar xvvjf $GDB.tar.bz2; | |
fi; | |
build lib/libgmp.a $GMP $GMP_BUILD | |
build lib/libmpfr.a $MPFR $MPFR_BUILD "--with-gmp=$PREFIX" | |
build lib/libmpc.a $MPC $MPC_BUILD "--with-gmp=$PREFIX --with-mpfr=$PREFIX" | |
mkdir -p $BINUTILS_BUILD | |
if [ ! -e $BINUTILS_BUILD/.config.done ]; then | |
echo "--Configure binutils" | |
cd $BINUTILS_BUILD && \ | |
../$BINUTILS/configure --with-local-prefix=$PREFIX --prefix=$PREFIX --target=$ARCH && \ | |
touch .config.done && cd $WD || exit 1 | |
fi | |
if [ ! -e $BINUTILS_BUILD/.build.done ]; then | |
echo "-- Building Binutils" | |
cd $BINUTILS_BUILD && make -j4 && touch .build.done && cd $WD || exit 1 | |
fi | |
if [ ! -e "$PREFIX/$ARCH/bin/ld" ]; then | |
echo "-- Install Binutils" | |
cd $BINUTILS_BUILD && make install && cd $WD || exit 1 | |
fi | |
mkdir -p $GCC_BUILD | |
if [ ! -e $GCC_BUILD/.config.done ]; then | |
echo "-- Configuring GCC" | |
cd $GCC_BUILD && \ | |
../$GCC/configure --with-local-prefix=$PREFIX --prefix=$PREFIX --target=$ARCH \ | |
--enable-languages=c,c++ --with-gmp=$PREFIX --with-mpfr=$PREFIX --with-mpc=$PREFIX \ | |
--without-headers --enable-target-optspace && \ | |
touch .config.done && cd $WD || exit 1 | |
fi | |
if [ ! -e $GCC_BUILD/.build.done ]; then | |
echo "-- Building GCC" | |
cd $GCC_BUILD && \ | |
make all-gcc -j4 && \ | |
touch .build.done && \ | |
cd $WD || exit 1 | |
fi | |
if [ ! -e "$PREFIX/$ARCH/bin/gcc" ]; then | |
cd $GCC_BUILD && make install && cd $WD | |
fi | |
GCC_VERSION=$($PREFIX/$ARCH/bin/gcc -dumpversion) | |
if [ ! -e $GCC_BUILD/.libgcc.done ]; then | |
echo "-- Building libgcc" | |
cd $GCC_BUILD && make all-target-libgcc -j4 && touch .libgcc.done && cd $WD || exit 1 | |
fi | |
if [ ! -e "$PREFIX/lib/gcc/$ARCH/$GCC_VERSION/libgcc.a" ]; then | |
cd $GCC_BUILD && make install-target-libgcc && cd $WD || exit 1 | |
fi | |
if [ ! -e $LLVM_BUILD/.config.succeeded ]; then | |
echo "-- Configure LLVM" | |
mkdir -p $LLVM_BUILD && \ | |
cd $LLVM_BUILD && \ | |
$WD/$LLVM/configure --prefix=$PREFIX --enable-optimized --disable-docs --enable-pic --enable-targets=host,x86,arm && \ | |
touch .config.succeeded && | |
cd $WD || exit 1 | |
fi | |
if [ ! -e $LLVM_BUILD/.build.succeeded ]; then | |
echo "-- Build LLVM" | |
cd $LLVM_BUILD | |
make -j4 && touch .build.succeeded || exit 1 | |
cd $WD | |
fi | |
if [ ! -e "$PREFIX/bin/clang" ]; then | |
echo "-- Install LLVM" | |
cd $LLVM_BUILD | |
make install | |
cd $WD | |
fi | |
if [ ! -e $GDB_BUILD/.config.succeeded ]; then | |
echo "-- Configure GDB" | |
mkdir -p $GDB_BUILD && \ | |
cd $GDB_BUILD && \ | |
$WD/$GDB/configure --prefix=$PREFIX --target=$ARCH --with-gmp=$PREFIX --with-mpfr=$PREFIX --with-mpc=$PREFIX --without-python && \ | |
touch .config.succeeded && \ | |
cd $WD || exit 1 | |
fi | |
if [ ! -e $GDB_BUILD/.build.succeeded ]; then | |
cd $GDB_BUILD && \ | |
make -j4 && touch .build.succeeded && \ | |
cd $WD || exit 1 | |
fi | |
if [ ! -e "$PREFIX/bin/$ARCH-gdb" ]; then | |
echo "-- Install GDB" | |
cd $GDB_BUILD && make install && cd $WD || exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment