scripts/build/libc/uClibc.sh
author Johannes Stezenbach <js@sig21.net>
Fri Feb 24 16:08:32 2012 +0100 (2012-02-24)
changeset 2951 e9a326ae9369
parent 2777 a6c68712024f
child 3099 79169596cfc9
permissions -rw-r--r--
libc/uClibc: add additional debug level between "minimal" and "all"

During application development it is desirable to enable malloc
debugging and LD_DEBUG support, but the extensive debug spew from
SUPPORT_LD_DEBUG_EARLY is only useful when working on
uClibc's ld.so.

Signed-off-by: Johannes Stezenbach <js@sig21.net>
     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_ENDIAN}" in
   324         big)
   325             cat <<-ENDSED
   326 				s/.*(ARCH_LITTLE_ENDIAN).*/# \\1 is not set/
   327 				s/.*(ARCH_BIG_ENDIAN).*/\\1=y/
   328 				s/.*(ARCH_WANTS_LITTLE_ENDIAN).*/# \\1 is not set/
   329 				s/.*(ARCH_WANTS_BIG_ENDIAN).*/\\1=y/
   330 				ENDSED
   331         ;;
   332         little)
   333             cat <<-ENDSED
   334 				s/.*(ARCH_LITTLE_ENDIAN).*/\\1=y/
   335 				s/.*(ARCH_BIG_ENDIAN).*/# \\1 is not set/
   336 				s/.*(ARCH_WANTS_LITTLE_ENDIAN).*/\\1=y/
   337 				s/.*(ARCH_WANTS_BIG_ENDIAN).*/# \\1 is not set/
   338 				ENDSED
   339         ;;
   340     esac
   341 
   342     # Accomodate for old and new uClibc versions, where the
   343     # MMU settings has different config knobs
   344     if [ "${CT_ARCH_USE_MMU}" = "y" ]; then
   345         cat <<-ENDSED
   346 			s/.*(ARCH_HAS_MMU).*/\\1=y\nARCH_USE_MMU=y/
   347 			ENDSED
   348     else
   349         cat <<-ENDSED
   350 			s/.*(ARCH_HAS_MMU).*/# \\1 is not set/
   351 			/.*(ARCH_USE_MMU).*/d
   352 			ENDSED
   353     fi
   354 
   355     # Accomodate for old and new uClibc version, where the
   356     # way to select between hard/soft float has changed
   357     case "${CT_ARCH_FLOAT}" in
   358         hard|softfp)
   359             cat <<-ENDSED
   360 				s/^[^_]*(HAS_FPU).*/\\1=y/
   361 				s/.*(UCLIBC_HAS_FPU).*/\\1=y/
   362 				ENDSED
   363             ;;
   364         soft)
   365             cat <<-ENDSED
   366 				s/^[^_]*(HAS_FPU).*/\\# \\1 is not set/
   367 				s/.*(UCLIBC_HAS_FPU).*/# \\1 is not set/
   368 				ENDSED
   369             ;;
   370     esac
   371 
   372     # We always want ctor/dtor
   373     cat <<-ENDSED
   374 		s/^# (UCLIBC_CTOR_DTOR) is not set/\\1=y/
   375 		ENDSED
   376 
   377     # Change paths to work with crosstool-NG
   378     # From http://www.uclibc.org/cgi-bin/viewcvs.cgi?rev=16846&view=rev
   379     #  " we just want the kernel headers, not the whole kernel source ...
   380     #  " so people may need to update their paths slightly
   381     quoted_kernel_source=$(echo "${CT_HEADERS_DIR}" | sed -r -e 's,/include/?$,,; s,/,\\/,g;')
   382     quoted_headers_dir=$(echo "${CT_HEADERS_DIR}" | sed -r -e 's,/,\\/,g;')
   383     # CROSS_COMPILER_PREFIX is left as is, as the CROSS parameter is forced on the command line
   384     # DEVEL_PREFIX is left as '/usr/' because it is post-pended to $PREFIX, wich is the correct value of ${PREFIX}/${TARGET}
   385     # Some (old) versions of uClibc use KERNEL_SOURCE (which is _wrong_), and
   386     # newer versions use KERNEL_HEADERS (which is right).
   387     cat <<-ENDSED
   388 		s/^DEVEL_PREFIX=".*"/DEVEL_PREFIX="\\/usr\\/"/
   389 		s/^RUNTIME_PREFIX=".*"/RUNTIME_PREFIX="\\/"/
   390 		s/^SHARED_LIB_LOADER_PREFIX=.*/SHARED_LIB_LOADER_PREFIX="\\/lib\\/"/
   391 		s/^KERNEL_SOURCE=".*"/KERNEL_SOURCE="${quoted_kernel_source}"/
   392 		s/^KERNEL_HEADERS=".*"/KERNEL_HEADERS="${quoted_headers_dir}"/
   393 		s/^UCLIBC_DOWNLOAD_PREGENERATED_LOCALE=y/\\# UCLIBC_DOWNLOAD_PREGENERATED_LOCALE is not set/
   394 		ENDSED
   395 
   396     if [ "${CT_USE_PIPES}" = "y" ]; then
   397         if grep UCLIBC_EXTRA_CFLAGS extra/Configs/Config.in >/dev/null 2>&1; then
   398             # Good, there is special provision for such things as -pipe!
   399             cat <<-ENDSED
   400 				s/^(UCLIBC_EXTRA_CFLAGS=".*)"$/\\1 -pipe"/
   401 				ENDSED
   402         else
   403             # Hack our -pipe into WARNINGS, which will be internally incorporated to
   404             # CFLAGS. This a dirty hack, but yet needed
   405             cat <<-ENDSED
   406 				s/^(WARNINGS=".*)"$/\\1 -pipe"/
   407 				ENDSED
   408         fi
   409     fi
   410 
   411     # Locales support
   412     # Note that the two PREGEN_LOCALE and the XLOCALE lines may be missing
   413     # entirely if LOCALE is not set.  If LOCALE was already set, we'll
   414     # assume the user has already made all the appropriate generation
   415     # arrangements.  Note that having the uClibc Makefile download the
   416     # pregenerated locales is not compatible with crosstool; besides,
   417     # crosstool downloads them as part of getandpatch.sh.
   418     case "${CT_LIBC_UCLIBC_LOCALES}:${CT_LIBC_UCLIBC_LOCALES_PREGEN_DATA}" in
   419         :*)
   420             ;;
   421         y:)
   422             cat <<-ENDSED
   423 				s/^# UCLIBC_HAS_LOCALE is not set/UCLIBC_HAS_LOCALE=y\\
   424 				# UCLIBC_PREGENERATED_LOCALE_DATA is not set\\
   425 				# UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA is not set\\
   426 				# UCLIBC_HAS_XLOCALE is not set/
   427 				ENDSED
   428             ;;
   429         y:y)
   430             cat <<-ENDSED
   431 				s/^# UCLIBC_HAS_LOCALE is not set/UCLIBC_HAS_LOCALE=y\\
   432 				UCLIBC_PREGENERATED_LOCALE_DATA=y\\
   433 				# UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA is not set\\
   434 				# UCLIBC_HAS_XLOCALE is not set/
   435 				ENDSED
   436             ;;
   437     esac
   438 
   439     # WCHAR support
   440     if [ "${CT_LIBC_UCLIBC_WCHAR}" = "y" ] ; then
   441         cat <<-ENDSED
   442 			s/^.*UCLIBC_HAS_WCHAR.*/UCLIBC_HAS_WCHAR=y/
   443 			ENDSED
   444     else
   445         cat <<-ENDSED
   446 			s/^.*UCLIBC_HAS_WCHAR.*/UCLIBC_HAS_WCHAR=n/
   447 			ENDSED
   448     fi
   449 
   450     # Force on options needed for C++ if we'll be making a C++ compiler.
   451     # I'm not sure locales are a requirement for doing C++... Are they?
   452     if [ "${CT_CC_LANG_CXX}" = "y" ]; then
   453         cat <<-ENDSED
   454 			s/^# DO_C99_MATH is not set/DO_C99_MATH=y/
   455 			s/^# UCLIBC_HAS_GNU_GETOPT is not set/UCLIBC_HAS_GNU_GETOPT=y/
   456 			ENDSED
   457     fi
   458 
   459     # Push the threading model
   460     # Note: we take into account all of the .28, .29, .30 and .31
   461     #       versions, here. Even snapshots with NPTL.
   462     case "${CT_THREADS}:${CT_LIBC_UCLIBC_LNXTHRD}" in
   463         none:)
   464             cat <<-ENDSED
   465 				s/^UCLIBC_HAS_THREADS=y/# UCLIBC_HAS_THREADS is not set/
   466 				s/^LINUXTHREADS_OLD=y/# LINUXTHREADS_OLD is not set/
   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:old)
   472             cat <<-ENDSED
   473 				s/^# UCLIBC_HAS_THREADS is not set/UCLIBC_HAS_THREADS=y/
   474 				s/^# LINUXTHREADS_OLD is not set/LINUXTHREADS_OLD=y/
   475 				s/^LINUXTHREADS_NEW=y/# LINUXTHREADS_NEW is not set/
   476 				s/^UCLIBC_HAS_THREADS_NATIVE=y/# UCLIBC_HAS_THREADS_NATIVE is not set/
   477 				ENDSED
   478             ;;
   479         linuxthreads:new)
   480             cat <<-ENDSED
   481 				s/^# UCLIBC_HAS_THREADS is not set/UCLIBC_HAS_THREADS=y/
   482 				s/^LINUXTHREADS_OLD=y/# LINUXTHREADS_OLD is not set/
   483 				s/^# LINUXTHREADS_NEW is not set/LINUXTHREADS_NEW=y/
   484 				s/^UCLIBC_HAS_THREADS_NATIVE=y/# UCLIBC_HAS_THREADS_NATIVE is not set/
   485 				ENDSED
   486             ;;
   487         nptl:)
   488             cat <<-ENDSED
   489 				s/^HAS_NO_THREADS=y/# HAS_NO_THREADS is not set/
   490 				s/^UCLIBC_HAS_THREADS=y/# UCLIBC_HAS_THREADS is not set/
   491 				s/^LINUXTHREADS_OLD=y/# LINUXTHREADS_OLD is not set/
   492 				s/^LINUXTHREADS_NEW=y/# LINUXTHREADS_NEW is not set/
   493 				s/^# UCLIBC_HAS_THREADS_NATIVE is not set/UCLIBC_HAS_THREADS_NATIVE=y/
   494 				ENDSED
   495             ;;
   496         *)
   497             CT_Abort "Incorrect thread settings: CT_THREADS='${CT_THREAD}' CT_LIBC_UCLIBC_LNXTHRD='${CT_LIBC_UCLIBC_LNXTHRD}'"
   498             ;;
   499     esac
   500 
   501     # Always build the libpthread_db
   502     cat <<-ENDSED
   503 		s/^# PTHREADS_DEBUG_SUPPORT is not set.*/PTHREADS_DEBUG_SUPPORT=y/
   504 		ENDSED
   505 
   506     # Force on debug options if asked for
   507     case "${CT_LIBC_UCLIBC_DEBUG_LEVEL}" in
   508       0)
   509         cat <<-ENDSED
   510 			s/^DODEBUG=y/# DODEBUG is not set/
   511 			s/^DODEBUG_PT=y/# DODEBUG_PT is not set/
   512 			s/^DOASSERTS=y/# DOASSERTS is not set/
   513 			s/^SUPPORT_LD_DEBUG=y/# SUPPORT_LD_DEBUG is not set/
   514 			s/^SUPPORT_LD_DEBUG_EARLY=y/# SUPPORT_LD_DEBUG_EARLY is not set/
   515 			s/^UCLIBC_MALLOC_DEBUGGING=y/# UCLIBC_MALLOC_DEBUGGING is not set/
   516 			ENDSED
   517         ;;
   518       1)
   519         cat <<-ENDSED
   520 			s/^# DODEBUG is not set.*/DODEBUG=y/
   521 			s/^DODEBUG_PT=y/# DODEBUG_PT is not set/
   522 			s/^DOASSERTS=y/# DOASSERTS is not set/
   523 			s/^SUPPORT_LD_DEBUG=y/# SUPPORT_LD_DEBUG is not set/
   524 			s/^SUPPORT_LD_DEBUG_EARLY=y/# SUPPORT_LD_DEBUG_EARLY is not set/
   525 			s/^UCLIBC_MALLOC_DEBUGGING=y/# UCLIBC_MALLOC_DEBUGGING is not set/
   526 			ENDSED
   527         ;;
   528       2)
   529         cat <<-ENDSED
   530 			s/^# DODEBUG is not set.*/DODEBUG=y/
   531 			s/^DODEBUG_PT=y/# DODEBUG_PT is not set/
   532 			s/^# DOASSERTS is not set.*/DOASSERTS=y/
   533 			s/^# SUPPORT_LD_DEBUG is not set.*/SUPPORT_LD_DEBUG=y/
   534 			s/^SUPPORT_LD_DEBUG_EARLY=y/# SUPPORT_LD_DEBUG_EARLY is not set/
   535 			s/^# UCLIBC_MALLOC_DEBUGGING is not set/UCLIBC_MALLOC_DEBUGGING=y/
   536 			ENDSED
   537         ;;
   538       3)
   539         cat <<-ENDSED
   540 			s/^# DODEBUG is not set.*/DODEBUG=y/
   541 			s/^# DODEBUG_PT is not set.*/DODEBUG_PT=y/
   542 			s/^# DOASSERTS is not set.*/DOASSERTS=y/
   543 			s/^# SUPPORT_LD_DEBUG is not set.*/SUPPORT_LD_DEBUG=y/
   544 			s/^# SUPPORT_LD_DEBUG_EARLY is not set.*/SUPPORT_LD_DEBUG_EARLY=y/
   545 			s/^# UCLIBC_MALLOC_DEBUGGING is not set/UCLIBC_MALLOC_DEBUGGING=y/
   546 			ENDSED
   547         ;;
   548     esac
   549 
   550     # And now, this is the end
   551     ) >>"${munge_file}"
   552 
   553     sed -r -f "${munge_file}" "${src_config_file}" >"${dst_config_file}"
   554 }