scripts/build/libc/uClibc.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Wed Jul 28 01:03:07 2010 +0200 (2010-07-28)
changeset 2036 67e02b48b595
parent 2033 ffc1121618fa
child 2037 cd00fdab6117
permissions -rw-r--r--
libc/uClibc: do not systematically use pre-generated locale data

It seems that using pre-generated locale data can be more problematic
than usefull in some circumstances.

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