scripts/build/libc/uClibc.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Thu Jul 22 20:06:27 2010 +0200 (2010-07-22)
changeset 2033 ffc1121618fa
parent 2009 7e19c1de65cd
child 2036 67e02b48b595
permissions -rw-r--r--
libc/uClibc: do not install cross-ldd

I was unable to make the cross-ldd from uClibc to work, and
it is not possible to build it on non-POSIX system.

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