scripts/build/libc/uClibc.sh
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Fri Jan 03 17:10:09 2014 +0100 (2014-01-03)
changeset 3270 dff359adf15c
parent 3100 bd4af15b7c75
child 3272 16028ca35721
permissions -rw-r--r--
libc/eglibc: fix downloading of localedef addon

For the versions of eglibc where the ports addon is not external (ie,
all versions after, and including 2.17), we would fail to download the
localedef addon, since the test did not care about the addon we were
about to download, only whether the ports addon was external or not.

Fix that by skipping the ports addon only if that's the addon we're
trying to download.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
     1 # This file declares functions to install the uClibc C library
     2 # Copyright 2007 Yann E. MORIN
     3 # Licensed under the GPL v2. See COPYING in the root of this package
     4 
     5 # This is a constant because it does not change very often.
     6 # We're in 2010, and are still using data from 7 years ago.
     7 uclibc_locales_version=030818
     8 uclibc_local_tarball="uClibc-locale-${uclibc_locales_version}"
     9 
    10 # Download uClibc
    11 do_libc_get() {
    12     libc_src="http://www.uclibc.org/downloads
    13               http://www.uclibc.org/downloads/old-releases"
    14     if [ "${CT_LIBC_UCLIBC_CUSTOM}" = "y" ]; then
    15         CT_GetCustom "uClibc" "${CT_LIBC_VERSION}" \
    16                      "${CT_LIBC_UCLIBC_CUSTOM_LOCATION}"
    17     else
    18         CT_GetFile "uClibc-${CT_LIBC_VERSION}" ${libc_src}
    19     fi
    20     # uClibc locales
    21     if [ "${CT_LIBC_UCLIBC_LOCALES_PREGEN_DATA}" = "y" ]; then
    22         CT_GetFile "${uclibc_local_tarball}" ${libc_src}
    23     fi
    24 
    25     return 0
    26 }
    27 
    28 # Extract uClibc
    29 do_libc_extract() {
    30     # If not using custom directory location, extract and patch
    31     # Note: we do the inverse test we do in other components,
    32     # because here we still need to extract the locales, even for
    33     # custom location directory. Just use negate the whole test,
    34     # to keep it the same as for other components.
    35     if ! [ "${CT_LIBC_UCLIBC_CUSTOM}" = "y" \
    36          -a -d "${CT_SRC_DIR}/uClibc-${CT_LIBC_VERSION}" ]; then
    37         CT_Extract "uClibc-${CT_LIBC_VERSION}"
    38         CT_Patch "uClibc" "${CT_LIBC_VERSION}"
    39     fi
    40 
    41     # uClibc locales
    42     # Extracting pregen locales ourselves is kinda
    43     # broken, so just link it in place...
    44     if [    "${CT_LIBC_UCLIBC_LOCALES_PREGEN_DATA}" = "y"           \
    45          -a ! -f "${CT_SRC_DIR}/.${uclibc_local_tarball}.extracted" ]; then
    46         CT_Pushd "${CT_SRC_DIR}/uClibc-${CT_LIBC_VERSION}/extra/locale"
    47         CT_DoExecLog ALL ln -s "${CT_TARBALLS_DIR}/${uclibc_local_tarball}.tgz" .
    48         CT_Popd
    49         touch "${CT_SRC_DIR}/.${uclibc_local_tarball}.extracted"
    50     fi
    51 
    52     return 0
    53 }
    54 
    55 # Check that uClibc has been previously configured
    56 do_libc_check_config() {
    57     CT_DoStep INFO "Checking C library configuration"
    58 
    59     CT_TestOrAbort "You did not provide a uClibc config file!" -n "${CT_LIBC_UCLIBC_CONFIG_FILE}" -a -f "${CT_LIBC_UCLIBC_CONFIG_FILE}"
    60 
    61     if grep -E '^KERNEL_SOURCE=' "${CT_LIBC_UCLIBC_CONFIG_FILE}" >/dev/null 2>&1; then
    62         CT_DoLog WARN "Your uClibc version refers to the kernel _sources_, which is bad."
    63         CT_DoLog WARN "I can't guarantee that our little hack will work. Please try to upgrade."
    64     fi
    65 
    66     CT_DoLog EXTRA "Munging uClibc configuration"
    67     mungeuClibcConfig "${CT_LIBC_UCLIBC_CONFIG_FILE}" "${CT_CONFIG_DIR}/uClibc.config"
    68 
    69     CT_EndStep
    70 }
    71 
    72 # Build and install headers and start files
    73 do_libc_start_files() {
    74     local install_rule
    75     local cross
    76 
    77     CT_DoStep INFO "Installing C library headers"
    78 
    79     # Simply copy files until uClibc has the ability to build out-of-tree
    80     CT_DoLog EXTRA "Copying sources to build dir"
    81     CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/uClibc-${CT_LIBC_VERSION}"   \
    82                             "${CT_BUILD_DIR}/build-libc-headers"
    83     cd "${CT_BUILD_DIR}/build-libc-headers"
    84 
    85     # Retrieve the config file
    86     CT_DoExecLog ALL cp "${CT_CONFIG_DIR}/uClibc.config" .config
    87 
    88     # uClibc uses the CROSS environment variable as a prefix to the
    89     # compiler tools to use.  Setting it to the empty string forces
    90     # use of the native build host tools, which we need at this
    91     # stage, as we don't have target tools yet.
    92     # BUT! With NPTL, we need a cross-compiler (and we have it)
    93     if [ "${CT_THREADS}" = "nptl" ]; then
    94         cross="${CT_TARGET}-"
    95     fi
    96 
    97     # Force the date of the pregen locale data, as the
    98     # newer ones that are referenced are not available
    99     CT_DoLog EXTRA "Applying configuration"
   100     CT_DoYes "" |CT_DoExecLog ALL                                   \
   101                  make CROSS="${cross}"                              \
   102                  PREFIX="${CT_SYSROOT_DIR}/"                        \
   103                  LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \
   104                  oldconfig
   105 
   106     CT_DoLog EXTRA "Building headers"
   107     CT_DoExecLog ALL                                        \
   108     make ${CT_LIBC_UCLIBC_VERBOSITY}                        \
   109          CROSS="${cross}"                                   \
   110          PREFIX="${CT_SYSROOT_DIR}/"                        \
   111          LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \
   112          headers
   113 
   114     if [ "${CT_LIBC_UCLIBC_0_9_30_or_later}" = "y" ]; then
   115         install_rule=install_headers
   116     else
   117         install_rule=install_dev
   118     fi
   119 
   120     CT_DoLog EXTRA "Installing headers"
   121     CT_DoExecLog ALL                                        \
   122     make ${CT_LIBC_UCLIBC_VERBOSITY}                        \
   123          CROSS="${cross}"                                   \
   124          PREFIX="${CT_SYSROOT_DIR}/"                        \
   125          LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \
   126          ${install_rule}
   127 
   128     if [ "${CT_THREADS}" = "nptl" ]; then
   129         CT_DoLog EXTRA "Building start files"
   130         CT_DoExecLog ALL                                        \
   131         make ${CT_LIBC_UCLIBC_PARALLEL:+${JOBSFLAGS}}           \
   132              CROSS="${cross}"                                   \
   133              PREFIX="${CT_SYSROOT_DIR}/"                        \
   134              STRIPTOOL=true                                     \
   135              ${CT_LIBC_UCLIBC_VERBOSITY}                        \
   136              LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \
   137              lib/crt1.o lib/crti.o lib/crtn.o
   138 
   139         # From:  http://git.openembedded.org/cgit.cgi/openembedded/commit/?id=ad5668a7ac7e0436db92e55caaf3fdf782b6ba3b
   140         # libm.so is needed for ppc, as libgcc is linked against libm.so
   141         # No problem to create it for other archs.
   142         CT_DoLog EXTRA "Building dummy shared libs"
   143         CT_DoExecLog ALL "${cross}gcc" -nostdlib        \
   144                                        -nostartfiles    \
   145                                        -shared          \
   146                                        -x c /dev/null   \
   147                                        -o libdummy.so
   148 
   149         CT_DoLog EXTRA "Installing start files"
   150         CT_DoExecLog ALL install -m 0644 lib/crt1.o lib/crti.o lib/crtn.o   \
   151                                          "${CT_SYSROOT_DIR}/usr/lib"
   152 
   153         CT_DoLog EXTRA "Installing dummy shared libs"
   154         CT_DoExecLog ALL install -m 0755 libdummy.so "${CT_SYSROOT_DIR}/usr/lib/libc.so"
   155         CT_DoExecLog ALL install -m 0755 libdummy.so "${CT_SYSROOT_DIR}/usr/lib/libm.so"
   156     fi # CT_THREADS == nptl
   157 
   158     CT_EndStep
   159 }
   160 
   161 # This function build and install the full uClibc
   162 do_libc() {
   163     CT_DoStep INFO "Installing C library"
   164 
   165     # Simply copy files until uClibc has the ability to build out-of-tree
   166     CT_DoLog EXTRA "Copying sources to build dir"
   167     CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/uClibc-${CT_LIBC_VERSION}"   \
   168                             "${CT_BUILD_DIR}/build-libc"
   169     cd "${CT_BUILD_DIR}/build-libc"
   170 
   171     # Retrieve the config file
   172     CT_DoExecLog ALL cp "${CT_CONFIG_DIR}/uClibc.config" .config
   173 
   174     # uClibc uses the CROSS environment variable as a prefix to the compiler
   175     # tools to use.  The newly built tools should be in our path, so we need
   176     # only give the correct name for them.
   177     # Note about CFLAGS: In uClibc, CFLAGS are generated by Rules.mak,
   178     # depending  on the configuration of the library. That is, they are tailored
   179     # to best fit the target. So it is useless and seems to be a bad thing to
   180     # use LIBC_EXTRA_CFLAGS here.
   181     CT_DoLog EXTRA "Applying configuration"
   182     CT_DoYes "" |CT_DoExecLog CFG                                   \
   183                  make CROSS=${CT_TARGET}-                           \
   184                  PREFIX="${CT_SYSROOT_DIR}/"                        \
   185                  LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \
   186                  oldconfig
   187 
   188     # We do _not_ want to strip anything for now, in case we specifically
   189     # asked for a debug toolchain, thus the STRIPTOOL= assignment
   190     # /Old/ versions can not build in //
   191     CT_DoLog EXTRA "Building C library"
   192     CT_DoExecLog ALL                                        \
   193     make -j1                                                \
   194          CROSS=${CT_TARGET}-                                \
   195          PREFIX="${CT_SYSROOT_DIR}/"                        \
   196          STRIPTOOL=true                                     \
   197          ${CT_LIBC_UCLIBC_VERBOSITY}                        \
   198          LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \
   199          pregen
   200     CT_DoExecLog ALL                                        \
   201     make ${CT_LIBC_UCLIBC_PARALLEL:+${JOBSFLAGS}}           \
   202          CROSS=${CT_TARGET}-                                \
   203          PREFIX="${CT_SYSROOT_DIR}/"                        \
   204          STRIPTOOL=true                                     \
   205          ${CT_LIBC_UCLIBC_VERBOSITY}                        \
   206          LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \
   207          all
   208 
   209     # YEM-FIXME:
   210     # - we want to install 'runtime' files, eg. lib*.{a,so*}, crti.o and
   211     #   such files, except the headers as they already are installed
   212     # - "make install_dev" installs the headers, the crti.o... and the
   213     #   static libs, but not the dynamic libs
   214     # - "make install_runtime" installs the dynamic libs only
   215     # - "make install" calls install_runtime and install_dev
   216     # - so we're left with re-installing the headers... Sigh...
   217     #
   218     # We do _not_ want to strip anything for now, in case we specifically
   219     # asked for a debug toolchain, hence the STRIPTOOL= assignment
   220     #
   221     # Note: JOBSFLAGS is not usefull for installation.
   222     #
   223     CT_DoLog EXTRA "Installing C library"
   224     CT_DoExecLog ALL                                        \
   225     make CROSS=${CT_TARGET}-                                \
   226          PREFIX="${CT_SYSROOT_DIR}/"                        \
   227          STRIPTOOL=true                                     \
   228          ${CT_LIBC_UCLIBC_VERBOSITY}                        \
   229          LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \
   230          install
   231 
   232     CT_EndStep
   233 }
   234 
   235 # Initialises the .config file to sensible values
   236 # $1: original file
   237 # $2: munged file
   238 mungeuClibcConfig() {
   239     src_config_file="$1"
   240     dst_config_file="$2"
   241     munge_file="${CT_BUILD_DIR}/munge-uClibc-config.sed"
   242 
   243     # Start with a fresh file
   244     rm -f "${munge_file}"
   245     touch "${munge_file}"
   246 
   247     # Do it all in a sub-shell, it's easier to redirect output
   248     (
   249 
   250     # Hack our target in the config file.
   251     case "${CT_ARCH}:${CT_ARCH_BITNESS}" in
   252         x86:32)      arch=i386;;
   253         x86:64)      arch=x86_64;;
   254         sh:32)       arch="sh";;
   255         sh:64)       arch="sh64";;
   256         blackfin:32) arch="bfin";;
   257         *)           arch="${CT_ARCH}";;
   258     esac
   259     # Also remove stripping: its the responsibility of the
   260     # firmware builder to strip or not.
   261     cat <<-ENDSED
   262 		s/^(TARGET_.*)=y$/# \\1 is not set/
   263 		s/^# TARGET_${arch} is not set/TARGET_${arch}=y/
   264 		s/^TARGET_ARCH=".*"/TARGET_ARCH="${arch}"/
   265 		s/.*(DOSTRIP).*/# \\1 is not set/
   266 		ENDSED
   267 
   268     # Ah. We may one day need architecture-specific handler here...
   269     case "${CT_ARCH}" in
   270         arm)
   271             # Hack the ARM {E,O}ABI into the config file
   272             if [ "${CT_ARCH_ARM_EABI}" = "y" ]; then
   273                 cat <<-ENDSED
   274 					s/.*(CONFIG_ARM_OABI).*/# \\1 is not set/
   275 					s/.*(CONFIG_ARM_EABI).*/\\1=y/
   276 					ENDSED
   277             else
   278                 cat <<-ENDSED
   279 					s/.*(CONFIG_ARM_OABI).*/\\1=y/
   280 					s/.*(CONFIG_ARM_EABI).*/# \\1 is not set/
   281 					ENDSED
   282             fi
   283             ;;
   284         mips)
   285             case "${CT_ARCH_mips_ABI}" in
   286                 32)
   287                     cat <<-ENDSED
   288 						s/.*(CONFIG_MIPS_O32_ABI).*/\\1=y/
   289 						s/.*(CONFIG_MIPS_N32_ABI).*/# \\1 is not set/
   290 						s/.*(CONFIG_MIPS_N64_ABI).*/# \\1 is not set/
   291 						ENDSED
   292                     ;;
   293                 # For n32 and n64, also force the ISA
   294                 # Not so sure this is pertinent, so it's
   295                 # commented out for now. It would take a
   296                 # (MIPS+uClibc) expert to either remove
   297                 # or re-enable the overrides.
   298                 n32)
   299                     cat <<-ENDSED
   300 						s/.*(CONFIG_MIPS_O32_ABI).*/# \\1 is not set/
   301 						s/.*(CONFIG_MIPS_N32_ABI).*/\\1=y/
   302 						s/.*(CONFIG_MIPS_N64_ABI).*/# \\1 is not set/
   303 						s/.*(CONFIG_MIPS_ISA_.*).*/# \\1 is not set/
   304 						s/.*(CONFIG_MIPS_ISA_3).*/\\1=y/
   305 						ENDSED
   306                     ;;
   307                 64)
   308                     cat <<-ENDSED
   309 						s/.*(CONFIG_MIPS_O32_ABI).*/# \\1 is not set/
   310 						s/.*(CONFIG_MIPS_N32_ABI).*/# \\1 is not set/
   311 						s/.*(CONFIG_MIPS_N64_ABI).*/\\1=y/
   312 						s/.*(CONFIG_MIPS_ISA_.*).*/# \\1 is not set/
   313 						s/.*(CONFIG_MIPS_ISA_MIPS64).*/\\1=y/
   314 						ENDSED
   315                     ;;
   316             esac
   317             ;;
   318     esac
   319 
   320     # Accomodate for old and new uClibc versions, where the
   321     # way to select between big/little endian has changed
   322     case "${CT_ARCH_ENDIAN}" in
   323         big)
   324             cat <<-ENDSED
   325 				s/.*(ARCH_LITTLE_ENDIAN).*/# \\1 is not set/
   326 				s/.*(ARCH_BIG_ENDIAN).*/\\1=y/
   327 				s/.*(ARCH_WANTS_LITTLE_ENDIAN).*/# \\1 is not set/
   328 				s/.*(ARCH_WANTS_BIG_ENDIAN).*/\\1=y/
   329 				ENDSED
   330         ;;
   331         little)
   332             cat <<-ENDSED
   333 				s/.*(ARCH_LITTLE_ENDIAN).*/\\1=y/
   334 				s/.*(ARCH_BIG_ENDIAN).*/# \\1 is not set/
   335 				s/.*(ARCH_WANTS_LITTLE_ENDIAN).*/\\1=y/
   336 				s/.*(ARCH_WANTS_BIG_ENDIAN).*/# \\1 is not set/
   337 				ENDSED
   338         ;;
   339     esac
   340 
   341     # Accomodate for old and new uClibc versions, where the
   342     # MMU settings has different config knobs
   343     if [ "${CT_ARCH_USE_MMU}" = "y" ]; then
   344         cat <<-ENDSED
   345 			s/.*(ARCH_HAS_MMU).*/\\1=y\nARCH_USE_MMU=y/
   346 			ENDSED
   347     else
   348         cat <<-ENDSED
   349 			s/.*(ARCH_HAS_MMU).*/# \\1 is not set/
   350 			/.*(ARCH_USE_MMU).*/d
   351 			ENDSED
   352     fi
   353 
   354     # Accomodate for old and new uClibc version, where the
   355     # way to select between hard/soft float has changed
   356     case "${CT_ARCH_FLOAT}" in
   357         hard|softfp)
   358             cat <<-ENDSED
   359 				s/^[^_]*(HAS_FPU).*/\\1=y/
   360 				s/.*(UCLIBC_HAS_FPU).*/\\1=y/
   361 				ENDSED
   362             ;;
   363         soft)
   364             cat <<-ENDSED
   365 				s/^[^_]*(HAS_FPU).*/\\# \\1 is not set/
   366 				s/.*(UCLIBC_HAS_FPU).*/# \\1 is not set/
   367 				ENDSED
   368             ;;
   369     esac
   370 
   371     # We always want ctor/dtor
   372     cat <<-ENDSED
   373 		s/^# (UCLIBC_CTOR_DTOR) is not set/\\1=y/
   374 		ENDSED
   375 
   376     # Change paths to work with crosstool-NG
   377     # From http://www.uclibc.org/cgi-bin/viewcvs.cgi?rev=16846&view=rev
   378     #  " we just want the kernel headers, not the whole kernel source ...
   379     #  " so people may need to update their paths slightly
   380     quoted_kernel_source=$(echo "${CT_HEADERS_DIR}" | sed -r -e 's,/include/?$,,; s,/,\\/,g;')
   381     quoted_headers_dir=$(echo "${CT_HEADERS_DIR}" | sed -r -e 's,/,\\/,g;')
   382     # CROSS_COMPILER_PREFIX is left as is, as the CROSS parameter is forced on the command line
   383     # DEVEL_PREFIX is left as '/usr/' because it is post-pended to $PREFIX, wich is the correct value of ${PREFIX}/${TARGET}
   384     # Some (old) versions of uClibc use KERNEL_SOURCE (which is _wrong_), and
   385     # newer versions use KERNEL_HEADERS (which is right).
   386     cat <<-ENDSED
   387 		s/^DEVEL_PREFIX=".*"/DEVEL_PREFIX="\\/usr\\/"/
   388 		s/^RUNTIME_PREFIX=".*"/RUNTIME_PREFIX="\\/"/
   389 		s/^SHARED_LIB_LOADER_PREFIX=.*/SHARED_LIB_LOADER_PREFIX="\\/lib\\/"/
   390 		s/^KERNEL_SOURCE=".*"/KERNEL_SOURCE="${quoted_kernel_source}"/
   391 		s/^KERNEL_HEADERS=".*"/KERNEL_HEADERS="${quoted_headers_dir}"/
   392 		s/^UCLIBC_DOWNLOAD_PREGENERATED_LOCALE=y/\\# UCLIBC_DOWNLOAD_PREGENERATED_LOCALE is not set/
   393 		ENDSED
   394 
   395     if [ "${CT_USE_PIPES}" = "y" ]; then
   396         if grep UCLIBC_EXTRA_CFLAGS extra/Configs/Config.in >/dev/null 2>&1; then
   397             # Good, there is special provision for such things as -pipe!
   398             cat <<-ENDSED
   399 				s/^(UCLIBC_EXTRA_CFLAGS=".*)"$/\\1 -pipe"/
   400 				ENDSED
   401         else
   402             # Hack our -pipe into WARNINGS, which will be internally incorporated to
   403             # CFLAGS. This a dirty hack, but yet needed
   404             cat <<-ENDSED
   405 				s/^(WARNINGS=".*)"$/\\1 -pipe"/
   406 				ENDSED
   407         fi
   408     fi
   409 
   410     # Locales support
   411     # Note that the two PREGEN_LOCALE and the XLOCALE lines may be missing
   412     # entirely if LOCALE is not set.  If LOCALE was already set, we'll
   413     # assume the user has already made all the appropriate generation
   414     # arrangements.  Note that having the uClibc Makefile download the
   415     # pregenerated locales is not compatible with crosstool; besides,
   416     # crosstool downloads them as part of getandpatch.sh.
   417     case "${CT_LIBC_UCLIBC_LOCALES}:${CT_LIBC_UCLIBC_LOCALES_PREGEN_DATA}" in
   418         :*)
   419             ;;
   420         y:)
   421             cat <<-ENDSED
   422 				s/^# UCLIBC_HAS_LOCALE is not set/UCLIBC_HAS_LOCALE=y\\
   423 				# UCLIBC_PREGENERATED_LOCALE_DATA is not set\\
   424 				# UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA is not set\\
   425 				# UCLIBC_HAS_XLOCALE is not set/
   426 				ENDSED
   427             ;;
   428         y:y)
   429             cat <<-ENDSED
   430 				s/^# UCLIBC_HAS_LOCALE is not set/UCLIBC_HAS_LOCALE=y\\
   431 				UCLIBC_PREGENERATED_LOCALE_DATA=y\\
   432 				# UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA is not set\\
   433 				# UCLIBC_HAS_XLOCALE is not set/
   434 				ENDSED
   435             ;;
   436     esac
   437 
   438     # WCHAR support
   439     if [ "${CT_LIBC_UCLIBC_WCHAR}" = "y" ] ; then
   440         cat <<-ENDSED
   441 			s/^.*UCLIBC_HAS_WCHAR.*/UCLIBC_HAS_WCHAR=y/
   442 			ENDSED
   443     else
   444         cat <<-ENDSED
   445 			s/^.*UCLIBC_HAS_WCHAR.*/UCLIBC_HAS_WCHAR=n/
   446 			ENDSED
   447     fi
   448 
   449     # Force on options needed for C++ if we'll be making a C++ compiler.
   450     # I'm not sure locales are a requirement for doing C++... Are they?
   451     if [ "${CT_CC_LANG_CXX}" = "y" ]; then
   452         cat <<-ENDSED
   453 			s/^# DO_C99_MATH is not set/DO_C99_MATH=y/
   454 			s/^# UCLIBC_HAS_GNU_GETOPT is not set/UCLIBC_HAS_GNU_GETOPT=y/
   455 			ENDSED
   456     fi
   457 
   458     # Push the threading model
   459     case "${CT_THREADS}:${CT_LIBC_UCLIBC_LNXTHRD}" in
   460         none:)
   461             cat <<-ENDSED
   462 				s/^UCLIBC_HAS_THREADS=y/# UCLIBC_HAS_THREADS is not set/
   463 				s/^LINUXTHREADS_OLD=y/# LINUXTHREADS_OLD is not set/
   464 				s/^LINUXTHREADS_NEW=y/# LINUXTHREADS_NEW is not set/
   465 				s/^UCLIBC_HAS_THREADS_NATIVE=y/# UCLIBC_HAS_THREADS_NATIVE is not set/
   466 				ENDSED
   467             ;;
   468         linuxthreads:old)
   469             cat <<-ENDSED
   470 				s/^# UCLIBC_HAS_THREADS is not set/UCLIBC_HAS_THREADS=y/
   471 				s/^# LINUXTHREADS_OLD is not set/LINUXTHREADS_OLD=y/
   472 				s/^LINUXTHREADS_NEW=y/# LINUXTHREADS_NEW is not set/
   473 				s/^UCLIBC_HAS_THREADS_NATIVE=y/# UCLIBC_HAS_THREADS_NATIVE is not set/
   474 				ENDSED
   475             ;;
   476         linuxthreads:new)
   477             cat <<-ENDSED
   478 				s/^# UCLIBC_HAS_THREADS is not set/UCLIBC_HAS_THREADS=y/
   479 				s/^LINUXTHREADS_OLD=y/# LINUXTHREADS_OLD is not set/
   480 				s/^# LINUXTHREADS_NEW is not set/LINUXTHREADS_NEW=y/
   481 				s/^UCLIBC_HAS_THREADS_NATIVE=y/# UCLIBC_HAS_THREADS_NATIVE is not set/
   482 				ENDSED
   483             ;;
   484         nptl:)
   485             cat <<-ENDSED
   486 				s/^HAS_NO_THREADS=y/# HAS_NO_THREADS is not set/
   487 				s/^UCLIBC_HAS_THREADS=y/# UCLIBC_HAS_THREADS is not set/
   488 				s/^LINUXTHREADS_OLD=y/# LINUXTHREADS_OLD is not set/
   489 				s/^LINUXTHREADS_NEW=y/# LINUXTHREADS_NEW is not set/
   490 				s/^# UCLIBC_HAS_THREADS_NATIVE is not set/UCLIBC_HAS_THREADS_NATIVE=y/
   491 				ENDSED
   492             ;;
   493         *)
   494             CT_Abort "Incorrect thread settings: CT_THREADS='${CT_THREAD}' CT_LIBC_UCLIBC_LNXTHRD='${CT_LIBC_UCLIBC_LNXTHRD}'"
   495             ;;
   496     esac
   497 
   498     # Always build the libpthread_db
   499     cat <<-ENDSED
   500 		s/^# PTHREADS_DEBUG_SUPPORT is not set.*/PTHREADS_DEBUG_SUPPORT=y/
   501 		ENDSED
   502 
   503     # Force on debug options if asked for
   504     case "${CT_LIBC_UCLIBC_DEBUG_LEVEL}" in
   505       0)
   506         cat <<-ENDSED
   507 			s/^DODEBUG=y/# DODEBUG is not set/
   508 			s/^DODEBUG_PT=y/# DODEBUG_PT is not set/
   509 			s/^DOASSERTS=y/# DOASSERTS is not set/
   510 			s/^SUPPORT_LD_DEBUG=y/# SUPPORT_LD_DEBUG is not set/
   511 			s/^SUPPORT_LD_DEBUG_EARLY=y/# SUPPORT_LD_DEBUG_EARLY is not set/
   512 			s/^UCLIBC_MALLOC_DEBUGGING=y/# UCLIBC_MALLOC_DEBUGGING is not set/
   513 			ENDSED
   514         ;;
   515       1)
   516         cat <<-ENDSED
   517 			s/^# DODEBUG is not set.*/DODEBUG=y/
   518 			s/^DODEBUG_PT=y/# DODEBUG_PT is not set/
   519 			s/^DOASSERTS=y/# DOASSERTS is not set/
   520 			s/^SUPPORT_LD_DEBUG=y/# SUPPORT_LD_DEBUG is not set/
   521 			s/^SUPPORT_LD_DEBUG_EARLY=y/# SUPPORT_LD_DEBUG_EARLY is not set/
   522 			s/^UCLIBC_MALLOC_DEBUGGING=y/# UCLIBC_MALLOC_DEBUGGING is not set/
   523 			ENDSED
   524         ;;
   525       2)
   526         cat <<-ENDSED
   527 			s/^# DODEBUG is not set.*/DODEBUG=y/
   528 			s/^DODEBUG_PT=y/# DODEBUG_PT is not set/
   529 			s/^# DOASSERTS is not set.*/DOASSERTS=y/
   530 			s/^# SUPPORT_LD_DEBUG is not set.*/SUPPORT_LD_DEBUG=y/
   531 			s/^SUPPORT_LD_DEBUG_EARLY=y/# SUPPORT_LD_DEBUG_EARLY is not set/
   532 			s/^# UCLIBC_MALLOC_DEBUGGING is not set/UCLIBC_MALLOC_DEBUGGING=y/
   533 			ENDSED
   534         ;;
   535       3)
   536         cat <<-ENDSED
   537 			s/^# DODEBUG is not set.*/DODEBUG=y/
   538 			s/^# DODEBUG_PT is not set.*/DODEBUG_PT=y/
   539 			s/^# DOASSERTS is not set.*/DOASSERTS=y/
   540 			s/^# SUPPORT_LD_DEBUG is not set.*/SUPPORT_LD_DEBUG=y/
   541 			s/^# SUPPORT_LD_DEBUG_EARLY is not set.*/SUPPORT_LD_DEBUG_EARLY=y/
   542 			s/^# UCLIBC_MALLOC_DEBUGGING is not set/UCLIBC_MALLOC_DEBUGGING=y/
   543 			ENDSED
   544         ;;
   545     esac
   546 
   547     # And now, this is the end
   548     ) >>"${munge_file}"
   549 
   550     sed -r -f "${munge_file}" "${src_config_file}" >"${dst_config_file}"
   551 }