scripts/build/libc/uClibc.sh
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Thu Jan 10 00:27:13 2013 +0100 (2013-01-10)
changeset 3159 fb71cad4b085
parent 3099 79169596cfc9
child 3162 e51eb0a614c7
permissions -rw-r--r--
arch/arm: OABI is no more, switch to only EABI

Well, leave the prompt as an OBSOLETE thing, scheduled to
be removed soon.

As an indication OABI lives its last days, gcc-4.8 will no
longer recognise non-EABI targets.

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