mkdir -p ${CROOT}/lib
mkdir -p ${CROOT}/usr/lib
mkdir build
cd build
#Build gmp
ABI=64 NM="/usr/bin/nm -p" ${SRC}/gmp-4.3.2/configure --prefix=${COPT}--enable-cxx
make -j${NCPUS}>/dev/null
make check >/dev/null
make install
#BUild mpfr
rm -rf *
${SRC}/mpfr-2.4.2/configure --prefix=${COPT}--with-gmp=${COPT}
make -j${NCPUS}>/dev/null
make check >/dev/null
make install
#Build ppl
rm -rf *
${SRC}/ppl-0.10.2/configure --prefix=${COPT}--with-libgmp-prefix=${COPT}--with-libgmpxx-prefix=${COPT}--enable-optimization --enable-arch --with-cflags="${CFLAGS}"--with-cxxflags="${CXXFLAGS}"--without-java
make -j${NCPUS}>/dev/null
make check >/dev/null
make install
#Build Cloog-ppl
rm -rf *
${SRC}/cloog-ppl-0.15.9/configure --prefix=${COPT}--with-gmp=${COPT}--with-ppl=${COPT}--with-bits=gmp
make -j${NCPUS}>/dev/null
make check >/dev/null
make install
#Build kernel headers files
cd $KSRC
make ARCH=x86 CROSS_COMPILE=${TARGET}- menuconfig
make ARCH=x86 INSTALL_HDR_PATH=${CROOT}/usr headers_install
cd -
#Build binutils
rm -rf *
CC="gcc -no-cpp-precomp" ${SRC}/binutils-2.20.1/configure --prefix=${PREFIX}--target=${TARGET}--with-sysroot=${CROOT}--with-libs-path="${CLIB}"--libexecdir="${LIBEXECDIR}"--infodir="${SHARDIR}/info"--mandir="${SHARDIR}/man"--disable-nls --with-gmp=${COPT}--with-mpfr=${COPT}--with-ppl=${COPT}--with-cloog=${COPT}--program-prefix=${TARGET}---disable-multilib --build=${BUILD_HOST}--host=${BUILD_HOST}--disable-shared
make configure-host >/dev/null
make -j${NCPUS}>/dev/null
make check >/dev/null
make install
cp -v ${SRC}/binutils-2.20.1/include/libiberty.h ${CROOT}/usr/include/
ln -vs ../../bin/${TARGET}-readelf ${TARGET_PREFIX}/bin/readelf
#bulid gcc
rm -rf *
AR_FOR_TARGET=${TARGET}-ar AS_FOR_TARGET=${TARGET}-as LD_FOR_TARGET=${TARGET}-ld NM_FOR_TARGET=${TARGET}-nm OBJDUMP_FOR_TARGET=${TARGET}-objdump RANLIB_FOR_TARGET=${TARGET}-ranlib STRIP_FOR_TARGET=${TARGET}-strip CFLAGS_FOR_TARGET="${TARGET_CFLAGS}" CXXFLAGS_FOR_TARGET="${TARGET_CXXFLAGS}" LDFLAGS="-L${PREFIX}/lib $LDFLAGS" CC="gcc -no-cpp-precomp" ${SRC}/gcc-4.4.4/configure --target=${TARGET}--prefix=${PREFIX}--with-sysroot=${CROOT}--libexecdir="${LIBEXECDIR}"--infodir="${SHARDIR}/info"--mandir="${SHARDIR}/man"--with-newlib --enable-languages=c --disable-fixed-point --disable-threads --disable-shared --disable-decimal-float--disable-libmudflap --disable-libssp --disable-nls --program-prefix=${TARGET}---disable-libgfortran --disable-libgomp --disable-multilib --with-gmp=${COPT}--with-mpfr=${COPT}--with-ppl=${COPT}--with-cloog=${COPT}--build=${BUILD_HOST}--host=${BUILD_HOST}
make configure-host >/dev/null
make -j${NCPUS}>/dev/null
make check >/dev/null
make install
cd ${PREFIX}/lib/gcc/${TARGET}/`${TARGET}-gcc --version |head -n1 |awk '{ print $3 }'`/
ln -vs libgcc.a libgcc_eh.a
cd -
CC="gcc -no-cpp-precomp" ${SRC}/binutils-2.20.1/configure --prefix=${PREFIX}--target=${TARGET}--with-gmp=${COPT}--with-mpfr=${COPT}--with-ppl=${COPT}--with-cloog=${COPT}--libexecdir="${LIBEXECDIR}"--infodir="${SHARDIR}/info"--mandir="${SHARDIR}/man"--program-prefix=${TARGET}---disable-multilib --enable-shared --build=${BUILD_HOST}--host=${BUILD_HOST}--with-sysroot=${CROOT}--with-libs-path="${CLIB}"--disable-werror --enable-nls --enable-secureplt --without-included-gettext
make configure-host >/dev/null
make -j${NCPUS}>/dev/null
make check >/dev/null
make install
#Build Gdb
rm -rf *
${SRC}/gdb-7.2/configure --prefix=${PREFIX}--build=${BUILD_HOST}--host=${BUILD_HOST}--target=${TARGET}--disable-werror --with-gmp=${COPT}--with-mpfr=${COPT}--with-ppl=${COPT}--with-cloog=${COPT}--program-prefix=${TARGET}---enable-nls --with-sysroot=${CROOT}--with-libs-path="${CLIB}"--libexecdir="${LIBEXECDIR}"--without-included-gettext --enable-shared
make configure-host >/dev/null
make -j${NCPUS}>/dev/null
make check >/dev/null
make install
#BUild Module-init-tools
rm -rf *
cd ${SRC}/module-init-tools-3.5/
sed -i -e 's:-Wl,-Bstatic -lz -Wl,-Bdynamic:-lz:' configure ./configure --prefix=${PREFIX}--build=${BUILD_HOST}--host=${BUILD_HOST}--enable-zlib --target=${TARGET}
make -j${NCPUS}>/dev/null
make install
cd ${PREFIX}
rm -rf build
@echo "Build Complete!!!"