scripts/build/libc/uClibc.sh
author "Benoît THÉBAUDEAU" <benoit.thebaudeau@advansee.com>
Fri Jul 29 15:30:53 2011 +0200 (2011-07-29)
changeset 2587 7727970d04e9
parent 2410 3954053fb678
child 2600 fac4018427d2
permissions -rw-r--r--
libc/glibc: add partial support for locales

This patch adds partial support for glibc locales.

For now, it only generates the appropriate locales when the host and the target
have the same endianness and uint32_t alignment.

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