scripts/build/libc/uClibc.sh
author Remy Bohmer <linux@bohmer.net>
Sun Jul 11 22:23:34 2010 +0200 (2010-07-11)
changeset 2021 3e52a1510f87
parent 2008 b13d0db6fa95
child 2033 ffc1121618fa
permissions -rw-r--r--
debug/gdb: Fix compilation for Mingw hosts

GDB requires PDcurses instead of ncurses while running on Windows.
So, do not always compile ncurses in case GDB needs to build.

PDcurses is provided by an earlier build step and is not described in
this file.

Signed-off-by: Remy Bohmer <linux@bohmer.net>
[yann.morin.1998@anciense.nib.fr: we already have a way to detect ncurses usage]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
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@1209
   225
    if [ "${CT_LIBC_UCLIBC_BUILD_CROSS_LDD}" = "y" ]; then
yann@1209
   226
        CT_DoLog EXTRA "Building C library cross-ldd"
yann@1209
   227
        CT_DoExecLog ALL                    \
yann@1209
   228
        make PREFIX="${CT_SYSROOT_DIR}/"    \
yann@1209
   229
             ${CT_LIBC_UCLIBC_VERBOSITY}    \
yann@1209
   230
             -C utils hostutils
yann@1209
   231
yann@1209
   232
        CT_DoLog EXTRA "Installing C library cross-ldd"
yann@1209
   233
        CT_DoExecLog ALL install -m 0755 utils/ldd.host "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ldd"
yann@1209
   234
    fi
yann@1209
   235
yann@850
   236
    CT_EndStep
yann@850
   237
}
yann@850
   238
yann@850
   239
# This function is used to install those components needing the final C compiler
yann@850
   240
do_libc_finish() {
yann@1209
   241
    :
yann@850
   242
}
yann@850
   243
yann@850
   244
# Initialises the .config file to sensible values
yann@850
   245
# $1: original file
yann@850
   246
# $2: munged file
yann@850
   247
mungeuClibcConfig() {
yann@850
   248
    src_config_file="$1"
yann@850
   249
    dst_config_file="$2"
yann@850
   250
    munge_file="${CT_BUILD_DIR}/munge-uClibc-config.sed"
yann@850
   251
yann@850
   252
    # Start with a fresh file
yann@850
   253
    rm -f "${munge_file}"
yann@850
   254
    touch "${munge_file}"
yann@850
   255
yann@1674
   256
    # Do it all in a sub-shell, it's easier to redirect output
yann@1674
   257
    (
yann@1674
   258
yann@850
   259
    # Hack our target in the config file.
yann@1750
   260
    case "${CT_ARCH}:${CT_ARCH_BITNESS}" in
thomas@1910
   261
        x86:32)      arch=i386;;
thomas@1910
   262
        x86:64)      arch=x86_64;;
thomas@1910
   263
        sh:32)       arch="sh";;
thomas@1910
   264
        sh:64)       arch="sh64";;
thomas@1910
   265
        blackfin:32) arch="bfin";;
thomas@1910
   266
        *)           arch="${CT_ARCH}";;
yann@1750
   267
    esac
yann@850
   268
    # Also remove stripping: its the responsibility of the
yann@850
   269
    # firmware builder to strip or not.
yann@1674
   270
    cat <<-ENDSED
yann@1674
   271
		s/^(TARGET_.*)=y$/# \\1 is not set/
yann@1750
   272
		s/^# TARGET_${arch} is not set/TARGET_${arch}=y/
yann@1750
   273
		s/^TARGET_ARCH=".*"/TARGET_ARCH="${arch}"/
yann@1674
   274
		s/.*(DOSTRIP).*/# \\1 is not set/
yann@1674
   275
		ENDSED
yann@850
   276
yann@850
   277
    # Ah. We may one day need architecture-specific handler here...
yann@1675
   278
    if [ "${CT_ARCH}" = "arm" ]; then
yann@1675
   279
        # Hack the ARM {E,O}ABI into the config file
yann@1675
   280
        if [ "${CT_ARCH_ARM_EABI}" = "y" ]; then
yann@1675
   281
            cat <<-ENDSED
yann@1675
   282
				s/.*(CONFIG_ARM_OABI).*/# \\1 is not set/
yann@1675
   283
				s/.*(CONFIG_ARM_EABI).*/\\1=y/
yann@1675
   284
				ENDSED
yann@1675
   285
        else
yann@1675
   286
            cat <<-ENDSED
yann@1675
   287
				s/.*(CONFIG_ARM_OABI).*/\\1=y/
yann@1675
   288
				s/.*(CONFIG_ARM_EABI).*/# \\1 is not set/
yann@1675
   289
				ENDSED
yann@1675
   290
        fi
yann@850
   291
    fi
yann@850
   292
yann@850
   293
    # Accomodate for old and new uClibc versions, where the
yann@850
   294
    # way to select between big/little endian has changed
yann@850
   295
    case "${CT_ARCH_BE},${CT_ARCH_LE}" in
yann@1674
   296
        y,) cat <<-ENDSED
yann@1674
   297
				s/.*(ARCH_LITTLE_ENDIAN).*/# \\1 is not set/
yann@1674
   298
				s/.*(ARCH_BIG_ENDIAN).*/\\1=y/
yann@1674
   299
				s/.*(ARCH_WANTS_LITTLE_ENDIAN).*/# \\1 is not set/
yann@1674
   300
				s/.*(ARCH_WANTS_BIG_ENDIAN).*/\\1=y/
yann@1674
   301
				ENDSED
yann@850
   302
        ;;
yann@1674
   303
        ,y) cat <<-ENDSED
yann@1674
   304
				s/.*(ARCH_LITTLE_ENDIAN).*/\\1=y/
yann@1674
   305
				s/.*(ARCH_BIG_ENDIAN).*/# \\1 is not set/
yann@1674
   306
				s/.*(ARCH_WANTS_LITTLE_ENDIAN).*/\\1=y/
yann@1674
   307
				s/.*(ARCH_WANTS_BIG_ENDIAN).*/# \\1 is not set/
yann@1674
   308
				ENDSED
yann@850
   309
        ;;
yann@850
   310
    esac
yann@850
   311
yann@850
   312
    # Accomodate for old and new uClibc version, where the
yann@850
   313
    # way to select between hard/soft float has changed
yann@850
   314
    case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
yann@1674
   315
        y,) cat <<-ENDSED
yann@1674
   316
				s/^[^_]*(HAS_FPU).*/\\1=y/
yann@1674
   317
				s/.*(UCLIBC_HAS_FPU).*/\\1=y/
yann@1674
   318
				ENDSED
yann@850
   319
            ;;
yann@1674
   320
        ,y) cat <<-ENDSED
yann@1674
   321
				s/^[^_]*(HAS_FPU).*/\\# \\1 is not set/
yann@1674
   322
				s/.*(UCLIBC_HAS_FPU).*/# \\1 is not set/
yann@1674
   323
				ENDSED
yann@850
   324
            ;;
yann@850
   325
    esac
yann@850
   326
yann@850
   327
    # Change paths to work with crosstool-NG
yann@850
   328
    # From http://www.uclibc.org/cgi-bin/viewcvs.cgi?rev=16846&view=rev
yann@850
   329
    #  " we just want the kernel headers, not the whole kernel source ...
yann@850
   330
    #  " so people may need to update their paths slightly
yann@850
   331
    quoted_kernel_source=$(echo "${CT_HEADERS_DIR}" | sed -r -e 's,/include/?$,,; s,/,\\/,g;')
yann@850
   332
    quoted_headers_dir=$(echo "${CT_HEADERS_DIR}" | sed -r -e 's,/,\\/,g;')
yann@850
   333
    # CROSS_COMPILER_PREFIX is left as is, as the CROSS parameter is forced on the command line
yann@850
   334
    # DEVEL_PREFIX is left as '/usr/' because it is post-pended to $PREFIX, wich is the correct value of ${PREFIX}/${TARGET}
yann@850
   335
    # Some (old) versions of uClibc use KERNEL_SOURCE (which is _wrong_), and
yann@1674
   336
    # newer versions use KERNEL_HEADERS (which is right).
yann@1674
   337
    cat <<-ENDSED
yann@1674
   338
		s/^DEVEL_PREFIX=".*"/DEVEL_PREFIX="\\/usr\\/"/
yann@1674
   339
		s/^RUNTIME_PREFIX=".*"/RUNTIME_PREFIX="\\/"/
yann@1674
   340
		s/^SHARED_LIB_LOADER_PREFIX=.*/SHARED_LIB_LOADER_PREFIX="\\/lib\\/"/
yann@1674
   341
		s/^KERNEL_SOURCE=".*"/KERNEL_SOURCE="${quoted_kernel_source}"/
yann@1674
   342
		s/^KERNEL_HEADERS=".*"/KERNEL_HEADERS="${quoted_headers_dir}"/
yann@1674
   343
		s/^UCLIBC_DOWNLOAD_PREGENERATED_LOCALE=y/\\# UCLIBC_DOWNLOAD_PREGENERATED_LOCALE is not set/
yann@1674
   344
		ENDSED
yann@850
   345
yann@850
   346
    if [ "${CT_USE_PIPES}" = "y" ]; then
yann@850
   347
        if grep UCLIBC_EXTRA_CFLAGS extra/Configs/Config.in >/dev/null 2>&1; then
yann@850
   348
            # Good, there is special provision for such things as -pipe!
yann@1674
   349
            cat <<-ENDSED
yann@1674
   350
				s/^(UCLIBC_EXTRA_CFLAGS=".*)"$/\\1 -pipe"/
yann@1674
   351
				ENDSED
yann@850
   352
        else
yann@850
   353
            # Hack our -pipe into WARNINGS, which will be internally incorporated to
yann@850
   354
            # CFLAGS. This a dirty hack, but yet needed
yann@1674
   355
            cat <<-ENDSED
yann@1674
   356
				s/^(WARNINGS=".*)"$/\\1 -pipe"/
yann@1674
   357
				ENDSED
yann@850
   358
        fi
yann@850
   359
    fi
yann@850
   360
yann@1028
   361
    # Locales support
yann@850
   362
    # Note that the two PREGEN_LOCALE and the XLOCALE lines may be missing
yann@850
   363
    # entirely if LOCALE is not set.  If LOCALE was already set, we'll
yann@850
   364
    # assume the user has already made all the appropriate generation
yann@850
   365
    # arrangements.  Note that having the uClibc Makefile download the
yann@850
   366
    # pregenerated locales is not compatible with crosstool; besides,
yann@850
   367
    # crosstool downloads them as part of getandpatch.sh.
yann@1028
   368
    if [ "${CT_LIBC_UCLIBC_LOCALES}" = "y" ] ; then
yann@1674
   369
        cat <<-ENDSED
yann@1674
   370
			s/^# UCLIBC_HAS_LOCALE is not set/UCLIBC_HAS_LOCALE=y\\
yann@1674
   371
			UCLIBC_PREGENERATED_LOCALE_DATA=y\\
yann@1674
   372
			# UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA is not set\\
yann@1674
   373
			# UCLIBC_HAS_XLOCALE is not set/
yann@1674
   374
			ENDSED
yann@1028
   375
    fi
yann@1028
   376
fpasch@1639
   377
    # WCHAR support
fpasch@1639
   378
    if [ "${CT_LIBC_UCLIBC_WCHAR}" = "y" ] ; then
yann@1674
   379
        cat <<-ENDSED
yann@1674
   380
			s/^.*UCLIBC_HAS_WCHAR.*/UCLIBC_HAS_WCHAR=y/
yann@1674
   381
			ENDSED
fpasch@1639
   382
    else
yann@1674
   383
        cat <<-ENDSED
yann@1674
   384
			s/^.*UCLIBC_HAS_WCHAR.*/UCLIBC_HAS_WCHAR=n/
yann@1674
   385
			ENDSED
fpasch@1639
   386
    fi
fpasch@1639
   387
yann@1028
   388
    # Force on options needed for C++ if we'll be making a C++ compiler.
yann@1028
   389
    # I'm not sure locales are a requirement for doing C++... Are they?
yann@850
   390
    if [ "${CT_CC_LANG_CXX}" = "y" ]; then
yann@1674
   391
        cat <<-ENDSED
yann@1674
   392
			s/^# DO_C99_MATH is not set/DO_C99_MATH=y/
yann@1674
   393
			s/^# UCLIBC_CTOR_DTOR is not set/UCLIBC_CTOR_DTOR=y/
yann@1674
   394
			s/^# UCLIBC_HAS_GNU_GETOPT is not set/UCLIBC_HAS_GNU_GETOPT=y/
yann@1674
   395
			ENDSED
yann@850
   396
    fi
yann@850
   397
yann@1977
   398
    # Push the threading model
yann@1977
   399
    # Note: we take into account all of the .28, .29, .30 and .31
yann@2009
   400
    #       versions, here. Even snapshots with NPTL.
yann@1977
   401
    case "${CT_THREADS}:${CT_LIBC_UCLIBC_LNXTHRD}" in
yann@2009
   402
        none:)
yann@1977
   403
            cat <<-ENDSED
yann@1977
   404
				s/^UCLIBC_HAS_THREADS=y/# UCLIBC_HAS_THREADS is not set/
yann@1977
   405
				s/^LINUXTHREADS_OLD=y/# LINUXTHREADS_OLD is not set/
yann@1977
   406
				s/^LINUXTHREADS_NEW=y/# LINUXTHREADS_NEW is not set/
yann@2009
   407
				s/^UCLIBC_HAS_THREADS_NATIVE=y/# UCLIBC_HAS_THREADS_NATIVE is not set/
yann@1977
   408
				ENDSED
yann@1977
   409
            ;;
yann@2007
   410
        linuxthreads:old)
yann@1977
   411
            cat <<-ENDSED
yann@1977
   412
				s/^# UCLIBC_HAS_THREADS is not set/UCLIBC_HAS_THREADS=y/
yann@2007
   413
				s/^# LINUXTHREADS_OLD is not set/LINUXTHREADS_OLD=y/
yann@1977
   414
				s/^LINUXTHREADS_NEW=y/# LINUXTHREADS_NEW is not set/
yann@2009
   415
				s/^UCLIBC_HAS_THREADS_NATIVE=y/# UCLIBC_HAS_THREADS_NATIVE is not set/
yann@1977
   416
				ENDSED
yann@1977
   417
            ;;
yann@2007
   418
        linuxthreads:new)
yann@1977
   419
            cat <<-ENDSED
yann@1977
   420
				s/^# UCLIBC_HAS_THREADS is not set/UCLIBC_HAS_THREADS=y/
yann@1977
   421
				s/^LINUXTHREADS_OLD=y/# LINUXTHREADS_OLD is not set/
yann@2007
   422
				s/^# LINUXTHREADS_NEW is not set/LINUXTHREADS_NEW=y/
yann@2009
   423
				s/^UCLIBC_HAS_THREADS_NATIVE=y/# UCLIBC_HAS_THREADS_NATIVE is not set/
yann@1977
   424
				ENDSED
yann@1977
   425
            ;;
yann@2009
   426
        nptl:)
yann@2009
   427
            cat <<-ENDSED
yann@2009
   428
				s/^HAS_NO_THREADS=y/# HAS_NO_THREADS is not set/
yann@2009
   429
				s/^UCLIBC_HAS_THREADS=y/# UCLIBC_HAS_THREADS is not set/
yann@2009
   430
				s/^LINUXTHREADS_OLD=y/# LINUXTHREADS_OLD is not set/
yann@2009
   431
				s/^LINUXTHREADS_NEW=y/# LINUXTHREADS_NEW is not set/
yann@2009
   432
				s/^# UCLIBC_HAS_THREADS_NATIVE is not set/UCLIBC_HAS_THREADS_NATIVE=y/
yann@2009
   433
				ENDSED
yann@2009
   434
            ;;
yann@2009
   435
        *)
yann@2009
   436
            CT_Abort "Incorrect thread settings: CT_THREADS='${CT_THREAD}' CT_LIBC_UCLIBC_LNXTHRD='${CT_LIBC_UCLIBC_LNXTHRD}'"
yann@2009
   437
            ;;
yann@1977
   438
    esac
yann@1977
   439
yann@850
   440
    # Always build the libpthread_db
yann@1674
   441
    cat <<-ENDSED
yann@1674
   442
		s/^# PTHREADS_DEBUG_SUPPORT is not set.*/PTHREADS_DEBUG_SUPPORT=y/
yann@1674
   443
		ENDSED
yann@850
   444
yann@850
   445
    # Force on debug options if asked for
yann@850
   446
    case "${CT_LIBC_UCLIBC_DEBUG_LEVEL}" in
yann@850
   447
      0)
yann@1674
   448
        cat <<-ENDSED
yann@1674
   449
			s/^DODEBUG=y/# DODEBUG is not set/
yann@1674
   450
			s/^DODEBUG_PT=y/# DODEBUG_PT is not set/
yann@1674
   451
			s/^DOASSERTS=y/# DOASSERTS is not set/
yann@1674
   452
			s/^SUPPORT_LD_DEBUG=y/# SUPPORT_LD_DEBUG is not set/
yann@1674
   453
			s/^SUPPORT_LD_DEBUG_EARLY=y/# SUPPORT_LD_DEBUG_EARLY is not set/
yann@1674
   454
			s/^UCLIBC_MALLOC_DEBUGGING=y/# UCLIBC_MALLOC_DEBUGGING is not set/
yann@1674
   455
			ENDSED
yann@850
   456
        ;;
yann@850
   457
      1)
yann@1674
   458
        cat <<-ENDSED
yann@1674
   459
			s/^# DODEBUG is not set.*/DODEBUG=y/
yann@1674
   460
			s/^DODEBUG_PT=y/# DODEBUG_PT is not set/
yann@1674
   461
			s/^DOASSERTS=y/# DOASSERTS is not set/
yann@1674
   462
			s/^SUPPORT_LD_DEBUG=y/# SUPPORT_LD_DEBUG is not set/
yann@1674
   463
			s/^SUPPORT_LD_DEBUG_EARLY=y/# SUPPORT_LD_DEBUG_EARLY is not set/
yann@1674
   464
			s/^UCLIBC_MALLOC_DEBUGGING=y/# UCLIBC_MALLOC_DEBUGGING is not set/
yann@1674
   465
			ENDSED
yann@850
   466
        ;;
yann@850
   467
      2)
yann@1674
   468
        cat <<-ENDSED
yann@1674
   469
			s/^# DODEBUG is not set.*/DODEBUG=y/
yann@1674
   470
			s/^# DODEBUG_PT is not set.*/DODEBUG_PT=y/
yann@1674
   471
			s/^# DOASSERTS is not set.*/DOASSERTS=y/
yann@1674
   472
			s/^# SUPPORT_LD_DEBUG is not set.*/SUPPORT_LD_DEBUG=y/
yann@1674
   473
			s/^# SUPPORT_LD_DEBUG_EARLY is not set.*/SUPPORT_LD_DEBUG_EARLY=y/
yann@1674
   474
			s/^# UCLIBC_MALLOC_DEBUGGING is not set/UCLIBC_MALLOC_DEBUGGING=y/
yann@1674
   475
			ENDSED
yann@850
   476
        ;;
yann@850
   477
    esac
yann@1674
   478
yann@1674
   479
    # And now, this is the end
yann@1674
   480
    ) >>"${munge_file}"
yann@1674
   481
yann@850
   482
    sed -r -f "${munge_file}" "${src_config_file}" >"${dst_config_file}"
yann@850
   483
}