Chinaunix首页 | 论坛 | 博客
  • 博客访问: 179019
  • 博文数量: 27
  • 博客积分: 2774
  • 博客等级: 少校
  • 技术积分: 250
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-31 11:00
文章分类

全部博文(27)

文章存档

2011年(2)

2010年(5)

2009年(10)

2008年(3)

2007年(7)

分类: LINUX

2011-01-10 05:32:16



#!/bin/bash
export CFLAGS="-O2 -march=core2 -mtune=generic -Wall -pipe"
export CXXFLAGS="${CFLAGS}"
export BUILD_HOST="x86_64-apple-darwin10"
export TARGET_CFLAGS="-O2 -march=i686 -mtune=i686 -Wall -pipe"
export TARGET_CXXFLAGS="${TARGET_CFLAGS}"
export TARGET="i686-linux"
export PREFIX="/Volumes/Data/CC"
export TARGET_PREFIX="${PREFIX}/${TARGET}"
export CROOT="${PREFIX}/${TARGET}/sys-root"
export CINCLUDE="${CROOT}/usr/include"
export CLIB="${CROOT}/lib ${CROOT}/usr/lib"
export SHARDIR="${PREFIX}/share"
export LIBEXECDIR="${PREFIX}/lib/misc"
export COPT="/opt"
export SRC="`pwd`"
export NCPUS="`sysctl -n hw.activecpu`"
export PATH="${PREFIX}/bin:${PREFIX}/sbin:${PATH}"

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 -

#Build Glibc
rm -rf *

echo "libc_cv_forced_unwind=yes" > config.cache
echo "libc_cv_c_cleanup=yes" >> config.cache
echo "libc_cv_gnu89_inline=yes" >> config.cache
echo "install_root=${CROOT}" >> configparms

CFLAGS="-O2 -U_FORTIFY_SOURCE -march=i686 -Wall -pipe -mtune=i686 -fno-stack-protector" ${SRC}/glibc-2.11.2/configure --host=${TARGET} --prefix=/usr --with-headers="${CINCLUDE}" --disable-stackguard-randomization --enable-old-ssp-compat --enable-bind-now --enable-add-ons=nptl,c_stubs,libidn,ports --enable-kernel=2.6.24 --disable-profile --enable-omitfp --with-binutils=${TARGET_PREFIX}/bin --without-selinux --disable-multilib --without-gd --without-cvs --with-elf --build=${BUILD_HOST} -C
make -j${NCPUS} > /dev/null
make check > /dev/null
make install_root=${CROOT} install
# sed -i -e 's://lib/::g' ${CROOT}/usr/lib/libc.so
# sed -i -e 's://lib/::g' ${CROOT}/usr/lib/libpthread.so

######################################
#Rebuild binutils
rm -rf *

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

#Rebuild 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 --prefix=${PREFIX} --program-prefix=${TARGET}- --with-sysroot=${CROOT} --with-headers-path="${CINCLUDE}" --with-libs-path="${CLIB}" --libexecdir="${LIBEXECDIR}" --infodir="${SHARDIR}/info" --mandir="${SHARDIR}/man" --enable-version-specific-runtime-libs --with-gmp=${COPT} --with-mpfr=${COPT} --with-ppl=${COPT} --with-cloog=${COPT} --build=${BUILD_HOST} --host=${BUILD_HOST} --target=${TARGET} --enable-languages=c,c++ --enable-threads=posix --enable-__cxa_atexit --enable-c99 --enable-long-long --enable-openmp --enable-secureplt --enable-libmudflap --enable-libgomp --enable-clocale=gnu --enable-nls --enable-shared --enable-checking=release --with-system-zlib --disable-multilib --disable-altivec --disable-fixed-point --disable-werror --disable-libssp --disable-libgcj --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!!!"


阅读(2680) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~