#!/bin/bash # # thrown together by Eric Herman on 2010 December 19 # # much of this is based upon Cross-Compiled Linux From Scratch # http://cross-lfs.org/ # Copyright (C) 2005-2010 Joe Ciccone, Jim Gifford & Ryan Oliver # which is based upon Based on LFS, # http://www.linuxfromscratch.org/lfs/ # Copyright (C) 1999-2010 Gerard Beekmans # export CROSS_TARGET="x86_64-unknown-linux-gnu" export KERNEL_ARCH="ARCH=x86_64" export BUILD64="-m64" < configure && echo "CLOOGPPL configure diff" || exit $? diff -u configure.orig configure # echo "CLOOGPPL crazy hack-around for m4 breakage" && # patch -Np1 -i ${PATCHES}/cloog-ppl-0.15.10-cheesy_hackaround_m4_breakage-1.patch && echo "CLOOGPPL configure" && LDFLAGS="-Wl,-rpath,${CROSSTOOLS}/lib" \ ./configure \ --prefix=${CROSSTOOLS} \ --enable-shared \ --with-bits=gmp \ --with-gmp=${CROSSTOOLS} \ --with-ppl=${CROSSTOOLS} && echo "CLOOGPPL make" && make && echo "CLOOGPPL install" && make install && echo "CLOOGPPL YAY" || exit $? popd echo "CLOOGPPL removing build dir" pwd rm -rf cloog* ls -l echo "" cat <> gcc/config/linux.h && echo "#define STANDARD_INCLUDE_DIR \"${TOOLS}/include/\"" >> gcc/config/linux.h && echo "" >> gcc/config/linux.h && echo "#undef STANDARD_STARTFILE_PREFIX_1" >> gcc/config/linux.h && echo "#define STANDARD_STARTFILE_PREFIX_1 \"${TOOLS}/lib/\"" >> gcc/config/linux.h && echo "#undef STANDARD_STARTFILE_PREFIX_2" >> gcc/config/linux.h && echo "#define STANDARD_STARTFILE_PREFIX_2 \"\"" >> gcc/config/linux.h && echo "GCC static linux.h diff" || exit $? diff -u gcc/config/linux.h.orig gcc/config/linux.h echo "" echo "alter gcc's c preprocessor's default include search path" && echo " to use ${TOOLS} only" && cp -v gcc/Makefile.in{,.orig} sed -e "s@\(^CROSS_SYSTEM_HEADER_DIR =\).*@\1 ${TOOLS}/include@g" \ gcc/Makefile.in.orig > gcc/Makefile.in && echo "GCC static Makefile diff" || exit $? diff -u gcc/Makefile.in.orig gcc/Makefile.in echo "" && echo "create a dummy limits.h so the build will not use the host one" && touch ${TOOLS}/include/limits.h && echo "" && echo "The GCC documentation recommends building GCC outside of the source" && echo " directory in a dedicated build directory" && mkdir -v ../build-gcc && cd ../build-gcc && echo "GCC static configure" && echo 'do we need?: CPPFLAGS_FOR_TARGET="--sysroot=${SYSROOT}"' && echo 'do we need?: LDFLAGS_FOR_TARGET="--sysroot=${SYSROOT}"' && AR=ar \ LDFLAGS="-Wl,-rpath,${CROSSTOOLS}/lib" \ ../gcc*/configure \ --prefix=${CROSSTOOLS} \ --build=${CROSS_HOST} \ --host=${CROSS_HOST} \ --target=${CROSS_TARGET} \ --with-sysroot=${SYSROOT} \ --with-local-prefix=${TOOLS} \ --with-mpfr=${CROSSTOOLS} \ --with-gmp=${CROSSTOOLS} \ --with-ppl=${CROSSTOOLS} \ --with-cloog=${CROSSTOOLS} \ --with-mpc=${CROSSTOOLS} \ --without-headers \ --with-newlib \ --disable-decimal-float \ --disable-libgomp \ --disable-libmudflap \ --disable-libssp \ --disable-threads \ --enable-languages=c \ --disable-nls \ --disable-shared \ --disable-multilib && echo "GCC static build" && make all-gcc all-target-libgcc && echo "GCC static install" && make install-gcc install-target-libgcc && echo "GCC static YAY" || exit $? popd echo "GCC static removing build dir" pwd rm -rf gcc* build-gcc ls -l echo "" cat << END_OF_MSG - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LIBC $LIBC - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - END_OF_MSG tar xf ${SOURCES}/$LIBC && pushd *libc* && echo "LIBC patch" && echo "Disable linking to libgcc_eh" && cp -v Makeconfig{,.orig} && sed -e 's/-lgcc_eh//g' Makeconfig.orig > Makeconfig && echo "will now diff" || exit $? diff -u Makeconfig.orig Makeconfig echo " building LIBC outside of the source directory" && mkdir -v ../build-lib && cd ../build-lib && echo " added to config.cache for (E)GLIBC to support NPTL" || exit $? cat > config.cache << "EOF" libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes libc_cv_gnu89_inline=yes EOF BUILD_CC="gcc" \ CC="${CROSS_TARGET}-gcc ${BUILD64}" \ AR="${CROSS_TARGET}-ar" \ RANLIB="${CROSS_TARGET}-ranlib" \ ../*libc*/configure \ --prefix=${TOOLS} \ --host=${CROSS_TARGET} \ --build=${CROSS_HOST} \ --disable-profile \ --enable-add-ons \ --with-tls \ --enable-kernel=2.6.30 \ --with-__thread \ --with-binutils=${CROSSTOOLS}/bin \ --with-headers=${TOOLS}/include \ --cache-file=config.cache && echo "LIBC build" && make && echo "LIBC install" && make install && echo "LIBC YAY" || exit $? popd echo "LIBC removing build dir" pwd rm -rf *libc* build-lib ls -l echo "" cat << END_OF_MSG - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - GCC $GCC - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - END_OF_MSG tar xf ${SOURCES}/$GCC && pushd gcc* && echo "GCC patch" && echo "applying gcc-4.5.1-pure64_specs-2.patch" && patch -Np1 -i ${PATCHES}/gcc-4.5.1-pure64_specs-2.patch && echo "" && echo "Change the StartFile Spec and Standard Include Dir so that GCC looks" && echo " in ${TOOLS}" && cp -v gcc/config/linux.h{,.orig} && echo "#undef STANDARD_INCLUDE_DIR" >> gcc/config/linux.h && echo "#define STANDARD_INCLUDE_DIR \"${TOOLS}/include\"" >> gcc/config/linux.h && echo "" >> gcc/config/linux.h && echo "#undef STANDARD_STARTFILE_PREFIX_1" >> gcc/config/linux.h && echo "#define STANDARD_STARTFILE_PREFIX_1 \"${TOOLS}/lib\"" >> gcc/config/linux.h && echo "#undef STANDARD_STARTFILE_PREFIX_2" >> gcc/config/linux.h && echo "#define STANDARD_STARTFILE_PREFIX_2 \"\"" >> gcc/config/linux.h && echo "GCC linux.h diff" || exit $? diff -u gcc/config/linux.h.orig gcc/config/linux.h echo "" && echo "alter gcc's c preprocessor's default include search path" && echo " to use /tools only" && cp -v gcc/Makefile.in{,.orig} && sed -e "s@\(^CROSS_SYSTEM_HEADER_DIR =\).*@\1 ${TOOLS}/include@g" \ gcc/Makefile.in.orig > gcc/Makefile.in && echo "will now diff" || exit $? diff -u gcc/Makefile.in.orig gcc/Makefile.in echo "" && echo "build GCC in a dedicated build directory" && mkdir -v ../build-gcc && cd ../build-gcc && echo "GCC configure" && echo 'do we need?: CPPFLAGS_FOR_TARGET="--sysroot=${SYSROOT}"' && echo 'do we need?: LDFLAGS_FOR_TARGET="--sysroot=${SYSROOT}"' && AR=ar \ LDFLAGS="-Wl,-rpath,${CROSSTOOLS}/lib" \ ../gcc*/configure \ --prefix=${CROSSTOOLS} \ --build=${CROSS_HOST} \ --target=${CROSS_TARGET} \ --host=${CROSS_HOST} \ --with-sysroot=${SYSROOT} \ --with-local-prefix=${TOOLS} \ --with-mpfr=${CROSSTOOLS} \ --with-mpc=${CROSSTOOLS} \ --with-gmp=${CROSSTOOLS} \ --with-ppl=${CROSSTOOLS} \ --with-cloog=${CROSSTOOLS} \ --disable-nls \ --enable-shared \ --enable-languages=c,c++ \ --enable-__cxa_atexit \ --enable-c99 \ --enable-long-long \ --enable-threads=posix \ --disable-multilib && echo "GCC make" && make AS_FOR_TARGET="${CROSS_TARGET}-as" \ LD_FOR_TARGET="${CROSS_TARGET}-ld" && echo "GCC install" && make install && echo "GCC YAY" || exit $? popd echo "GCC removing build dir" pwd rm -rf gcc* build-gcc ls -l popd echo "WOOT!"