summaryrefslogtreecommitdiff
path: root/scripts/build
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/build')
-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
11 files changed, 912 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}"
+}