scripts/build/libc/uClibc.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Jan 17 23:04:57 2011 +0100 (2011-01-17)
changeset 2271 42ebee266fe5
parent 2238 c9eab2fa7a3c
child 2275 9ab4392430ad
permissions -rw-r--r--
libc/eglibc: cleanup common code for sharing with glibc

Some stuff is eglibc-specific, so needs to be conditonal.

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