scripts/build/libc/glibc.sh
author "Benoît THÉBAUDEAU" <benoit.thebaudeau@advansee.com>
Fri Jul 29 15:30:53 2011 +0200 (2011-07-29)
changeset 2587 7727970d04e9
parent 2504 3fc114996b20
child 3041 b9f695c2f5b7
permissions -rw-r--r--
libc/glibc: add partial support for locales

This patch adds partial support for glibc locales.

For now, it only generates the appropriate locales when the host and the target
have the same endianness and uint32_t alignment.

Signed-off-by: "Benoît THÉBAUDEAU" <benoit.thebaudeau@advansee.com>
yann@850
     1
# This file adds functions to build glibc
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@2272
     5
# Add the definitions common to glibc and eglibc
yann@2483
     6
#   do_libc_extract
yann@2272
     7
#   do_libc_start_files
yann@2277
     8
#   do_libc
yann@2277
     9
#   do_libc_finish
yann@2277
    10
#   do_libc_add_ons_list
yann@2277
    11
#   do_libc_min_kernel_config
yann@2272
    12
. "${CT_LIB_DIR}/scripts/build/libc/glibc-eglibc.sh-common"
yann@2272
    13
yann@850
    14
# Download glibc
yann@850
    15
do_libc_get() {
yann@1260
    16
    local date
yann@1260
    17
    local version
yann@1482
    18
    local -a addons_list
yann@1482
    19
yann@1482
    20
    addons_list=($(do_libc_add_ons_list " "))
yann@1114
    21
yann@1759
    22
    # Main source
yann@1759
    23
    CT_GetFile "glibc-${CT_LIBC_VERSION}"               \
yann@1759
    24
               {ftp,http}://ftp.gnu.org/gnu/glibc       \
yann@1759
    25
               ftp://gcc.gnu.org/pub/glibc/releases     \
yann@1759
    26
               ftp://gcc.gnu.org/pub/glibc/snapshots
yann@1759
    27
yann@1759
    28
    # C library addons
yann@1759
    29
    for addon in "${addons_list[@]}"; do
yann@2504
    30
        # Never ever try to download these add-ons,
yann@2504
    31
        # they've always been internal
yann@2504
    32
        case "${addon}" in
yann@2504
    33
            nptl)   continue;;
yann@2504
    34
        esac
yann@2504
    35
yann@2496
    36
        if ! CT_GetFile "glibc-${addon}-${CT_LIBC_VERSION}"     \
yann@2496
    37
                        {ftp,http}://ftp.gnu.org/gnu/glibc      \
yann@2496
    38
                        ftp://gcc.gnu.org/pub/glibc/releases    \
yann@2496
    39
                        ftp://gcc.gnu.org/pub/glibc/snapshots
yann@2496
    40
        then
yann@2496
    41
            # Some add-ons are bundled with glibc, others are
yann@2496
    42
            # bundled in their own tarball. Eg. NPTL is internal,
yann@2496
    43
            # while LinuxThreads was external. Also, for old
yann@2496
    44
            # versions of glibc, the libidn add-on was external,
yann@2496
    45
            # but with version >=2.10, it is internal.
yann@2496
    46
            CT_DoLog DEBUG "Addon '${addon}' could not be downloaded."
yann@2496
    47
            CT_DoLog DEBUG "We'll see later if we can find it in the source tree"
yann@2496
    48
        fi
yann@1759
    49
    done
yann@850
    50
yann@850
    51
    return 0
yann@850
    52
}
yann@850
    53
yann@850
    54
# There is nothing to do for glibc check config
yann@850
    55
do_libc_check_config() {
yann@850
    56
    :
yann@850
    57
}
benoit@2587
    58
benoit@2587
    59
# Extract the files required for the libc locales
benoit@2587
    60
# Nothing to do
benoit@2587
    61
do_libc_locales_extract() {
benoit@2587
    62
    :
benoit@2587
    63
}
benoit@2587
    64
benoit@2587
    65
# Build and install the libc locales
benoit@2587
    66
do_libc_locales() {
benoit@2587
    67
    local src_dir="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}"
benoit@2587
    68
    local -a extra_config
benoit@2587
    69
    local glibc_cflags
benoit@2587
    70
benoit@2587
    71
    mkdir -p "${CT_BUILD_DIR}/build-localedef"
benoit@2587
    72
    cd "${CT_BUILD_DIR}/build-localedef"
benoit@2587
    73
benoit@2587
    74
    CT_DoLog EXTRA "Configuring C library localedef"
benoit@2587
    75
benoit@2587
    76
    if [ "${CT_LIBC_EGLIBC_HAS_PKGVERSION_BUGURL}" = "y" ]; then
benoit@2587
    77
        extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
benoit@2587
    78
        [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
benoit@2587
    79
    fi
benoit@2587
    80
benoit@2587
    81
    CT_DoLog DEBUG "Extra config args passed: '${extra_config[*]}'"
benoit@2587
    82
benoit@2587
    83
    glibc_cflags="-O2 -fno-stack-protector"
benoit@2587
    84
    case "${CT_LIBC_ENABLE_FORTIFIED_BUILD}" in
benoit@2587
    85
        y)  ;;
benoit@2587
    86
        *)  glibc_cflags+=" -U_FORTIFY_SOURCE";;
benoit@2587
    87
    esac
benoit@2587
    88
benoit@2587
    89
    # ./configure is misled by our tools override wrapper for bash
benoit@2587
    90
    # so just tell it where the real bash is _on_the_target_!
benoit@2587
    91
    # Notes:
benoit@2587
    92
    # - ${ac_cv_path_BASH_SHELL} is only used to set BASH_SHELL
benoit@2587
    93
    # - ${BASH_SHELL}            is only used to set BASH
benoit@2587
    94
    # - ${BASH}                  is only used to set the shebang
benoit@2587
    95
    #                            in two scripts to run on the target
benoit@2587
    96
    # So we can safely bypass bash detection at compile time.
benoit@2587
    97
    # Should this change in a future eglibc release, we'd better
benoit@2587
    98
    # directly mangle the generated scripts _after_ they get built,
benoit@2587
    99
    # or even after they get installed... eglibc is such a sucker...
benoit@2587
   100
    echo "ac_cv_path_BASH_SHELL=/bin/bash" >>config.cache
benoit@2587
   101
benoit@2587
   102
    # Configure with --prefix the way we want it on the target...
benoit@2587
   103
benoit@2587
   104
    CT_DoExecLog CFG                                                \
benoit@2587
   105
    CFLAGS="${glibc_cflags}"                                        \
benoit@2587
   106
    "${src_dir}/configure"                                          \
benoit@2587
   107
        --prefix=/usr                                               \
benoit@2587
   108
        --cache-file="$(pwd)/config.cache"                          \
benoit@2587
   109
        --without-cvs                                               \
benoit@2587
   110
        --disable-profile                                           \
benoit@2587
   111
        --without-gd                                                \
benoit@2587
   112
        --disable-debug                                             \
benoit@2587
   113
        "${extra_config[@]}"
benoit@2587
   114
benoit@2587
   115
    CT_DoLog EXTRA "Building C library localedef"
benoit@2587
   116
    CT_DoExecLog ALL make ${JOBSFLAGS}
benoit@2587
   117
benoit@2587
   118
    # The target's endianness and uint32_t alignment should be passed as options
benoit@2587
   119
    # to localedef, but glibc's localedef does not support these options, which
benoit@2587
   120
    # means that the locale files generated here will be suitable for the target
benoit@2587
   121
    # only if it has the same endianness and uint32_t alignment as the host's.
benoit@2587
   122
benoit@2587
   123
    CT_DoLog EXTRA "Installing C library locales"
benoit@2587
   124
    CT_DoExecLog ALL make ${JOBSFLAGS}                              \
benoit@2587
   125
                          install_root="${CT_SYSROOT_DIR}"          \
benoit@2587
   126
                          localedata/install-locales
benoit@2587
   127
}