--- /dev/null 2009-03-13 12:41:30.082500994 -0500 +++ b/scripts/uclibc++.sh 2009-03-31 23:58:35.000000000 -0500 @@ -0,0 +1,85 @@ +#!/bin/bash + +# Tuple for Cross Compiling +export ARCH=${CT_ARCH}-unknown-linux-uclibc + +# This won't work if we're building a cross-compiler for the same thing we're running on, +# because GCC thinks too much +export CROSS_TARGET=${CT_ARCH}-unknown-linux +export CROSS_HOST=`uname -m`-unknown-linux + +# The current GCC source directory crosstool-ng has +export GCCSRC=${CT_WORK_DIR}/src/${CT_CC}-${CT_CC_VERSION} + +# Crosstool-ng has this as a config option. ...why +export CPUS=${CT_PARALLEL_JOBS} + +# Where we need a clean directory to do this GCC hack +export GCC_WORK_DIR="${CT_WORK_DIR}/${ARCH}/build/build-uclibc++-gcc" +rm -rf ${GCC_WORK_DIR} +mkdir -p $GCC_WORK_DIR +cd $GCC_WORK_DIR + +# We need the cross-compiler in our path to do this +export PATH=${CT_PREFIX_DIR}/bin:$PATH + +sed -i 's@^STMP_FIX.*@@' "${GCCSRC}/gcc/Makefile.in" + +CC="${ARCH}-gcc" GCC_FOR_TARGET="${ARCH}-gcc" CC_FOR_TARGET="${ARCH}-gcc" \ + AR="${ARCH}-ar" AR_FOR_TARGET="${ARCH}-ar" AS="${ARCH}-as" LD="${ARCH}-ld" \ + ac_cv_path_AR_FOR_TARGET="${ARCH}-ar" \ + ac_cv_path_RANLIB_FOR_TARGET="${ARCH}-ranlib" \ + ac_cv_path_NM_FOR_TARGET="${ARCH}-nm" \ + NM="${ARCH}-nm" NM_FOR_TARGET="${ARCH}-nm" CXX_FOR_TARGET="${ARCH}-g++" \ + "${GCCSRC}/configure" --prefix=/ --disable-multilib \ + --build="${CROSS_HOST}" --host="${CROSS_TARGET}" --target="${CROSS_TARGET}" \ + --enable-long-long --enable-c99 --enable-shared --enable-threads=posix \ + --enable-__cxa_atexit --disable-nls --enable-languages=c,c++ \ + --disable-libstdcxx-pch --enable-sjlj-exceptions --program-prefix="" + +make -j $CPUS configure-host +make -j $CPUS configure-target-libstdc++-v3 +cd "$CROSS_TARGET"/libstdc++-v3/libsupc++ +make -j $CPUS && + +# The only file we actually needed +cp .libs/libsupc++.a ${CT_PREFIX_DIR}/lib && + +# Build uClibc++ +export UCLIBC_WORK_DIR="${CT_WORK_DIR}/${ARCH}/build/build-uclibc++" +rm -rf ${UCLIBC_WORK_DIR} +mkdir -p ${UCLIBC_WORK_DIR} + +cd ${CT_LOCAL_TARBALLS_DIR} +if [[ ! -f ${CT_LOCAL_TARBALLS_DIR}/uClibc++-0.2.2.tar.bz2 ]]; then + wget http://cxx.uclibc.org/src/uClibc++-0.2.2.tar.bz2 +fi + +cd ${UCLIBC_WORK_DIR} +tar -jxvf ${CT_LOCAL_TARBALLS_DIR}/uClibc++-0.2.2.tar.bz2 + +# Build uClib++ +cd uClibc++-0.2.2 +CROSS= make defconfig && +sed -r -i 's/(UCLIBCXX_HAS_(TLS|LONG_DOUBLE))=y/# \1 is not set/' .config && +sed -r -i '/UCLIBCXX_RUNTIME_PREFIX=/s/".*"/""/' .config && +CROSS= make oldconfig && +CROSS="$ARCH"- make && +CROSS= make install PREFIX="${UCLIBC_WORK_DIR}" + +# Get rid of the old libstd++ files +cd ${UCLIBC_WORK_DIR} +rm "${CT_PREFIX_DIR}"/"${ARCH}"/lib/libstdc++* + +# Use the new ones +cp "${UCLIBC_WORK_DIR}"/lib/* "${CT_PREFIX_DIR}"/"${ARCH}"/lib && +cd "${CT_PREFIX_DIR}"/"${ARCH}"/lib && +ln -s libuClibc++.so libstdc++.so && +ln -s libuClibc++.a libstdc++.a && + +# Get rid of the old C++ include files +rm -rf "${CT_PREFIX_DIR}"/"${ARCH}"/include/c++/${CT_CC_VERSION}/ +mkdir -p "${CT_PREFIX_DIR}"/"${ARCH}"/include/c++/${CT_CC_VERSION}/ + +# And use uClibc++ +cp "${UCLIBC_WORK_DIR}"/include/* "${CT_PREFIX_DIR}"/"${ARCH}"/include/c++/${CT_CC_VERSION}/