scripts/build/libc/uClibc.sh
author "Benoît THÉBAUDEAU" <benoit.thebaudeau@advansee.com>
Thu Aug 18 16:05:48 2011 +0200 (2011-08-18)
changeset 2612 a52574521bea
parent 2578 35afb309f957
child 2761 19760eb7a090
permissions -rw-r--r--
debug/gdb: update GDB revisions

Update GDB with the latest available revisions.

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