scripts/build/libc/uClibc.sh
author Remy Bohmer <linux@bohmer.net>
Thu May 27 23:18:19 2010 +0200 (2010-05-27)
changeset 2060 51e4597b07fc
parent 2037 cd00fdab6117
child 2081 223aaf040327
permissions -rw-r--r--
scripts: add option to strip all toolchain executables

To reduce filesizes of the toolchain and even improve build times
of projects to be build with this toolchain it is usefull to strip
the delivered toolchain executables. Since it is not likely that we
will debug the toolchain executables itself we do not need the
debug information inside the executables itself.

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