summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorYann E. MORIN" <yann.morin.1998@anciens.enib.fr>2007-02-24 11:00:05 (GMT)
committerYann E. MORIN" <yann.morin.1998@anciens.enib.fr>2007-02-24 11:00:05 (GMT)
commit1906cf93f86d8d66f45f90380a8d3da25c087ee5 (patch)
tree90916c99abe1f1ec26709ee420e6c349eda4670a /scripts
parent2609573aede4ce198b3462976725b25eb1637d2e (diff)
Add the full crosstool-NG sources to the new repository of its own.
You might just say: 'Yeah! crosstool-NG's got its own repo!". Unfortunately, that's because the previous repo got damaged beyond repair and I had no backup. That means I'm putting backups in place in the afternoon. That also means we've lost history... :-(
Diffstat (limited to 'scripts')
-rw-r--r--scripts/build/binutils.sh39
-rw-r--r--scripts/build/cc_core_gcc.sh58
-rw-r--r--scripts/build/cc_core_tcc.sh0
-rw-r--r--scripts/build/cc_gcc.sh115
-rw-r--r--scripts/build/cc_tcc.sh0
-rw-r--r--scripts/build/kernel_cygwin.sh0
l---------scripts/build/kernel_linux-libc-headers.sh1
-rw-r--r--scripts/build/kernel_linux.sh148
-rw-r--r--scripts/build/libc_glibc.sh285
-rw-r--r--scripts/build/libc_libfloat.sh31
-rw-r--r--scripts/build/libc_uClibc.sh235
-rw-r--r--scripts/buildToolchain.sh123
-rwxr-xr-xscripts/crosstool.sh273
-rw-r--r--scripts/functions215
-rw-r--r--scripts/getExtractPatch.sh336
15 files changed, 1859 insertions, 0 deletions
diff --git a/scripts/build/binutils.sh b/scripts/build/binutils.sh
new file mode 100644
index 0000000..26493c4
--- /dev/null
+++ b/scripts/build/binutils.sh
@@ -0,0 +1,39 @@
+# This file adds functions to build binutils
+# Copyright 2007 Yann E. MORIN
+# Licensed under the GPL v2. See COPYING in the root of this package
+
+do_binutils() {
+ mkdir -p "${CT_BUILD_DIR}/build-binutils"
+ cd "${CT_BUILD_DIR}/build-binutils"
+
+ CT_DoStep INFO "Installing binutils"
+
+ CT_DoLog EXTRA "Configuring binutils"
+ CFLAGS="${CT_CFLAGS_FOR_HOST}" \
+ "${CT_SRC_DIR}/${CT_BINUTILS_FILE}/configure" \
+ ${CT_CANADIAN_OPT} \
+ --target=${CT_TARGET} \
+ --host=${CT_HOST} \
+ --prefix=${CT_PREFIX_DIR} \
+ --disable-nls \
+ ${CT_BINUTILS_EXTRA_CONFIG} \
+ ${BINUTILS_SYSROOT_ARG} 2>&1 |CT_DoLog DEBUG
+
+ CT_DoLog EXTRA "Building binutils"
+ make ${PARALLELMFLAGS} 2>&1 |CT_DoLog DEBUG
+
+ CT_DoLog EXTRA "Installing binutils"
+ make install 2>&1 |CT_DoLog DEBUG
+
+ # Make those new tools available to the core C compiler to come:
+ # Note: some components want the ${TARGET}-{ar,as,ld,strip} commands as
+ # well. Create that (libfloat is one such sucker).
+ mkdir -p "${CT_CC_CORE_PREFIX_DIR}/${CT_TARGET}/bin"
+ mkdir -p "${CT_CC_CORE_PREFIX_DIR}/bin"
+ for t in ar as ld strip; do
+ ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
+ ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
+ done |CT_DoLog DEBUG
+
+ CT_EndStep
+}
diff --git a/scripts/build/cc_core_gcc.sh b/scripts/build/cc_core_gcc.sh
new file mode 100644
index 0000000..720a581
--- /dev/null
+++ b/scripts/build/cc_core_gcc.sh
@@ -0,0 +1,58 @@
+# This file adds the function to build the core gcc C compiler
+# Copyright 2007 Yann E. MORIN
+# Licensed under the GPL v2. See COPYING in the root of this package
+
+do_cc_core() {
+ mkdir -p "${CT_BUILD_DIR}/build-cc-core"
+ cd "${CT_BUILD_DIR}/build-cc-core"
+
+ CT_DoStep INFO "Installing core C compiler"
+
+ CT_DoLog EXTRA "Copy headers to install area of bootstrap gcc, so it can build libgcc2"
+ mkdir -p "${CT_CC_CORE_PREFIX_DIR}/${CT_TARGET}/include"
+ cp -r "${CT_HEADERS_DIR}"/* "${CT_CC_CORE_PREFIX_DIR}/${CT_TARGET}/include" 2>&1 |CT_DoLog DEBUG
+
+ CT_DoLog EXTRA "Configuring core C compiler"
+
+ extra_config=""
+ [ "${CT_ARCH_FLOAT_SW}" = "y" ] && extra_config="${extra_config} --with-float=soft"
+ [ -n "${CT_ARCH_CPU}" ] && extra_config="${extra_config} --with-cpu=${CT_ARCH_CPU}"
+ [ -n "${CT_ARCH_TUNE}" ] && extra_config="${extra_config} --with-tune=${CT_ARCH_TUNE}"
+ [ -n "${CT_ARCH_ARCH}" ] && extra_config="${extra_config} --with-arch=${CT_ARCH_ARCH}"
+ [ -n "${CT_ARCH_FPU}" ] && extra_config="${extra_config} --with-fpu=${CT_ARCH_FPU}"
+
+ CT_DoLog DEBUG "Extra config passed: \"${extra_config}\""
+
+ # Use --with-local-prefix so older gccs don't look in /usr/local (http://gcc.gnu.org/PR10532)
+ CFLAGS="${CT_CFLAGS_FOR_HOST}" \
+ "${CT_SRC_DIR}/${CT_CC_CORE_FILE}/configure" \
+ ${CT_CANADIAN_OPT} \
+ --target=${CT_TARGET} \
+ --host=${CT_HOST} \
+ --prefix="${CT_CC_CORE_PREFIX_DIR}" \
+ --with-local-prefix="${CT_SYSROOT_DIR}" \
+ --disable-multilib \
+ --with-newlib \
+ ${CC_CORE_SYSROOT_ARG} \
+ ${extra_config} \
+ --disable-nls \
+ --enable-threads=no \
+ --enable-symvers=gnu \
+ --enable-__cxa_atexit \
+ --enable-languages=c \
+ --disable-shared \
+ ${CT_CC_CORE_EXTRA_CONFIG} 2>&1 |CT_DoLog DEBUG
+
+ if [ ! "${CT_CANADIAN}" = "y" ]; then
+ CT_DoLog EXTRA "Building libiberty"
+ make ${PARALLELMFLAGS} all-build-libiberty 2>&1 |CT_DoLog DEBUG
+ fi
+
+ CT_DoLog EXTRA "Building core C compiler"
+ make ${PARALLELMFLAGS} all-gcc 2>&1 |CT_DoLog DEBUG
+
+ CT_DoLog EXTRA "Installing core C compiler"
+ make install-gcc 2>&1 |CT_DoLog DEBUG
+
+ CT_EndStep
+}
diff --git a/scripts/build/cc_core_tcc.sh b/scripts/build/cc_core_tcc.sh
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/scripts/build/cc_core_tcc.sh
diff --git a/scripts/build/cc_gcc.sh b/scripts/build/cc_gcc.sh
new file mode 100644
index 0000000..7621d42
--- /dev/null
+++ b/scripts/build/cc_gcc.sh
@@ -0,0 +1,115 @@
+# This file adds the function to build the final gcc C compiler
+# Copyright 2007 Yann E. MORIN
+# Licensed under the GPL v2. See COPYING in the root of this package
+
+do_cc() {
+ CT_DoStep INFO "Installing final C compiler"
+
+ mkdir -p "${CT_BUILD_DIR}/build-cc"
+ cd "${CT_BUILD_DIR}/build-cc"
+
+ CT_DoLog EXTRA "Configuring C compiler"
+
+ # Enable selected languages
+ lang_opt="c"
+ [ "${CT_CC_LANG_CXX}" = "y" ] && lang_opt="${lang_opt},c++"
+ [ "${CT_CC_LANG_FORTRAN}" = "y" ] && lang_opt="${lang_opt},fortran"
+ [ "${CT_CC_LANG_ADA}" = "y" ] && lang_opt="${lang_opt},ada"
+ [ "${CT_CC_LANG_JAVA}" = "y" ] && lang_opt="${lang_opt},java"
+ [ "${CT_CC_LANG_OBJC}" = "y" ] && lang_opt="${lang_opt},objc"
+ [ "${CT_CC_LANG_OBJCXX}" = "y" ] && lang_opt="${lang_opt},obj-c++"
+ CT_Test "Building Fortran language is not yet supported. Will try..." "${CT_CC_LANG_FORTRAN}" = "y"
+ CT_Test "Building ADA language is not yet supported. Will try..." "${CT_CC_LANG_ADA}" = "y"
+ CT_Test "Building Java language is not yet supported. Will try..." "${CT_CC_LANG_JAVA}" = "y"
+ CT_Test "Building Objective-C language is not yet supported. Will try..." "${CT_CC_LANG_OBJC}" = "y"
+ CT_Test "Building Objective-C++ language is not yet supported. Will try..." "${CT_CC_LANG_OBJCXX}" = "y"
+ CT_Test "Building ${CT_CC_LANG_OTHERS} language(s) is not yet supported. Will try..." -n "${CT_CC_LANG_OTHERS}"
+ lang_opt=`echo "${lang_opt},${CT_CC_LANG_OTHERS}" |sed -r -e 's/^(.*),*$/\1/;'`
+
+ extra_config="--enable-languages=${lang_opt}"
+ [ "${CT_ARCH_FLOAT_SW}" = "y" ] && extra_config="${extra_config} --with-float=soft"
+ [ "${CT_SHARED_LIBS}" = "y" ] || extra_config="${extra_config} --disable-shared"
+ [ -n "${CT_ARCH_CPU}" ] && extra_config="${extra_config} --with-cpu=${CT_ARCH_CPU}"
+ [ -n "${CT_ARCH_TUNE}" ] && extra_config="${extra_config} --with-tune=${CT_ARCH_TUNE}"
+ [ -n "${CT_ARCH_ARCH}" ] && extra_config="${extra_config} --with-arch=${CT_ARCH_ARCH}"
+ [ -n "${CT_ARCH_FPU}" ] && extra_config="${extra_config} --with-fpu=${CT_ARCH_FPU}"
+ if [ "${CT_TARGET_MULTILIB}" = "y" ]; then
+ extra_config="${extra_config} --enable-multilib"
+ else
+ extra_config="${extra_config} --disable-multilib"
+ fi
+
+ CT_DoLog DEBUG "Extra config passed: \"${extra_config}\""
+
+ # --enable-symvers=gnu really only needed for sh4 to work around a
+ # detection problem only matters for gcc-3.2.x and later, I think.
+ # --disable-nls to work around crash bug on ppc405, but also because
+ # embedded systems don't really need message catalogs...
+ CFLAGS="${CT_CFLAGS_FOR_HOST}" \
+ "${CT_SRC_DIR}/${CT_CC_FILE}/configure" \
+ ${CT_CANADIAN_OPT} \
+ --target=${CT_TARGET} --host=${CT_HOST} \
+ --prefix="${CT_PREFIX_DIR}" \
+ ${CC_SYSROOT_ARG} \
+ ${extra_config} \
+ --with-local-prefix="${CT_SYSROOT_DIR}" \
+ --disable-nls \
+ --enable-threads=posix \
+ --enable-symvers=gnu \
+ --enable-__cxa_atexit \
+ --enable-c99 \
+ --enable-long-long \
+ ${CT_CC_EXTRA_CONFIG} 2>&1 |CT_DoLog DEBUG
+
+ if [ ! "${CT_CANADIAN}" = "y" ]; then
+ CT_DoLog EXTRA "Building libiberty"
+ make ${PARALLELMFLAGS} all-build-libiberty 2>&1 |CT_DoLog DEBUG
+ fi
+
+
+ # Idea from <cort.dougan at gmail.com>:
+ # Fix lib/lib64 confusion for GCC 3.3.3 on PowerPC64 and x86_64.
+ # GCC 3.4.0 and up don't suffer from this confusion, and don't need this
+ # kludge.
+ # FIXME: we should patch gcc's source rather than uglify crosstool.sh.
+ # FIXME: is this needed for gcc-3.3.[56]?
+ case "${CT_CC_FILE}" in
+ gcc-3.3.[34])
+ case "${CT_TARGET}" in
+ powerpc64-unknown-linux-gnu|x86_64-unknown-linux-gnu)
+ for d in `find "${CT_SYSROOT_DIR}" -name lib -type d -empty`; do
+ if [ -d `dirname "${d}"`/lib64 ] ; then
+ rm -rf "${d}"
+ ln -s `dirname "${d}"`/lib64 "${d}"
+ fi
+ done ;;
+ *) ;;
+ esac ;;
+ esac
+
+ CT_DoLog EXTRA "Building C compiler"
+ make ${PARALLELMFLAGS} all 2>&1 |CT_DoLog DEBUG
+
+ CT_DoLog EXTRA "Installing C compiler"
+ make install 2>&1 |CT_DoLog DEBUG
+
+ # FIXME: shouldn't people who want this just --disable-multilib in final gcc
+ # and be done with it?
+ # This code should probably be deleted, it was written long ago and hasn't
+ # been tested in ages.
+ # kludge: If the chip does not have a floating point unit
+ # (i.e. if GLIBC_EXTRA_CONFIG contains --without-fp),
+ # and there are shared libraries in /lib/nof, copy them to /lib
+ # so they get used by default.
+ # FIXME: only rs6000/powerpc seem to use nof. See MULTILIB_DIRNAMES
+ # in $GCC_DIR/gcc/config/$TARGET/* to see what your arch calls it.
+ #case "${CT_LIBC_EXTRA_CONFIG}" in
+ # *--without-fp*)
+ # if test -d "${CT_SYSROOT_DIR}/lib/nof"; then
+ # cp -af "${CT_SYSROOT_DIR}/lib/nof/"*.so* "${CT_SYSROOT_DIR}/lib" || true
+ # fi
+ # ;;
+ #esac
+
+ CT_EndStep
+}
diff --git a/scripts/build/cc_tcc.sh b/scripts/build/cc_tcc.sh
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/scripts/build/cc_tcc.sh
diff --git a/scripts/build/kernel_cygwin.sh b/scripts/build/kernel_cygwin.sh
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/scripts/build/kernel_cygwin.sh
diff --git a/scripts/build/kernel_linux-libc-headers.sh b/scripts/build/kernel_linux-libc-headers.sh
new file mode 120000
index 0000000..05c7045
--- /dev/null
+++ b/scripts/build/kernel_linux-libc-headers.sh
@@ -0,0 +1 @@
+kernel_linux.sh \ No newline at end of file
diff --git a/scripts/build/kernel_linux.sh b/scripts/build/kernel_linux.sh
new file mode 100644
index 0000000..caf35d1
--- /dev/null
+++ b/scripts/build/kernel_linux.sh
@@ -0,0 +1,148 @@
+# This file declares functions to install the kernel headers for linux
+# Copyright 2007 Yann E. MORIN
+# Licensed under the GPL v2. See COPYING in the root of this package
+
+# Check kernel configuration
+do_kernel_check_config() {
+ CT_DoStep INFO "Checking kernel configuration"
+
+ CT_TestOrAbort "You did not provide a kernel config file!" -n "${CT_KERNEL_LINUX_CONFIG_FILE}" -a -f "${CT_KERNEL_LINUX_CONFIG_FILE}"
+
+ CT_EndStep
+}
+
+# Wrapper to the actual headers install method
+do_kernel_headers() {
+ CT_DoStep INFO "Installing kernel headers"
+
+ # We need to enter this directory to find the kernel version strings
+ cd "${CT_SRC_DIR}/${CT_KERNEL_FILE}"
+ if [ "${CT_KERNEL_LINUX_HEADERS_SANITISED}" != "y" ]; then
+ k_version=`awk '/^VERSION =/ { print $3 }' Makefile`
+ k_patchlevel=`awk '/^PATCHLEVEL =/ { print $3 }' Makefile`
+ k_sublevel=`awk '/^SUBLEVEL =/ { print $3 }' Makefile`
+ k_extraversion=`awk '/^EXTRAVERSION =/ { print $3 }' Makefile`
+ else
+ k_version=`echo "${CT_KERNEL_VERSION}." |cut -d . -f 1`
+ k_patchlevel=`echo "${CT_KERNEL_VERSION}." |cut -d . -f 2`
+ k_sublevel=`echo "${CT_KERNEL_VERSION}." |cut -d . -f 3`
+ k_extraversion=`echo "${CT_KERNEL_VERSION}." |cut -d . -f 4`
+ fi
+
+ case "${k_version}.${k_patchlevel}" in
+ 2.2|2.4|2.6) ;;
+ *) CT_Abort "Unsupported kernel version \"linux-${k_version}.${k_patchlevel}\".";;
+ esac
+
+ # Kernel version that support verbosity will use this, others will ignore it:
+ V_OPT="V=${CT_KERNEL_LINUX_VERBOSE_LEVEL}"
+
+ if [ "${CT_KERNEL_LINUX_HEADERS_INSTALL}" = "y" ]; then
+ do_kernel_install
+ elif [ "${CT_KERNEL_LINUX_HEADERS_SANITISED}" = "y" ]; then
+ do_kernel_sanitised
+ else [ "${CT_KERNEL_LINUX_HEADERS_COPY}" = "y" ];
+ do_kernel_copy
+ fi
+
+ CT_EndStep
+}
+
+# Install kernel headers using headers_install from kernel sources.
+do_kernel_install() {
+ CT_DoLog EXTRA "Using kernel's headers_install"
+
+ mkdir -p "${CT_BUILD_DIR}/build-kernel-headers"
+ cd "${CT_BUILD_DIR}/build-kernel-headers"
+
+ case "${k_version}.${k_patchlevel}" in
+ 2.6) [ ${k_sublevel} -ge 18 ] || CT_Abort "Kernel version >= 2.6.18 is needed to install kernel headers.";;
+ *) CT_Abort "Kernel version >= 2.6.18 is needed to install kernel headers.";;
+ esac
+
+ CT_DoLog EXTRA "Configuring kernel headers"
+ cp "${CT_KERNEL_LINUX_CONFIG_FILE}" .config
+ CT_DoYes "" |make -C "${CT_SRC_DIR}/${CT_KERNEL_FILE}" \
+ O="${CT_BUILD_DIR}/build-kernel-headers" \
+ ${V_OPT} \
+ ARCH=${CT_KERNEL_ARCH} oldconfig 2>&1 |CT_DoLog DEBUG
+
+ CT_DoLog EXTRA "Installing kernel headers"
+ make ARCH=${CT_KERNEL_ARCH} \
+ INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \
+ ${V_OPT} \
+ headers_install 2>&1 |CT_DoLog DEBUG
+
+ CT_DoLog EXTRA "Checking installed headers"
+ make ARCH=${CT_KERNEL_ARCH} \
+ INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \
+ ${V_OPT} \
+ headers_check 2>&1 |CT_DoLog DEBUG
+}
+
+# Install kernel headers from oldish Mazur's sanitised headers.
+do_kernel_sanitised() {
+ CT_DoLog EXTRA "Copying sanitised headers"
+ cd "${CT_SRC_DIR}/${CT_KERNEL_FILE}"
+ cp -rv include/linux "${CT_HEADERS_DIR}" 2>&1 |CT_DoLog DEBUG
+ cp -rv "include/asm-${CT_KERNEL_ARCH}" "${CT_HEADERS_DIR}/asm" 2>&1 |CT_DoLog DEBUG
+}
+
+# Install kernel headers by plain copy.
+do_kernel_copy() {
+ CT_DoLog EXTRA "Copying plain kernel headers"
+ CT_DoLog WARN "You are using plain kernel headers. You really shouldn't do that."
+ CT_DoLog WARN "You'd be better off by using installed headers (or sanitised headers)."
+
+ # 2.2 and 2.4 don't support building out-of-tree. 2.6 does.
+ CT_DoLog EXTRA "Preparing kernel headers"
+ case "${k_version}.${k_patchlevel}" in
+ 2.2|2.4) cd "${CT_SRC_DIR}/${CT_KERNEL_FILE}"
+ cp "${CT_KERNEL_LINUX_CONFIG_FILE}" .config
+ CT_DoYes "" |make ARCH=${CT_KERNEL_ARCH} oldconfig
+ # 2.4 doesn't follow V=# for verbosity... :-(
+ make ARCH=${CT_KERNEL_ARCH} symlinks include/linux/version.h
+ ;;
+ 2.6) mkdir -p "${CT_BUILD_DIR}/build-kernel-headers"
+ cd "${CT_BUILD_DIR}/build-kernel-headers"
+ cp "${CT_KERNEL_LINUX_CONFIG_FILE}" .config
+ CT_DoYes "" |make -C "${CT_SRC_DIR}/${CT_KERNEL_FILE}" \
+ O="`pwd`" ${V_OPT} ARCH=${CT_KERNEL_ARCH} \
+ oldconfig
+ case "${CT_KERNEL_ARCH}" in
+ sh*) # sh does secret stuff in 'make prepare' that can't be
+ # triggered separately, but happily, it doesn't use
+ # target gcc, so we can use it.
+ # Update: this fails on 2.6.11, as it installs
+ # elfconfig.h, which requires target compiler :-(
+ make ${PARALLELMFLAGS} \
+ ARCH=${CT_KERNEL_ARCH} ${V_OPT} \
+ prepare include/linux/version.h
+ ;;
+ arm*|cris*) make ${PARALLELMFLAGS} \
+ ARCH=${CT_KERNEL_ARCH} ${V_OPT} \
+ include/asm include/linux/version.h \
+ include/asm-${CT_KERNEL_ARCH}/.arch
+ ;;
+ mips*) # for linux-2.6, 'make prepare' for mips doesn't
+ # actually create any symlinks. Hope generic is ok.
+ # Note that glibc ignores all -I flags passed in CFLAGS,
+ # so you have to use -isystem.
+ make ${PARALLELMFLAGS} \
+ ARCH=${CT_KERNEL_ARCH} ${V_OPT} \
+ include/asm include/linux/version.h
+ TARGET_CFLAGS="${TARGET_CFLAGS} -isystem ${LINUX_HEADER_DIR}/include/asm-mips/mach-generic"
+ ;;
+ *) make ${PARALLELMFLAGS} \
+ ARCH=${CT_KERNEL_ARCH} ${V_OPT} \
+ include/asm include/linux/version.h
+ ;;
+ esac
+ ;;
+ esac 2>&1 |CT_DoLog DEBUG
+
+ CT_DoLog EXTRA "Copying kernel headers"
+ cp -rv include/asm-generic "${CT_HEADERS_DIR}/asm-generic" 2>&1 |CT_DoLog DEBUG
+ cp -rv include/linux "${CT_HEADERS_DIR}" 2>&1 |CT_DoLog DEBUG
+ cp -rv include/asm-${CT_KERNEL_ARCH} "${CT_HEADERS_DIR}/asm" 2>&1 |CT_DoLog DEBUG
+}
diff --git a/scripts/build/libc_glibc.sh b/scripts/build/libc_glibc.sh
new file mode 100644
index 0000000..2fa9ac7
--- /dev/null
+++ b/scripts/build/libc_glibc.sh
@@ -0,0 +1,285 @@
+# This file adds functions to build glibc
+# Copyright 2007 Yann E. MORIN
+# Licensed under the GPL v2. See COPYING in the root of this package
+
+# There is nothing to do for glibc check config
+do_libc_check_config() {
+ CT_DoStep INFO "Checking C library configuration"
+ CT_DoLog EXTRA "glibc has nothing to check"
+ CT_EndStep
+}
+
+# This function installs the glibc headers needed to build the core compiler
+do_libc_headers() {
+ # Only need to install bootstrap glibc headers for gcc-3.0 and above? Or maybe just gcc-3.3 and above?
+ # See also http://gcc.gnu.org/PR8180, which complains about the need for this step.
+ grep -q 'gcc-[34]' "${CT_SRC_DIR}/${CT_CC_CORE_FILE}/ChangeLog" || return 0
+
+ CT_DoStep INFO "Installing C library headers"
+
+ mkdir -p "${CT_BUILD_DIR}/build-libc-headers"
+ cd "${CT_BUILD_DIR}/build-libc-headers"
+
+ CT_DoLog EXTRA "Configuring C library headers"
+
+ # The following three things have to be done to build glibc-2.3.x, but they don't hurt older versions.
+ # 1. override CC to keep glibc's configure from using $TARGET-gcc.
+ # 2. disable linuxthreads, which needs a real cross-compiler to generate tcb-offsets.h properly
+ # 3. build with gcc 3.2 or later
+ # Compare these options with the ones used when building glibc for real below - they're different.
+ # As of glibc-2.3.2, to get this step to work for hppa-linux, you need --enable-hacker-mode
+ # so when configure checks to make sure gcc has access to the assembler you just built...
+ # Alternately, we could put ${PREFIX}/${TARGET}/bin on the path.
+ # Set --build so maybe we don't have to specify "cross-compiling=yes" below (haven't tried yet)
+ # Note: the warning
+ # "*** WARNING: Are you sure you do not want to use the `linuxthreads'"
+ # *** add-on?"
+ # is ok here, since all we want are the basic headers at this point.
+ # Override libc_cv_ppc_machine so glibc-cvs doesn't complain
+ # 'a version of binutils that supports .machine "altivec" is needed'.
+ libc_cv_ppc_machine=yes \
+ CC=${CT_CC_NATIVE} \
+ "${CT_SRC_DIR}/${CT_LIBC_FILE}/configure" \
+ --build="${CT_BUILD}" \
+ --host="${CT_TARGET}" \
+ --prefix=/usr \
+ --with-headers="${CT_HEADERS_DIR}" \
+ --without-cvs --disable-sanity-checks \
+ --enable-hacker-mode \
+ --enable-add-ons="" \
+ --without-nptl 2>&1 |CT_DoLog DEBUG
+
+ CT_DoLog EXTRA "Installing C library headers"
+
+ if grep -q GLIBC_2.3 "${CT_SRC_DIR}/${CT_LIBC_FILE}/ChangeLog"; then
+ # glibc-2.3.x passes cross options to $(CC) when generating errlist-compat.c,
+ # which fails without a real cross-compiler.
+ # Fortunately, we don't need errlist-compat.c, since we just need .h
+ # files, so work around this by creating a fake errlist-compat.c and
+ # satisfying its dependencies.
+ # Another workaround might be to tell configure to not use any cross
+ # options to $(CC).
+ # The real fix would be to get install-headers to not generate
+ # errlist-compat.c.
+ # Note: BOOTSTRAP_GCC is used by:
+ # patches/glibc-2.3.5/glibc-mips-bootstrap-gcc-header-install.patch
+ libc_cv_ppc_machine=yes \
+ make CFLAGS=-DBOOTSTRAP_GCC sysdeps/gnu/errlist.c 2>&1 |CT_DoLog DEBUG
+ mkdir -p stdio-common
+ # sleep for 2 seconds for benefit of filesystems with lousy time
+ # resolution, like FAT, so make knows for sure errlist-compat.c doesn't
+ # need generating
+ sleep 2
+ touch stdio-common/errlist-compat.c
+ fi
+ # Note: BOOTSTRAP_GCC (see above)
+ libc_cv_ppc_machine=yes \
+ make cross-compiling=yes install_root=${CT_SYSROOT_DIR} \
+ CFLAGS=-DBOOTSTRAP_GCC ${LIBC_SYSROOT_ARG} \
+ install-headers 2>&1 |CT_DoLog DEBUG
+
+ # Two headers -- stubs.h and features.h -- aren't installed by install-headers,
+ # so do them by hand. We can tolerate an empty stubs.h for the moment.
+ # See e.g. http://gcc.gnu.org/ml/gcc/2002-01/msg00900.html
+ mkdir -p "${CT_HEADERS_DIR}/gnu"
+ touch "${CT_HEADERS_DIR}/gnu/stubs.h"
+ cp "${CT_SRC_DIR}/${CT_LIBC_FILE}/include/features.h" "${CT_HEADERS_DIR}/features.h"
+
+ # Building the bootstrap gcc requires either setting inhibit_libc, or
+ # having a copy of stdio_lim.h... see
+ # http://sources.redhat.com/ml/libc-alpha/2003-11/msg00045.html
+ cp bits/stdio_lim.h "${CT_HEADERS_DIR}/bits/stdio_lim.h"
+
+ # Following error building gcc-4.0.0's gcj:
+ # error: bits/syscall.h: No such file or directory
+ # solved by following copy; see http://sourceware.org/ml/crossgcc/2005-05/msg00168.html
+ # but it breaks arm, see http://sourceware.org/ml/crossgcc/2006-01/msg00091.html
+ [ "${CT_ARCH}" != "arm" ] && cp misc/syscall-list.h "${CT_HEADERS_DIR}/bits/syscall.h" || true
+
+ CT_EndStep
+}
+
+# This function builds and install the full glibc
+do_libc() {
+ CT_DoStep INFO "Installing C library"
+
+ mkdir -p "${CT_BUILD_DIR}/build-libc"
+ cd "${CT_BUILD_DIR}/build-libc"
+
+ CT_DoLog EXTRA "Configuring C library"
+
+ # Add some default glibc config options if not given by user.
+ extra_config=""
+ case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
+ *enable-kernel*) ;;
+ *) extra_config="${extra_config} --enable-kernel=${CT_KERNEL_VERSION}"
+ esac
+ case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
+ *-tls*) ;;
+ *) extra_config="${extra_config} --without-tls"
+ esac
+ case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
+ *-__thread*) ;;
+ *) extra_config="${extra_config} --without-__thread"
+ esac
+ case "${CT_SHARED_LIBS}" in
+ y) extra_config="${extra_config} --enable-shared";;
+ *) extra_config="${extra_config} --disable-shared";;
+ esac
+ case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
+ *--with-fp*) ;;
+ *--without-fp*) ;;
+ *) case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
+ y,) extra_config="${extra_config} --with-fp";;
+ ,y) extra_config="${extra_config} --without-fp";;
+ esac;;
+ esac
+ case "${CT_LIBC_ADDONS},${CT_LIBC_ADDONS_LIST}" in
+ y,) extra_config="${extra_config} --enable-add-ons";;
+ y,*) extra_config="${extra_config} --enable-add-ons=${CT_LIBC_ADDONS_LIST}";;
+ esac
+
+ CT_DoLog DEBUG "Extra config args passed: \"${extra_config}\""
+
+ # Add some default CC args
+ extra_cc_args=
+ case "${CT_LIBC_EXTRA_CC_ARGS}" in
+ *-mbig-endian*) ;;
+ *-mlittle-endian*) ;;
+ *) case "${CT_ARCH_BE},${CT_ARCH_LE}" in
+ y,) extra_cc_args="${extra_cc_args} -mbig-endian";;
+ ,y) extra_cc_args="${extra_cc_args} -mlittle-endian";;
+ esac;;
+ esac
+
+ CT_DoLog DEBUG "Extra CC args passed: \"${extra_cc_args}\""
+
+ # sh3 and sh4 really need to set configparms as of gcc-3.4/glibc-2.3.2
+ # note: this is awkward, doesn't work well if you need more than one line in configparms
+ echo ${CT_LIBC_GLIBC_CONFIGPARMS} > configparms
+
+ # For glibc 2.3.4 and later we need to set some autoconf cache
+ # variables, because nptl/sysdeps/pthread/configure.in does not
+ # work when cross-compiling.
+ if test -d ${GLIBC_DIR}/nptl; then
+ libc_cv_forced_unwind=yes
+ libc_cv_c_cleanup=yes
+ export libc_cv_forced_unwind libc_cv_c_cleanup
+ fi
+
+ # Configure with --prefix the way we want it on the target...
+ # There are a whole lot of settings here. You'll probably want
+ # to read up on what they all mean, and customize a bit, possibly by setting GLIBC_EXTRA_CONFIG
+ # Compare these options with the ones used when installing the glibc headers above - they're different.
+ # Adding "--without-gd" option to avoid error "memusagestat.c:36:16: gd.h: No such file or directory"
+ # See also http://sources.redhat.com/ml/libc-alpha/2000-07/msg00024.html.
+ # Set BUILD_CC, or you won't be able to build datafiles
+ # Set --build, else glibc-2.3.2 will think you're not cross-compiling, and try to run the test programs
+
+ BUILD_CC=${CT_CC_NATIVE} \
+ CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O" \
+ CC="${CT_TARGET}-gcc ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}" \
+ AR=${CT_TARGET}-ar \
+ RANLIB=${CT_TARGET}-ranlib \
+ "${CT_SRC_DIR}/${CT_LIBC_FILE}/configure" \
+ --prefix=/usr \
+ --build=${CT_BUILD} --host=${CT_TARGET} \
+ ${CT_LIBC_GLIBC_EXTRA_CONFIG} \
+ ${extra_config} \
+ --without-cvs \
+ --disable-profile \
+ --disable-debug \
+ --without-gd \
+ --with-headers="${CT_HEADERS_DIR}" 2>&1 |CT_DoLog DEBUG
+
+ if grep -l '^install-lib-all:' "${CT_SRC_DIR}/${CT_LIBC_FILE}/Makerules" > /dev/null; then
+ # nptl-era glibc.
+ # If the install-lib-all target (which is added by our make-install-lib-all.patch)
+ # is present, it means we're building glibc-2.3.3 or later, and we can't
+ # build programs yet, as they require libeh, which won't be installed
+ # until full build of gcc
+ GLIBC_INITIAL_BUILD_RULE=lib
+ GLIBC_INITIAL_INSTALL_RULE="install-lib-all install-headers"
+ GLIBC_INSTALL_APPS_LATER=yes
+ else
+ # classic glibc.
+ # We can build and install everything with the bootstrap compiler.
+ GLIBC_INITIAL_BUILD_RULE=all
+ GLIBC_INITIAL_INSTALL_RULE=install
+ GLIBC_INSTALL_APPS_LATER=no
+ fi
+
+ # If this fails with an error like this:
+ # ... linux/autoconf.h: No such file or directory
+ # then you need to set the KERNELCONFIG variable to point to a .config file for this arch.
+ # The following architectures are known to need kernel .config: alpha, arm, ia64, s390, sh, sparc
+ # Note: LD and RANLIB needed by glibc-2.1.3's c_stub directory, at least on macosx
+ # No need for PARALLELMFLAGS here, Makefile already reads this environment variable
+ CT_DoLog EXTRA "Building C library"
+ make LD=${CT_TARGET}-ld \
+ RANLIB=${CT_TARGET}-ranlib \
+ ${GLIBC_INITIAL_BUILD_RULE} 2>&1 |CT_DoLog DEBUG
+
+ CT_DoLog EXTRA "Installing C library"
+ make install_root="${CT_SYSROOT_DIR}" \
+ ${LIBC_SYSROOT_ARG} \
+ ${GLIBC_INITIAL_INSTALL_RULE} 2>&1 |CT_DoLog DEBUG
+
+ # This doesn't seem to work when building a crosscompiler,
+ # as it tries to execute localedef using the just-built ld.so!?
+ #CT_DoLog EXTRA "Installing locales"
+ #make localedata/install-locales install_root=${SYSROOT} 2>&1 |CT_DoLog DEBUG
+
+ # Fix problems in linker scripts.
+ #
+ # 1. Remove absolute paths
+ # Any file in a list of known suspects that isn't a symlink is assumed to be a linker script.
+ # FIXME: test -h is not portable
+ # FIXME: probably need to check more files than just these three...
+ # Need to use sed instead of just assuming we know what's in libc.so because otherwise alpha breaks
+ #
+ # 2. Remove lines containing BUG per http://sources.redhat.com/ml/bug-glibc/2003-05/msg00055.html,
+ # needed to fix gcc-3.2.3/glibc-2.3.2 targeting arm
+ #
+ # To make "strip *.so.*" not fail (ptxdist does this), rename to .so_orig rather than .so.orig
+ CT_DoLog EXTRA "Fixing C library linker scripts"
+ for file in libc.so libpthread.so libgcc_s.so; do
+ for dir in lib lib64 usr/lib usr/lib64; do
+ if [ -f "${CT_SYSROOT_DIR}/${dir}/${file}" -a ! -L ${CT_SYSROOT_DIR}/$lib/$file ]; then
+ mv "${CT_SYSROOT_DIR}/${dir}/${file}" "${CT_SYSROOT_DIR}/${dir}/${file}_orig"
+ CT_DoLog DEBUG "Fixing \"${CT_SYS_ROOT_DIR}/${dir}/${file}\""
+ sed -i -r -e 's,/usr/lib/,,g;
+ s,/usr/lib64/,,g;
+ s,/lib/,,g;
+ s,/lib64/,,g;
+ /BUG in libc.scripts.output-format.sed/d' "${CT_SYSROOT_DIR}/${dir}/${file}_orig"
+ fi
+ done
+ done
+
+ CT_EndStep
+}
+
+# This function finishes the glibc install
+do_libc_finish() {
+ # Finally, build and install glibc programs, now that libeh (if any) is installed
+ # Don't do this unless needed, 'cause it causes glibc-2.{1.3,2.2} to fail here with
+ # .../gcc-3.4.1-glibc-2.1.3/build-glibc/libc.so.6: undefined reference to `__deregister_frame_info'
+ # .../gcc-3.4.1-glibc-2.1.3/build-glibc/libc.so.6: undefined reference to `__register_frame_info'
+ [ "${GLIBC_INSTALL_APPS_LATER}" = "yes" ] || return 0
+
+ CT_DoStep INFO "Finishing C library"
+
+ cd "${CT_BUILD_DIR}/build-libc"
+
+ CT_DoLog EXTRA "Re-building C library"
+ make LD=${CT_TARGET}-ld RANLIB=${CT_TARGET}-ranlib 2>&1 |CT_DoLog DEBUG
+
+ CT_DoLog EXTRA "Installing missing C library components"
+ # note: should do full install and then fix linker scripts, but this is faster
+ for t in bin rootsbin sbin data others; do
+ make install_root="${CT_SYSROOT_DIR}" \
+ ${LIBC_SYSROOT_ARG} \
+ install-${t} 2>&1 |CT_DoLog DEBUG
+ done
+}
diff --git a/scripts/build/libc_libfloat.sh b/scripts/build/libc_libfloat.sh
new file mode 100644
index 0000000..3828a3f
--- /dev/null
+++ b/scripts/build/libc_libfloat.sh
@@ -0,0 +1,31 @@
+# This file adds functions to build libfloat
+# Copyright 2007 Yann E. MORIN
+# Licensed under the GPL v2. See COPYING in the root of this package
+
+do_libfloat() {
+ # Here we build and install libfloat for the target, so that the C library
+ # builds OK with those versions of gcc that have severed softfloat support
+ # code
+ [ "${CT_ARCH_FLOAT_SW_LIBFLOAT}" = "y" ] || return 0
+ CT_DoStep INFO "Installing software floating point emulation library libfloat"
+
+ CT_Pushd "${CT_BUILD_DIR}"
+ CT_DoLog EXTRA "Copying sources to build dir"
+ mkdir build-libfloat
+ cd build-libfloat
+ ( cd "${CT_SRC_DIR}/${CT_LIBFLOAT_FILE}"; tar cf - . ) |tar xvf - |CT_DoLog DEBUG
+
+ CT_DoLog EXTRA "Cleaning library"
+ make clean 2>&1 |CT_DoLog DEBUG
+
+ CT_DoLog EXTRA "Building library"
+ make CROSS_COMPILE="${CT_CC_CORE_PREFIX_DIR}/bin/${CT_TARGET}-" 2>&1 |CT_DoLog DEBUG
+
+ CT_DoLog EXTRA "Installing library"
+ make CROSS_COMPILE="${CT_CC_CORE_PREFIX_DIR}/bin/${CT_TARGET}-" \
+ DESTDIR="${CT_SYSROOT_DIR}" install 2>&1 |CT_DoLog DEBUG
+
+ CT_Popd
+
+ CT_EndStep
+}
diff --git a/scripts/build/libc_uClibc.sh b/scripts/build/libc_uClibc.sh
new file mode 100644
index 0000000..171736d
--- /dev/null
+++ b/scripts/build/libc_uClibc.sh
@@ -0,0 +1,235 @@
+# This file declares functions to install the uClibc C library
+# Copyright 2007 Yann E. MORIN
+# Licensed under the GPL v2. See COPYING in the root of this package
+
+
+# Check that uClibc has been previously configured
+do_libc_check_config() {
+ CT_DoStep INFO "Checking C library configuration"
+
+ CT_TestOrAbort "You did not provide a uClibc config file!" -n "${CT_LIBC_UCLIBC_CONFIG_FILE}" -a -f "${CT_LIBC_UCLIBC_CONFIG_FILE}"
+
+ cp "${CT_LIBC_UCLIBC_CONFIG_FILE}" "${CT_BUILD_DIR}/uClibc.config"
+
+ if egrep '^KERNEL_SOURCE=' "${CT_LIBC_UCLIBC_CONFIG_FILE}" >/dev/null 2>&1; then
+ CT_DoLog WARN "Your uClibc version refers to the kernel _sources_, which is bad."
+ CT_DoLog WARN "I can't guarantee that our little hack will work. Please try to upgrade."
+ fi
+
+ CT_DoLog EXTRA "Munging uClibc configuration"
+ mungeuClibcConfig "${CT_BUILD_DIR}/uClibc.config"
+
+ CT_EndStep
+}
+
+# This functions installs uClibc's headers
+do_libc_headers() {
+ # Only need to install bootstrap uClibc headers for gcc-3.0 and above? Or maybe just gcc-3.3 and above?
+ # See also http://gcc.gnu.org/PR8180, which complains about the need for this step.
+ grep -q 'gcc-[34]' "${CT_SRC_DIR}/${CT_CC_CORE_FILE}/ChangeLog" || return 0
+
+ CT_DoStep INFO "Installing C library headers"
+
+ mkdir -p "${CT_BUILD_DIR}/build-libc-headers"
+ cd "${CT_BUILD_DIR}/build-libc-headers"
+
+ # Simply copy files until uClibc has the ablity to build out-of-tree
+ CT_DoLog EXTRA "Copying sources to build dir"
+ { cd "${CT_SRC_DIR}/${CT_LIBC_FILE}"; tar cf - .; } |tar xf -
+
+ # Retrieve the config file
+ cp "${CT_BUILD_DIR}/uClibc.config" .config
+
+ # uClibc uses the CROSS environment variable as a prefix to the
+ # compiler tools to use. Setting it to the empty string forces
+ # use of the native build host tools, which we need at this
+ # stage, as we don't have target tools yet.
+ CT_DoLog EXTRA "Applying configuration"
+ CT_DoYes "" |make CROSS= PREFIX="${CT_SYSROOT_DIR}/" oldconfig 2>&1 |CT_DoLog DEBUG
+
+ CT_DoLog EXTRA "Building headers"
+ make ${PARALLELMFLAGS} CROSS= PREFIX="${CT_SYSROOT_DIR}/" headers 2>&1 |CT_DoLog DEBUG
+
+ CT_DoLog EXTRA "Installing headers"
+ make CROSS= PREFIX="${CT_SYSROOT_DIR}/" install_dev 2>&1 |CT_DoLog DEBUG
+
+ CT_EndStep
+}
+
+# This function build and install the full uClibc
+do_libc() {
+ CT_DoStep INFO "Installing C library"
+
+ mkdir -p "${CT_BUILD_DIR}/build-libc"
+ cd "${CT_BUILD_DIR}/build-libc"
+
+ # Simply copy files until uClibc has the ablity to build out-of-tree
+ CT_DoLog EXTRA "Copying sources to build dir"
+ { cd "${CT_SRC_DIR}/${CT_LIBC_FILE}"; tar cf - .; } |tar xf -
+
+ # Retrieve the config file
+ cp "${CT_BUILD_DIR}/uClibc.config" .config
+
+ # uClibc uses the CROSS environment variable as a prefix to the compiler
+ # tools to use. The newly built tools should be in our path, so we need
+ # only give the correct name for them.
+ # Note about CFLAGS: In uClibc, CFLAGS are generated by Rules.mak,
+ # depending on the configuration of the library. That is, they are tailored
+ # to best fit the target. So it is useless and seems to be a bad thing to
+ # use LIBC_EXTRA_CFLAGS here.
+ CT_DoLog EXTRA "Applying configuration"
+ CT_DoYes "" |make ${PARALLELMFLAGS} \
+ CROSS=${CT_TARGET}- \
+ PREFIX="${CT_SYSROOT_DIR}/" \
+ oldconfig 2>&1 |CT_DoLog DEBUG
+
+ # We do _not_ want to strip anything for now, in case we specifically
+ # asked for a debug toolchain, thus the STRIPTOOL= assignment
+ CT_DoLog EXTRA "Building C library"
+ make ${PARALLELMFLAGS} \
+ CROSS=${CT_TARGET}- \
+ PREFIX="${CT_SYSROOT_DIR}/" \
+ STRIPTOOL=true \
+ all 2>&1 |CT_DoLog DEBUG
+
+ # YEM-FIXME: we want to install libraries in $SYSROOT/lib, but we don't want
+ # to install headers in $SYSROOT/include, thus making only install_runtime.
+ # Plus, the headers were previously installed earlier with install_dev, so
+ # all should be well. Unfortunately, the install_dev target does not install
+ # crti.o and consorts... :-( So reverting to target 'install'.
+ # Note: PARALLELMFLAGS is not usefull for installation.
+ # We do _not_ want to strip anything for now, in case we specifically
+ # asked for a debug toolchain, thus the STRIPTOOL= assignment
+ CT_DoLog EXTRA "Installing C library"
+ make CROSS=${CT_TARGET}- \
+ PREFIX="${CT_SYSROOT_DIR}/" \
+ STRIPTOOL=true \
+ install 2>&1 |CT_DoLog DEBUG
+
+ CT_EndStep
+}
+
+# This function is used to install those components needing the final C compiler
+do_libc_finish() {
+ CT_DoStep INFO "Finishing C library"
+ # uClibc has nothing to finish
+ CT_DoLog EXTRA "uClibc has nothing to finish"
+ CT_EndStep
+}
+
+# Initialises the .config file to sensible values
+mungeuClibcConfig() {
+ config_file="$1"
+ munge_file="${CT_BUILD_DIR}/munge-uClibc-config.sed"
+
+ cat > "${munge_file}" <<-ENDSED
+s/^(TARGET_.*)=y$/# \\1 is not set/
+s/^# TARGET_${CT_KERNEL_ARCH} is not set/TARGET_${CT_KERNEL_ARCH}=y/
+s/^TARGET_ARCH=".*"/TARGET_ARCH="${CT_KERNEL_ARCH}"/
+ENDSED
+
+ case "${CT_ARCH_BE},${CT_ARCH_LE}" in
+ y,) cat >> "${munge_file}" <<-ENDSED
+s/.*(ARCH_BIG_ENDIAN).*/\\1=y/
+s/.*(ARCH_LITTLE_ENDIAN).*/# \\1 is not set/
+ENDSED
+ ;;
+ ,y) cat >> "${munge_file}" <<-ENDSED
+s/.*(ARCH_BIG_ENDIAN).*/# \\1 is not set/
+s/.*(ARCH_LITTLE_ENDIAN).*/\\1=y/
+ENDSED
+ ;;
+ esac
+
+ case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
+ y,) cat >> "${munge_file}" <<-ENDSED
+s/.*(HAS_FPU).*/\\1=y/
+ENDSED
+ ;;
+ ,y) cat >> "${munge_file}" <<-ENDSED
+s/.*(HAS_FPU).*/\\# \\1 is not set/
+ENDSED
+ ;;
+ esac
+
+ # Change paths to work with crosstool
+ # From http://www.uclibc.org/cgi-bin/viewcvs.cgi?rev=16846&view=rev
+ # " we just want the kernel headers, not the whole kernel source ...
+ # " so people may need to update their paths slightly
+ quoted_kernel_source=`echo "${CT_HEADERS_DIR}" | sed -r -e 's,/include/?$,,; s,/,\\\\/,g;'`
+ quoted_headers_dir=`echo ${CT_HEADERS_DIR} | sed -r -e 's,/,\\\\/,g;'`
+ # CROSS_COMPILER_PREFIX is left as is, as the CROSS parameter is forced on the command line
+ # DEVEL_PREFIX is left as '/usr/' because it is post-pended to $PREFIX, wich is the correct value of ${PREFIX}/${TARGET}
+ # Some (old) versions of uClibc use KERNEL_SOURCE (which is _wrong_), and
+ # newer versions use KERNEL_HEADERS (which is right). See:
+ cat >> "${munge_file}" <<-ENDSED
+s/^DEVEL_PREFIX=".*"/DEVEL_PREFIX="\\/usr\\/"/
+s/^RUNTIME_PREFIX=".*"/RUNTIME_PREFIX="\\/"/
+s/^SHARED_LIB_LOADER_PREFIX=.*/SHARED_LIB_LOADER_PREFIX="\\/lib\\/"/
+s/^KERNEL_SOURCE=".*"/KERNEL_SOURCE="${quoted_kernel_source}"/
+s/^KERNEL_HEADERS=".*"/KERNEL_HEADERS="${quoted_headers_dir}"/
+s/^UCLIBC_DOWNLOAD_PREGENERATED_LOCALE=y/\\# UCLIBC_DOWNLOAD_PREGENERATED_LOCALE is not set/
+ENDSED
+
+ # Hack our -pipe into WARNINGS, which will be internally incorporated to
+ # CFLAGS. This a dirty hack, but yet needed
+ if [ "${CT_USE_PIPES}" = "y" ]; then
+ cat >> "${munge_file}" <<-ENDSED
+s/^(WARNINGS=".*)"$/\\1 -pipe"/
+ENDSED
+ fi
+
+ # Force on options needed for C++ if we'll be making a C++ compiler.
+ # Note that the two PREGEN_LOCALE and the XLOCALE lines may be missing
+ # entirely if LOCALE is not set. If LOCALE was already set, we'll
+ # assume the user has already made all the appropriate generation
+ # arrangements. Note that having the uClibc Makefile download the
+ # pregenerated locales is not compatible with crosstool; besides,
+ # crosstool downloads them as part of getandpatch.sh.
+ if [ "${CT_CC_LANG_CXX}" = "y" ]; then
+ cat >> "${munge_file}" <<-ENDSED
+s/^# DO_C99_MATH is not set/DO_C99_MATH=y/
+s/^# UCLIBC_CTOR_DTOR is not set/UCLIBC_CTOR_DTOR=y/
+# Add these three lines when doing C++?
+#s/^# UCLIBC_HAS_WCHAR is not set/UCLIBC_HAS_WCHAR=y/
+#s/^# UCLIBC_HAS_LOCALE is not set/UCLIBC_HAS_LOCALE=y\\nUCLIBC_PREGENERATED_LOCALE_DATA=y\\n\\# UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA is not set\\n\\# UCLIBC_HAS_XLOCALE is not set/
+#s/^# UCLIBC_HAS_GNU_GETOPT is not set/UCLIBC_HAS_GNU_GETOPT=y/
+ENDSED
+ fi
+
+ # Force on debug options if asked for
+ case "${CT_LIBC_UCLIBC_DEBUG_LEVEL}" in
+ 0)
+ cat >>"${munge_file}" <<-ENDSED
+s/^PTHREADS_DEBUG_SUPPORT=y/# PTHREADS_DEBUG_SUPPORT is not set/
+s/^DODEBUG=y/# DODEBUG is not set/
+s/^DODEBUG_PT=y/# DODEBUG_PT is not set/
+s/^DOASSERTS=y/# DOASSERTS is not set/
+s/^SUPPORT_LD_DEBUG=y/# SUPPORT_LD_DEBUG is not set/
+s/^SUPPORT_LD_DEBUG_EARLY=y/# SUPPORT_LD_DEBUG_EARLY is not set/
+ENDSED
+ ;;
+ 1)
+ cat >>"${munge_file}" <<-ENDSED
+s/^# PTHREADS_DEBUG_SUPPORT is not set.*/PTHREADS_DEBUG_SUPPORT=y/
+s/^# DODEBUG is not set.*/DODEBUG=y/
+s/^DODEBUG_PT=y/# DODEBUG_PT is not set/
+s/^DOASSERTS=y/# DOASSERTS is not set/
+s/^SUPPORT_LD_DEBUG=y/# SUPPORT_LD_DEBUG is not set/
+s/^SUPPORT_LD_DEBUG_EARLY=y/# SUPPORT_LD_DEBUG_EARLY is not set/
+ENDSED
+ ;;
+ 2)
+ cat >>"${munge_file}" <<-ENDSED
+s/^# PTHREADS_DEBUG_SUPPORT is not set.*/PTHREADS_DEBUG_SUPPORT=y/
+s/^# DODEBUG is not set.*/DODEBUG=y/
+s/^# DODEBUG_PT is not set.*/DODEBUG_PT=y/
+s/^# DOASSERTS is not set.*/DOASSERTS=y/
+s/^# SUPPORT_LD_DEBUG is not set.*/SUPPORT_LD_DEBUG=y/
+s/^# SUPPORT_LD_DEBUG_EARLY is not set.*/SUPPORT_LD_DEBUG_EARLY=y/
+ENDSED
+ ;;
+ esac
+ sed -r -i -f "${munge_file}" "${config_file}"
+ rm -f "${munge_file}"
+}
diff --git a/scripts/buildToolchain.sh b/scripts/buildToolchain.sh
new file mode 100644
index 0000000..dff1f6f
--- /dev/null
+++ b/scripts/buildToolchain.sh
@@ -0,0 +1,123 @@
+# This scripts calls each component's build script.
+# Copyright 2007 Yann E. MORIN
+# Licensed under the GPL v2. See COPYING in the root of this package
+
+# Parse all build files to have the needed functions.
+. "${CT_TOP_DIR}/scripts/build/kernel_${CT_KERNEL}.sh"
+. "${CT_TOP_DIR}/scripts/build/binutils.sh"
+. "${CT_TOP_DIR}/scripts/build/libc_libfloat.sh"
+. "${CT_TOP_DIR}/scripts/build/libc_${CT_LIBC}.sh"
+. "${CT_TOP_DIR}/scripts/build/cc_core_${CT_CC_CORE}.sh"
+. "${CT_TOP_DIR}/scripts/build/cc_${CT_CC}.sh"
+
+# Arrange paths depending on wether we use sys-root or not.
+if [ "${CT_USE_SYSROOT}" = "y" ]; then
+ CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/sys-root"
+ CT_HEADERS_DIR="${CT_SYSROOT_DIR}/usr/include"
+ BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
+ CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
+ CC_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
+ LIBC_SYSROOT_ARG=""
+ # glibc's prefix must be exactly /usr, else --with-sysroot'd gcc will get
+ # confused when $sysroot/usr/include is not present.
+ # Note: --prefix=/usr is magic!
+ # See http://www.gnu.org/software/libc/FAQ.html#s-2.2
+else
+ # plain old way. All libraries in prefix/target/lib
+ CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}"
+ CT_HEADERS_DIR="${CT_SYSROOT_DIR}/include"
+ # hack! Always use --with-sysroot for binutils.
+ # binutils 2.14 and later obey it, older binutils ignore it.
+ # Lets you build a working 32->64 bit cross gcc
+ BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
+ # Use --with-headers, else final gcc will define disable_glibc while
+ # building libgcc, and you'll have no profiling
+ CC_CORE_SYSROOT_ARG="--without-headers"
+ CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}"
+ LIBC_SYSROOT_ARG="prefix="
+fi
+
+# Prepare the 'lib' directories in sysroot, else the ../lib64 hack used by
+# 32 -> 64 bit crosscompilers won't work, and build of final gcc will fail with
+# "ld: cannot open crti.o: No such file or directory"
+mkdir -p "${CT_SYSROOT_DIR}/lib"
+mkdir -p "${CT_SYSROOT_DIR}/usr/lib"
+
+# Canadian-cross are really picky on the way they are built. Tweak the values.
+if [ "${CT_CANADIAN}" = "y" ]; then
+ # Arrange so that gcc never, ever think that build system == host system
+ CT_CANADIAN_OPT="--build=`echo \"${CT_BUILD}\" |sed -r -e 's/-/-build_/'`"
+ # We shall have a compiler for this target!
+ # Do test here...
+else
+ CT_HOST="${CT_BUILD}"
+ CT_CANADIAN_OPT=
+ # Add the target toolchain in the path so that we can build the C library
+ export PATH="${CT_PREFIX_DIR}/bin:${CT_CC_CORE_PREFIX_DIR}/bin:${PATH}"
+fi
+
+# Modify GCC_HOST to never be equal to $BUILD or $TARGET
+# This strange operation causes gcc to always generate a cross-compiler
+# even if the build machine is the same kind as the host.
+# This is why CC has to be set when doing a canadian cross; you can't find a
+# host compiler by appending -gcc to our whacky $GCC_HOST
+# Kludge: it is reported that the above causes canadian crosses with cygwin
+# hosts to fail, so avoid it just in that one case. It would be cleaner to
+# just move this into the non-canadian case above, but I'm afraid that might
+# cause some configure script somewhere to decide that since build==host, they
+# could run host binaries.
+# (Copied almost as-is from original crosstool):
+case "${CT_KERNEL},${CT_CANADIAN}" in
+ cygwin,y) ;;
+ *) CT_HOST="`echo \"${CT_HOST}\" |sed -r -e 's/-/-host_/;'`";;
+esac
+
+# Ha. cygwin host have an .exe suffix (extension) for executables.
+[ "${CT_KERNEL}" = "cygwin" ] && EXEEXT=".exe" || EXEEXT=""
+
+# Transform the ARCH into a kernel-understandable ARCH
+case "${CT_ARCH}" in
+ x86) CT_KERNEL_ARCH=i386;;
+ ppc) CT_KERNL_ARCH=powerpc;;
+ *) CT_KERNEL_ARCH="${CT_ARCH}";;
+esac
+
+# Build up the TARGET_CFLAGS from user-provided options
+tmp_target_CFLAGS=
+[ -n "${CT_ARCH_CPU}" ] && tmp_target_CFLAGS="${tmp_target_CFLAGS} -mcpu=${CT_ARCH_CPU}"
+[ -n "${CT_ARCH_TUNE}" ] && tmp_target_CFLAGS="${tmp_target_CFLAGS} -mtune=${CT_ARCH_TUNE}"
+[ -n "${CT_ARCH_ARCH}" ] && tmp_target_CFLAGS="${tmp_target_CFLAGS} -march=${CT_ARCH_ARCH}"
+[ -n "${CT_ARCH_FPU}" ] && tmp_target_CFLAGS="${tmp_target_CFLAGS} -mfpu=${CT_ARCH_FPU}"
+# Override with user-specified CFLAGS
+CT_TARGET_CFLAGS="${tmp_target_CFLAGS} ${CT_TARGET_CFLAGS}"
+
+# Help gcc
+CT_CFLAGS_FOR_HOST=
+[ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST="${CT_CFLAGS_FOR_HOST} -pipe"
+
+# And help make go faster
+PARALLELMFLAGS=
+[ ${CT_PARALLEL_JOBS} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -j${CT_PARALLEL_JOBS}"
+[ ${CT_LOAD} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -l${CT_LOAD}"
+
+CT_DoStep EXTRA "Dumping internal crosstool-NG configuration"
+CT_DoLog EXTRA "Building a toolchain for :"
+CT_DoLog EXTRA " build = ${CT_BUILD}"
+CT_DoLog EXTRA " host = ${CT_HOST}"
+CT_DoLog EXTRA " target = ${CT_TARGET}"
+set |egrep '^CT_.+=' |sort |CT_DoLog DEBUG
+CT_EndStep
+
+# Now for the job by itself.
+# Check the C library config ASAP, before the user gets bored, and is
+# gone having his/her coffee
+do_libc_check_config
+do_kernel_check_config
+do_kernel_headers
+do_binutils
+do_libc_headers
+do_cc_core
+do_libfloat
+do_libc
+do_cc
+do_libc_finish
diff --git a/scripts/crosstool.sh b/scripts/crosstool.sh
new file mode 100755
index 0000000..48ddca2
--- /dev/null
+++ b/scripts/crosstool.sh
@@ -0,0 +1,273 @@
+#!/bin/bash
+# Copyright 2007 Yann E. MORIN
+# Licensed under the GPL v2. See COPYING in the root of this package.
+
+# This is the main entry point to crosstool
+# This will:
+# - download, extract and patch the toolchain components
+# - build and install each components in turn
+# - and eventually test the resulting toolchain
+
+# What this file does is prepare the environment, based upon the user-choosen
+# options. It also checks the existing environment for un-friendly variables,
+# and checks for needed tools. It eventually calls the main build script.
+
+# User must set CT_TOP_DIR in is environment!
+# Once we can build out-of-tree, then this will have to go.
+if [ -z "${CT_TOP_DIR}" -o ! -d "${CT_TOP_DIR}" ]; then
+ # We don't have the functions right now, because we don't have CT_TOP_DIR.
+ # Do the print stuff by hand:
+ echo "CT_TOP_DIR not set. You must set CT_TOP_DIR to the top directory where crosstool is installed."
+ exit 1
+fi
+
+# Parse the common functions
+. "${CT_TOP_DIR}/scripts/functions"
+
+CT_STAR_DATE=`CT_DoDate +%s%N`
+CT_STAR_DATE_HUMAN=`CT_DoDate +%Y%m%d.%H%M%S`
+
+# Log to a temporary file until we have built our environment
+CT_ACTUAL_LOG_FILE="`pwd`/$$.log"
+
+# CT_TOP_DIR should be an absolute path.
+CT_TOP_DIR="`CT_MakeAbsolutePath \"${CT_TOP_DIR}\"`"
+
+# Parse the configuration file
+CT_TestOrAbort "Configuration file not found. Please create one." -f "${CT_TOP_DIR}/.config"
+. "${CT_TOP_DIR}/.config"
+
+# The progress bar indicator is asked for
+if [ "${CT_LOG_PROGRESS_BAR}" = "y" ]; then
+ _CT_PROG_BAR() {
+ [ $((cpt/5)) -eq 0 ] && echo -en "/"
+ [ $((cpt/5)) -eq 1 ] && echo -en "-"
+ [ $((cpt/5)) -eq 2 ] && echo -en "\\"
+ [ $((cpt/5)) -eq 3 ] && echo -en "|"
+ echo -en "\r"
+ cpt=$(((cpt+1)%20))
+ }
+ CT_PROG_BAR=_CT_PROG_BAR
+ export -f _CT_PROG_BAR
+else
+ CT_PROG_BAR=
+fi
+
+# Apply the color scheme if needed
+if [ "${CT_LOG_USE_COLORS}" = "y" ]; then
+ CT_ERROR_COLOR="${_A_NOR}${_A_BRI}${_F_RED}"
+ CT_WARN_COLOR="${_A_NOR}${_A_BRI}${_F_YEL}"
+ CT_INFO_COLOR="${_A_NOR}${_A_BRI}${_F_GRN}"
+ CT_EXTRA_COLOR="${_A_NOR}${_A_DIM}${_F_GRN}"
+ CT_DEBUG_COLOR="${_A_NOR}${_A_DIM}${_F_WHI}"
+ CT_NORMAL_COLOR="${_A_NOR}"
+else
+ CT_ERROR_COLOR=
+ CT_WARN_COLOR=
+ CT_INFO_COLOR=
+ CT_EXTRA_COLOR=
+ CT_DEBUG_COLOR=
+ CT_NORMAL_COLOR=
+fi
+
+# Yes! We can do full logging from now on!
+CT_DoLog INFO "Build started ${CT_STAR_DATE_HUMAN}"
+
+# Some sanity checks in the environment and needed tools
+CT_DoLog INFO "Checking environment sanity"
+
+# Enable known ordering of files in directory listings:
+CT_Test "Crosstool-NG might not work as expected with LANG=\"${LANG}\"" -n "${LANG}"
+case "${LC_COLLATE},${LC_ALL}" in
+ # These four combinations are known to sort files in the correct order:
+ fr_FR*,) ;;
+ en_US*,) ;;
+ *,fr_FR*) ;;
+ *,en_US*) ;;
+ # Anything else is destined to be borked if not gracefuly handled:
+ *) CT_DoLog WARN "Either LC_COLLATE=\"${LC_COLLATE}\" or LC_ALL=\"${LC_ALL}\" is not supported."
+ export LC_ALL=`locale -a |egrep "^(fr_FR|en_US)" |head -n 1`
+ CT_TestOrAbort "Neither en_US* nor fr_FR* locales found on your system." -n "${LC_ALL}"
+ CT_DoLog WARN "Forcing to known working LC_ALL=\"${LC_ALL}\"."
+ ;;
+esac
+
+# Other environment sanity checks
+CT_TestAndAbort "Don't set LD_LIBRARY_PATH. It screws up the build." -n "${LD_LIBRARY_PATH}"
+CT_TestAndAbort "Don't set CFLAGS. It screws up the build." -n "${CFLAGS}"
+CT_TestAndAbort "Don't set CXXFLAGS. It screws up the build." -n "${CXXFLAGS}"
+CT_Test "GREP_OPTIONS screws up the build. Resetting." -n "${GREP_OPTIONS}"
+GREP_OPTIONS=
+CT_HasOrAbort awk
+CT_HasOrAbort sed
+CT_HasOrAbort bison
+CT_HasOrAbort flex
+
+CT_DoStep DEBUG "Dumping crosstool-NG configuration"
+cat ${CT_TOP_DIR}/.config |egrep '^(# |)CT_' |CT_DoLog DEBUG
+CT_EndStep
+
+CT_DoLog INFO "Building environment variables"
+
+# This should go in buildToolchain.sh, but we might need it because it could
+# be used by the user in his/her paths definitions.
+# Target triplet: CT_TARGET needs a little love:
+case "${CT_ARCH_BE},${CT_ARCH_LE}" in
+ y,) target_endian_eb=eb; target_endian_el=;;
+ ,y) target_endian_eb=; target_endian_el=el;;
+esac
+case "${CT_ARCH}" in
+ arm) CT_TARGET="${CT_ARCH}${target_endian_eb}";;
+ mips) CT_TARGET="${CT_ARCH}${target_endian_el}";;
+ x86*) # Much love for this one :-(
+ # Ultimately, we should use config.sub to output the correct
+ # procesor name. Work for later...
+ arch="${CT_ARCH_ARCH}"
+ [ -z "${arch}" ] && arch="${CT_ARCH_TUNE}"
+ case "${CT_ARCH}" in
+ x86_64) CT_TARGET=x86_64;;
+ *) case "${arch}" in
+ "") CT_TARGET=i386;;
+ i386|i486|i586|i686) CT_TARGET="${arch}";;
+ winchip*) CT_TARGET=i486;;
+ pentium|pentium-mmx|c3*) CT_TARGET=i586;;
+ nocona|athlon*64|k8|athlon-fx|opteron) CT_TARGET=x86_64;;
+ pentiumpro|pentium*|athlon*) CT_TARGET=i686;;
+ *) CT_TARGET=i586;;
+ esac;;
+ esac;;
+esac
+case "${CT_TARGET_VENDOR}" in
+ "") CT_TARGET="${CT_TARGET}-unknown";;
+ *) CT_TARGET="${CT_TARGET}-${CT_TARGET_VENDOR}";;
+esac
+case "${CT_KERNEL}" in
+ linux*) CT_TARGET="${CT_TARGET}-linux";;
+ cygwin*) CT_TARGET="${CT_TARGET}-cygwin";;
+esac
+case "${CT_LIBC}" in
+ glibc) CT_TARGET="${CT_TARGET}-gnu";;
+ uClibc) CT_TARGET="${CT_TARGET}-uclibc";;
+esac
+CT_TARGET="`${CT_TOP_DIR}/tools/config.sub ${CT_TARGET}`"
+
+# Now, build up the variables from the user-configured options.
+CT_KERNEL_FILE="${CT_KERNEL}-${CT_KERNEL_VERSION}"
+CT_BINUTILS_FILE="binutils-${CT_BINUTILS_VERSION}"
+if [ "${CT_CC_USE_CORE}" != "y" ]; then
+ CT_CC_CORE="${CT_CC}"
+ CT_CC_CORE_VERSION="${CT_CC_VERSION}"
+ CT_CC_CORE_EXTRA_CONFIG="${CT_CC_EXTRA_CONFIG}"
+fi
+CT_CC_CORE_FILE="${CT_CC_CORE}-${CT_CC_CORE_VERSION}"
+CT_CC_FILE="${CT_CC}-${CT_CC_VERSION}"
+CT_LIBC_FILE="${CT_LIBC}-${CT_LIBC_VERSION}"
+[ "${CT_ARCH_FLOAT_SW_LIBFLOAT}" = "y" ] && CT_LIBFLOAT_FILE="libfloat-990616"
+
+# Kludge: If any of the configured options needs CT_TARGET or CT_TOP_DIR,
+# then rescan the options file now:
+. "${CT_TOP_DIR}/.config"
+
+# Determine build system if not set by the user
+CT_Test "You did not specify the build system. Guessing." -z "${CT_BUILD}"
+CT_BUILD="`${CT_TOP_DIR}/tools/config.sub \"${CT_BUILD:-\`${CT_TOP_DIR}/tools/config.guess\`}\"`"
+
+# Get rid of pre-existing installed toolchain and previous build directories.
+# We need to do that _before_ we can safely log, because the log file will
+# most probably be in the toolchain directory.
+if [ -d "${CT_PREFIX_DIR}" ]; then
+ mv "${CT_PREFIX_DIR}" "${CT_PREFIX_DIR}.$$"
+ nohup rm -rf "${CT_PREFIX_DIR}.$$" >/dev/null 2>&1 &
+fi
+mkdir -p "${CT_PREFIX_DIR}"
+if [ -d "${CT_BUILD_DIR}" ]; then
+ mv "${CT_BUILD_DIR}" "${CT_BUILD_DIR}.$$"
+ nohup rm -rf "${CT_BUILD_DIR}.$$" >/dev/null 2>&1 &
+fi
+mkdir -p "${CT_BUILD_DIR}"
+
+# Check now if we can write to the destination directory:
+if [ -d "${CT_PREFIX_DIR}" ]; then
+ CT_TestAndAbort "Destination directory \"${CT_INSTALL_DIR}\" is not writeable" ! -w "${CT_PREFIX_DIR}"
+else
+ mkdir -p "${CT_PREFIX_DIR}" || CT_Abort "Could not create destination directory \"${CT_PREFIX_DIR}\""
+fi
+
+# Redirect log to the actual log file now we can
+# It's quite understandable that the log file will be installed in the
+# install directory, so we must first ensure it exists and is writeable (above)
+# before we can log there
+t="${CT_ACTUAL_LOG_FILE}"
+case "${CT_LOG_TO_FILE},${CT_LOG_FILE}" in
+ ,*) CT_ACTUAL_LOG_FILE=/dev/null
+ rm -f "${t}"
+ ;;
+ y,/*) mkdir -p "`dirname \"${CT_LOG_FILE}\"`"
+ CT_ACTUAL_LOG_FILE="${CT_LOG_FILE}"
+ mv "${t}" "${CT_ACTUAL_LOG_FILE}"
+ ;;
+ y,*) mkdir -p "`pwd`/`dirname \"${CT_LOG_FILE}\"`"
+ CT_ACTUAL_LOG_FILE="`pwd`/${CT_LOG_FILE}"
+ mv "${t}" "${CT_ACTUAL_LOG_FILE}"
+ ;;
+esac
+
+# Some more sanity checks now that we have all paths set up
+case "${CT_TARBALLS_DIR},${CT_SRC_DIR},${CT_BUILD_DIR},${CT_PREFIX_DIR},${CT_INSTALL_DIR}" in
+ *" "*) CT_Abort "Don't use spaces in paths, it breaks things.";;
+esac
+
+# Note: we'll always install the core compiler in its own directory, so as to
+# not mix the two builds: core and final. Anyway, its generic, wether we use
+# a different compiler as core, or not.
+CT_CC_CORE_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core"
+
+# Good, now grab a bit of informations on the system we're being run,
+# just in case something goes awok, and it's not our fault:
+CT_SYS_HOSTNAME=`hostname -f 2>/dev/null || true`
+# Hmmm. Some non-DHCP-enabled machines do not have an FQDN... Fall back to node name.
+CT_SYS_HOSTNAME="${CT_SYS_HOSTNAME:-`uname -n`}"
+CT_SYS_KERNEL=`uname -s`
+CT_SYS_REVISION=`uname -r`
+# MacOS X lacks '-o' :
+CT_SYS_OS=`uname -o || echo Unkown`
+CT_SYS_MACHINE=`uname -m`
+CT_SYS_PROCESSOR=`uname -p`
+CT_SYS_USER="`id -un`"
+CT_SYS_DATE=`CT_DoDate +%Y%m%d.%H%M%S`
+CT_SYS_GCC=`gcc -dumpversion`
+CT_TOOLCHAIN_ID="crosstool-${CT_VERSION} build ${CT_SYS_DATE} by ${CT_SYS_USER}@${CT_SYS_HOSTNAME} for ${CT_TARGET}"
+
+# renice oursleves
+renice ${CT_NICE} $$ |CT_DoLog DEBUG
+
+# Include sub-scripts instead of calling them: that way, we do not have to
+# export any variable, nor re-parse the configuration and functions files.
+. "${CT_TOP_DIR}/scripts/getExtractPatch.sh"
+. "${CT_TOP_DIR}/scripts/buildToolchain.sh"
+#. "${CT_TOP_DIR}/scripts/testToolchain.sh"
+
+if [ -n "${CT_TARGET_ALIAS}" ]; then
+ CT_DoLog EXTRA "Creating symlinks from \"${CT_TARGET}-*\" to \"${CT_TARGET_ALIAS}-*\""
+ CT_Pushd "${CT_PREFIX_DIR}/bin"
+ for t in "${CT_TARGET}-"*; do
+ _t="`echo \"$t\" |sed -r -e 's/^'\"${CT_TARGET}\"'-/'\"${CT_TARGET_ALIAS}\"'-/;'`"
+ CT_DoLog DEBUG "Linking \"${_t}\" -> \"${t}\""
+ ln -s "${t}" "${_t}"
+ done
+ CT_Popd
+fi
+
+CT_STOP_DATE=`CT_DoDate +%s%N`
+CT_STOP_DATE_HUMAN=`CT_DoDate +%Y%m%d.%H%M%S`
+CT_DoLog INFO "Build completed at ${CT_STOP_DATE_HUMAN}"
+elapsed=$((CT_STOP_DATE-CT_STAR_DATE))
+elapsed_min=$((elapsed/(60*1000*1000*1000)))
+elapsed_sec=`printf "%02d" $(((elapsed%(60*1000*1000*1000))/(1000*1000*1000)))`
+elapsed_csec=`printf "%02d" $(((elapsed%(1000*1000*1000))/(10*1000*1000)))`
+CT_DoLog INFO "(elapsed: ${elapsed_min}:${elapsed_sec}.${elapsed_csec})"
+
+# Restore a 'normal' color setting
+echo -en "${CT_NORMAL_COLOR}"
+
+trap - EXIT
diff --git a/scripts/functions b/scripts/functions
new file mode 100644
index 0000000..2e7859d
--- /dev/null
+++ b/scripts/functions
@@ -0,0 +1,215 @@
+# This file contains some usefull common functions
+# Copyright 2007 Yann E. MORIN
+# Licensed under the GPL v2. See COPYING in the root of this package
+
+CT_OnError() {
+ ret=$?
+ CT_DoLog ERROR "Build failed in step \"${CT_STEP_MESSAGE[${CT_STEP_COUNT}]}\""
+ for((step=(CT_STEP_COUNT-1); step>1; step--)); do
+ CT_DoLog ERROR " called in step \"${CT_STEP_MESSAGE[${step}]}\""
+ done
+ CT_DoLog ERROR "Error happened in \"${BASH_SOURCE[1]}\" in function \"${FUNCNAME[1]}\" (line unknown, sorry)"
+ for((depth=2; ${BASH_LINENO[$((${depth}-1))]}>0; depth++)); do
+ CT_DoLog ERROR " called from \"${BASH_SOURCE[${depth}]}\" at line # ${BASH_LINENO[${depth}-1]} in function \"${FUNCNAME[${depth}]}\""
+ done
+ CT_DoLog ERROR "Look at \"${CT_ACTUAL_LOG_FILE}\" for more info on this error."
+ exit $ret
+}
+trap CT_OnError ERR
+
+set -E
+set -o pipefail
+
+# This is crosstool-ng-0.0.1
+CT_VERSION=ng-0.0.1
+
+# The different log levels:
+CT_LOG_LEVEL_ERROR=0
+CT_LOG_LEVEL_WARN=1
+CT_LOG_LEVEL_INFO=2
+CT_LOG_LEVEL_EXTRA=3
+CT_LOG_LEVEL_DEBUG=4
+
+# Attributes
+_A_NOR="\\033[0m"
+_A_BRI="\\033[1m"
+_A_DIM="\\033[2m"
+_A_UND="\\033[4m"
+_A_BRB="\\033[5m"
+_A_REV="\\033[7m"
+_A_HID="\\033[8m"
+
+# Fore colors
+_F_BLK="\\033[30m"
+_F_RED="\\033[31m"
+_F_GRN="\\033[32m"
+_F_YEL="\\033[33m"
+_F_BLU="\\033[34m"
+_F_MAG="\\033[35m"
+_F_CYA="\\033[36m"
+_F_WHI="\\033[37m"
+
+# A function to log what is happening
+# Different log level are available:
+# - ERROR: A serious, fatal error occurred
+# - WARN: A non fatal, non serious error occurred, take your responsbility with the generated build
+# - INFO: Informational messages
+# - EXTRA: Extra informational messages
+# - DEBUG: Debug messages
+# Usage: CT_DoLog <level> [message]
+# If message is empty, then stdin will be logged.
+CT_DoLog() {
+ local max_level
+ local level
+ eval max_level="\${CT_LOG_LEVEL_${CT_LOG_LEVEL_MAX}}"
+ # Set the maximum log level to DEBUG if we have none
+ [ -z ${max_level} ] && max_level=${CT_LOG_LEVEL_DEBUG}
+
+ local LEVEL="$1"
+ shift
+ eval level="\${CT_LOG_LEVEL_${LEVEL}}"
+
+ if [ $# -eq 0 ]; then
+ cat -
+ else
+ echo "${1}"
+ fi |( IFS="\n" # We want the full lines, even leading spaces
+ cpt=0
+ indent=$((2*CT_STEP_COUNT))
+ while read line; do
+ l="`printf \"[%-5s]%*s%s%s\" \"${LEVEL}\" \"${indent}\" \" \" \"${line}\"`"
+ # There will always be a log file, be it /dev/null
+ echo -e "${l}" >>"${CT_ACTUAL_LOG_FILE}"
+ color="CT_${LEVEL}_COLOR"
+ normal="CT_NORMAL_COLOR"
+ if [ ${level} -le ${max_level} ]; then
+ echo -e "${!color}${l}${!normal}"
+ else
+ ${CT_PROG_BAR}
+ fi
+ done
+ )
+
+ return 0
+}
+
+# Abort the execution with a error message
+# Usage: CT_Abort <message>
+CT_Abort() {
+ CT_DoLog ERROR "$1" >&2
+ exit 1
+}
+
+# Test a condition, and print a message if satisfied
+# Usage: CT_Test <message> <tests>
+CT_Test() {
+ local ret
+ local m="$1"
+ shift
+ test "$@" && CT_DoLog WARN "$m"
+ return 0
+}
+
+# Test a condition, and abort with an error message if satisfied
+# Usage: CT_TestAndAbort <message> <tests>
+CT_TestAndAbort() {
+ local m="$1"
+ shift
+ test "$@" && CT_Abort "$m"
+ return 0
+}
+
+# Test a condition, and abort with an error message if not satisfied
+# Usage: CT_TestAndAbort <message> <tests>
+CT_TestOrAbort() {
+ local m="$1"
+ shift
+ test "$@" || CT_Abort "$m"
+ return 0
+}
+
+# Test the presence of a tool, or abort if not found
+# Usage: CT_HasOrAbort <tool>
+CT_HasOrAbort() {
+ CT_TestAndAbort "\"${1}\" not found and needed for successfull toolchain build." -z "`which \"${1}\"`"
+ return 0
+}
+
+# Get current date with nanosecond precision
+# On those system not supporting nanosecond precision, faked with rounding down
+# to the highest entire second
+# Usage: CT_DoDate <fmt>
+CT_DoDate() {
+ date "$1" |sed -r -e 's/%N$/000000000/;'
+}
+
+CT_STEP_COUNT=1
+CT_STEP_MESSAGE[${CT_STEP_COUNT}]="<none>"
+# Memorise a step being done so that any error is caught
+# Usage: CT_DoStep <loglevel> <message>
+CT_DoStep() {
+ local start=`CT_DoDate +%s%N`
+ CT_DoLog "$1" "================================================================="
+ CT_DoLog "$1" "$2"
+ CT_STEP_COUNT=$((CT_STEP_COUNT+1))
+ CT_STEP_LEVEL[${CT_STEP_COUNT}]="$1"; shift
+ CT_STEP_START[${CT_STEP_COUNT}]="${start}"
+ CT_STEP_MESSAGE[${CT_STEP_COUNT}]="$1"
+ return 0
+}
+
+# End the step just being done
+# Usage: CT_EndStep
+CT_EndStep() {
+ local stop=`CT_DoDate +%s%N`
+ local duration=`printf "%032d" $((stop-${CT_STEP_START[${CT_STEP_COUNT}]})) |sed -r -e 's/([[:digit:]]{2})[[:digit:]]{7}$/\.\1/; s/^0+//; s/^\./0\./;'`
+ local level="${CT_STEP_LEVEL[${CT_STEP_COUNT}]}"
+ local message="${CT_STEP_MESSAGE[${CT_STEP_COUNT}]}"
+ CT_STEP_COUNT=$((CT_STEP_COUNT-1))
+ CT_DoLog "${level}" "${message}: done in ${duration}s"
+ return 0
+}
+
+# Pushes into a directory, and pops back
+CT_Pushd() {
+ pushd "$1" >/dev/null 2>&1
+}
+CT_Popd() {
+ popd >/dev/null 2>&1
+}
+
+# Makes a path absolute
+# Usage: CT_MakeAbsolutePath path
+CT_MakeAbsolutePath() {
+ # Try to cd in that directory
+ if [ -d "$1" ]; then
+ CT_Pushd "$1"
+ pwd
+ CT_Popd
+ else
+ # No such directory, fail back to guessing
+ case "$1" in
+ /*) echo "$1";;
+ *) echo "`pwd`/$1";;
+ esac
+ fi
+
+ return 0
+}
+
+# Creates a temporary directory
+# $1: variable to assign to
+# Usage: CT_MktempDir foo
+CT_MktempDir() {
+ # Some mktemp do not allow more than 6 Xs
+ eval "$1"="`mktemp -q -d \"${CT_BUILD_DIR}/.XXXXXX\"`"
+ CT_TestOrAbort "Could not make temporary directory" -n "${!1}" -a -d "${!1}"
+}
+
+# Echoes the specified string on stdout until the pipe breaks.
+# Doesn't fail
+# $1: string to echo
+# Usage: CT_DoYes "" |make oldconfig
+CT_DoYes() {
+ yes "$1" || true
+}
diff --git a/scripts/getExtractPatch.sh b/scripts/getExtractPatch.sh
new file mode 100644
index 0000000..ed411b8
--- /dev/null
+++ b/scripts/getExtractPatch.sh
@@ -0,0 +1,336 @@
+# This script will download tarballs, extract them and patch the source.
+# Copyright 2007 Yann E. MORIN
+# Licensed under the GPL v2. See COPYING in the root of this package
+
+# Download tarballs in sequence. Once we have everything, start extracting
+# and patching the tarballs.
+
+#-----------------------------------------------------------------------------
+
+_wget=`which wget || true`
+_curl=`which curl || true`
+#_svn=`which svn ||true`
+#_cvs=`which cvs || true`
+
+case "${_wget},${_curl}" in
+ ,) CT_Abort "Found neither curl nor wget. Please install one.";;
+ ,*) CT_DoLog DEBUG "Using curl to retrieve tarballs"; CT_DoGetFile=CT_DoGetFileCurl;;
+ *) CT_DoLog DEBUG "Using wget to retrieve tarballs"; CT_DoGetFile=CT_DoGetFileWget;;
+esac
+
+CT_DoGetFileWget() {
+ # Need to return true because it is legitimate not to find the tarball at
+ # some of the provided URLs (think about snapshots, different layouts for
+ # different gcc versions, etc...)
+ # Some (very old!) FTP server might not support the passive mode, thus
+ # retry without
+ # With automated download as we are doing, it can be very dangerous to use
+ # -c to continue the downloads. It's far better to simply overwrite the
+ # destination file
+ wget -nc --progress=dot:binary --tries=3 --passive-ftp "$1" || wget -nc --progress=dot:binary --tries=3 "$1" || true
+}
+
+CT_DoGetFileCurl() {
+ # Note: comments about wget method are also valid here
+ # Plus: no good progreess indicator is available with curl,
+ # so output is consigned to oblivion
+ curl --ftp-pasv -O --retry 3 "$1" >/dev/null || curl -O --retry 3 "$1" >/dev/null || true
+}
+
+# For those wanting bleading edge, or to retrieve old uClibc snapshots
+# Usage: CT_GetFileSVN basename url
+#CT_DoGetFileSVN() {
+# local basename="$1"
+# local url="`echo \"$2\" |cut -d : -f 2-`"
+# local tmp_dir
+#
+# CT_TestOrAbort "You don't have subversion" -n "${_svn}"
+# CT_MktempDir tmp_dir
+# CT_Pushd "${tmp_dir}"
+# svn export --force "${url}" "${basename}"
+# tar cfj "${CT_TARBALLS_DIR}/${basename}.tar.bz2" "${basename}"
+# CT_Popd
+# rm -rf "${tmp_dir}"
+#}
+#
+#CT_DoGetFileCVS() {
+# :
+#}
+
+# Download the file from one of the URLs passed as argument
+# Usage: CT_GetFile <filename> <url> [<url> ...]
+CT_GetFile() {
+ local got_it
+ local ext
+ local url
+ local file="$1"
+ shift
+
+ # Do we already have it?
+ ext=`CT_GetFileExtension "${file}"`
+ if [ -n "${ext}" ]; then
+ if [ "${CT_FORCE_DOWNLOAD}" = "y" ]; then
+ rm -f "${CT_TARBALLS_DIR}/${file}${ext}"
+ else
+ return 0
+ fi
+ fi
+
+ CT_DoLog EXTRA "Retrieving \"${file}\""
+ CT_Pushd "${CT_TARBALLS_DIR}"
+ # File not yet downloaded, try to get it
+ got_it=0
+ if [ "${got_it}" != "y" ]; then
+ # We'd rather have a bzip2'ed tarball, then gzipped, and finally plain tar.
+ for ext in .tar.bz2 .tar.gz .tgz .tar; do
+ # Try all urls in turn
+ for url in "$@"; do
+ case "${url}" in
+# svn://*) CT_DoGetFileSVN "${file}" ${url}";;
+# cvs://*) CT_DoGetFileCVS "${file}" ${url}";;
+ *) CT_DoLog EXTRA "Trying \"${url}/${file}${ext}\""
+ ${CT_DoGetFile} "${url}/${file}${ext}" 2>&1 |CT_DoLog DEBUG
+ ;;
+ esac
+ [ -f "${file}${ext}" ] && got_it=1 && break 2 || true
+ done
+ done
+ fi
+ CT_Popd
+
+ CT_TestAndAbort "Could not download \"${file}\", and not present in \"${CT_TARBALLS_DIR}\"" ${got_it} -eq 0
+}
+
+#-----------------------------------------------------------------------------
+
+# Extract a tarball and patch.
+# Some tarballs need to be extracted in specific places. Eg.: glibc addons
+# must be extracted in the glibc directory; uCLibc locales must be extracted
+# in the extra/locale sub-directory of uClibc.
+CT_ExtractAndPatch() {
+ local file="$1"
+ local base_file=`echo "${file}" |cut -d - -f 1`
+ local ver_file=`echo "${file}" |cut -d - -f 2-`
+ local official_patch_dir
+ local custom_patch_dir
+ local libc_addon
+ local ext=`CT_GetFileExtension "${file}"`
+ CT_TestAndAbort "\"${file}\" not found in \"${CT_TARBALLS_DIR}\"" -z "${ext}"
+ local full_file="${CT_TARBALLS_DIR}/${file}${ext}"
+
+ CT_Pushd "${CT_SRC_DIR}"
+
+ # Add-ons need a little love, really.
+ case "${file}" in
+ glibc-[a-z]*-*)
+ CT_TestAndAbort "Trying to extract the C-library addon/locales \"${file}\" when C-library not yet extracted" ! -d "${CT_LIBC_FILE}"
+ cd "${CT_LIBC_FILE}"
+ libc_addon=y
+ [ -f ".${file}.extracted" ] && return 0
+ touch ".${file}.extracted"
+ ;;
+ uClibc-locale-*)
+ CT_TestAndAbort "Trying to extract the C-library addon/locales \"${file}\" when C-library not yet extracted" ! -d "${CT_LIBC_FILE}"
+ cd "${CT_LIBC_FILE}/extra/locale"
+ libc_addon=y
+ [ -f ".${file}.extracted" ] && return 0
+ touch ".${file}.extracted"
+ ;;
+ esac
+
+ # If the directory exists, then consider extraction and patching done
+ [ -d "${file}" ] && return 0
+
+ CT_DoLog EXTRA "Extracting \"${file}\""
+ case "${ext}" in
+ .tar.bz2) tar xvjf "${full_file}" |CT_DoLog DEBUG;;
+ .tar.gz|.tgz) tar xvzf "${full_file}" |CT_DoLog DEBUG;;
+ .tar) tar xvf "${full_file}" |CT_DoLog DEBUG;;
+ *) CT_Abort "Don't know how to handle \"${file}\": unknown extension" ;;
+ esac
+
+ # Snapshots might not have the version number in the extracted directory
+ # name. This is also the case for some (old) packages, such as libfloat.
+ # Overcome this issue by symlink'ing the directory.
+ if [ ! -d "${file}" -a "${libc_addon}" != "y" ]; then
+ case "${ext}" in
+ .tar.bz2) base=`tar tjf "${full_file}" |head -n 1 |cut -d / -f 1 || true`;;
+ .tar.gz|.tgz) base=`tar tzf "${full_file}" |head -n 1 |cut -d / -f 1 || true`;;
+ .tar) base=`tar tf "${full_file}" |head -n 1 |cut -d / -f 1 || true`;;
+ esac
+ CT_TestOrAbort "There was a problem when extracting \"${file}\"" -d "${base}" -o "${base}" != "${file}"
+ ln -s "${base}" "${file}"
+ fi
+
+ # Kludge: outside this function, we wouldn't know if we had just extracted
+ # a libc addon, or a plain package. Apply patches now.
+ CT_DoLog EXTRA "Patching \"${file}\""
+
+ # If libc addon, we're already in the correct place.
+ [ -z "${libc_addon}" ] && cd "${file}"
+
+ [ "${CUSTOM_PATCH_ONLY}" = "y" ] || official_patch_dir="${CT_TOP_DIR}/patches/${base_file}/${ver_file}"
+ [ "${CT_CUSTOM_PATCH}" = "y" ] && custom_patch_dir="${CT_CUSTOM_PATCH_DIR}/${base_file}/${ver_file}"
+ for patch_dir in "${official_patch_dir}" "${custom_patch_dir}"; do
+ if [ -n "${patch_dir}" -a -d "${patch_dir}" ]; then
+ for p in "${patch_dir}"/*.patch; do
+ if [ -f "${p}" ]; then
+ CT_DoLog DEBUG "Applying patch \"${p}\""
+ patch -g0 -F1 -p1 -f <"${p}" |CT_DoLog DEBUG
+ CT_TestAndAbort "Failed while applying patch file \"${p}\"" ${PIPESTATUS[0]} -ne 0
+ fi
+ done
+ fi
+ done
+
+ CT_Popd
+}
+
+#-----------------------------------------------------------------------------
+
+# Get the file name extension of a component
+# Usage: CT_GetFileExtension <component-version>
+# If found, echoes the extension to stdout
+# If not found, echoes nothing on stdout.
+CT_GetFileExtension() {
+ local ext
+ local file="$1"
+ local got_it=1
+
+ CT_Pushd "${CT_TARBALLS_DIR}"
+ for ext in .tar.gz .tar.bz2 .tgz .tar; do
+ if [ -f "${file}${ext}" ]; then
+ echo "${ext}"
+ got_it=0
+ break
+ fi
+ done
+ CT_Popd
+
+ return 0
+}
+
+#-----------------------------------------------------------------------------
+
+# Create needed directories, remove old ones
+mkdir -p "${CT_TARBALLS_DIR}"
+if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then
+ mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.$$"
+ nohup rm -rf "${CT_SRC_DIR}.$$" >/dev/null 2>&1 &
+fi
+mkdir -p "${CT_SRC_DIR}"
+
+# Make all path absolute, it so much easier!
+# Now we have had the directories created, we even will get rid of embedded .. in paths:
+CT_SRC_DIR="`CT_MakeAbsolutePath \"${CT_SRC_DIR}\"`"
+CT_TARBALLS_DIR="`CT_MakeAbsolutePath \"${CT_TARBALLS_DIR}\"`"
+
+# Prepare the addons list to be parsable:
+addons_list="`echo \"${CT_LIBC_ADDONS_LIST}\" |sed -r -e 's/,/ /g; s/ $//g;'`"
+
+if [ "${CT_NO_DOWNLOAD}" != "y" ]; then
+ CT_DoStep INFO "Retrieving needed toolchain components' tarballs"
+
+ # Kernel: for now, I don't care about cygwin.
+ CT_GetFile "${CT_KERNEL_FILE}" \
+ ftp://ftp.kernel.org/pub/linux/kernel/v2.6 \
+ ftp://ftp.kernel.org/pub/linux/kernel/v2.4 \
+ ftp://ftp.kernel.org/pub/linux/kernel/v2.2 \
+ ftp://ftp.kernel.org/pub/linux/kernel/v2.6/testing \
+ http://ep09.pld-linux.org/~mmazur/linux-libc-headers
+
+ # binutils
+ CT_GetFile "${CT_BINUTILS_FILE}" \
+ ftp://ftp.gnu.org/gnu/binutils \
+ ftp://ftp.kernel.org/pub/linux/devel/binutils
+
+ # Core and final gcc
+ # Ah! gcc folks are kind of 'different': they store the tarballs in
+ # subdirectories of the same name! That's because gcc is such /crap/ that
+ # it is such /big/ that it needs being splitted for distribution! Sad. :-(
+ # Arrgghh! Some of those versions does not follow this convention:
+ # gcc-3.3.3 lives in releases/gcc-3.3.3, while gcc-2.95.* isn't in a
+ # subdirectory! You bastard!
+ CT_GetFile "${CT_CC_CORE_FILE}" \
+ ftp://ftp.gnu.org/gnu/gcc/${CT_CC_CORE_FILE} \
+ ftp://ftp.gnu.org/gnu/gcc/releases/${CT_CC_CORE_FILE} \
+ ftp://ftp.gnu.org/gnu/gcc
+ CT_GetFile "${CT_CC_FILE}" \
+ ftp://ftp.gnu.org/gnu/gcc/${CT_CC_FILE} \
+ ftp://ftp.gnu.org/gnu/gcc/releases/${CT_CC_FILE} \
+ ftp://ftp.gnu.org/gnu/gcc
+
+ # C library
+ case "${CT_LIBC}" in
+ glibc)
+ # Ah! Not all GNU folks seem stupid. All glibc releases are in the same
+ # directory. Good. Alas, there is no snapshot there. I'll deal with them
+ # later on... :-/
+ libc_src="ftp://ftp.gnu.org/gnu/glibc"
+ ;;
+ uClibc)
+ # For uClibc, we have almost every thing: releases, and snapshots
+ # for the last month or so. We'll have to deal with svn revisions
+ # later...
+ libc_src="http://www.uclibc.org/downloads
+ http://www.uclibc.org/downloads/snapshots
+ http://www.uclibc.org/downloads/old-releases"
+ ;;
+ esac
+ CT_GetFile "${CT_LIBC_FILE}" ${libc_src}
+
+ # C library addons
+ addons_list=`echo "${CT_LIBC_ADDONS}" |sed -r -e 's/,/ /g; s/ $//g;'`
+ for addon in ${addons_list}; do
+ CT_GetFile "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}" \
+ ftp://ftp.gnu.org/gnu/glibc
+ done
+ if [ "${CT_LIBC_UCLIBC_LOCALES}" = "y" ]; then
+ CT_GetFile "uClibc-locale-030818" \
+ http://www.uclibc.org/downloads \
+ http://www.uclibc.org/downloads/snapshots \
+ http://www.uclibc.org/downloads/old-releases
+ fi
+
+ # libfloat if asked for
+ if [ "${CT_ARCH_FLOAT_SW_LIBFLOAT}" = "y" ]; then
+ lib_float_url="ftp://ftp.de.debian.org/debian/pool/main/libf/libfloat/"
+
+ # Please note: because the file we download, and the file we store on the
+ # file system don't have the same name, CT_GetFile will always try to
+ # download the file over and over.
+ # To avoid this, we check that the file we want already exists in the
+ # tarball directory first. This is an ugly hack that overrides the standard
+ # CT_GetFile behavior... Sight...
+ ext=`CT_GetFileExtension "${CT_LIBFLOAT_FILE}"`
+ if [ -z "${ext}" ]; then
+ CT_GetFile libfloat_990616.orig "${lib_float_url}"
+ ext=`CT_GetFileExtension "libfloat_990616.orig"`
+ # Hack: remove the .orig extension, and change _ to -
+ mv -v "${CT_TARBALLS_DIR}/libfloat_990616.orig${ext}" \
+ "${CT_TARBALLS_DIR}/libfloat-990616${ext}" 2>&1 |CT_DoLog DEBUG
+ fi
+ fi
+
+ CT_EndStep
+fi # CT_NO_DOWNLOAD
+
+if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
+ CT_DoStep INFO "Extracting and patching toolchain components"
+
+ CT_ExtractAndPatch "${CT_KERNEL_FILE}"
+ CT_ExtractAndPatch "${CT_BINUTILS_FILE}"
+ CT_ExtractAndPatch "${CT_CC_CORE_FILE}"
+ CT_ExtractAndPatch "${CT_CC_FILE}"
+ CT_ExtractAndPatch "${CT_LIBC_FILE}"
+ for addon in ${addons_list}; do
+ CT_ExtractAndPatch "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}"
+ done
+ if [ "${CT_LIBC_UCLIBC_LOCALES}" = "y" ]; then
+ CT_ExtractAndPatch "uclibc-locale-030818"
+ fi
+
+ [ "${CT_ARCH_FLOAT_SW_LIBFLOAT}" = "y" ] && CT_ExtractAndPatch "${CT_LIBFLOAT_FILE}"
+
+ CT_EndStep
+fi