libc/glibc: add partial support for locales
author"Benoît THÉBAUDEAU" <benoit.thebaudeau@advansee.com>
Fri Jul 29 15:30:53 2011 +0200 (2011-07-29)
changeset 25877727970d04e9
parent 2586 4f9efd2c6627
child 2588 99532252143d
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>
config/libc/glibc-eglibc.in-common
scripts/build/libc/glibc.sh
     1.1 --- a/config/libc/glibc-eglibc.in-common	Fri Jul 29 14:42:20 2011 +0200
     1.2 +++ b/config/libc/glibc-eglibc.in-common	Fri Jul 29 15:30:53 2011 +0200
     1.3 @@ -151,6 +151,15 @@
     1.4        Whether to build and install the libc locale files for the target,
     1.5        which is required in order to support internationalization.
     1.6  
     1.7 +if LIBC_glibc && LIBC_LOCALES
     1.8 +comment "WARNING!                                                     "
     1.9 +comment "|  The built locales will be usable if and only if the build  "
    1.10 +comment "|  machine and the target:                                    "
    1.11 +comment "|   - have the same endianness,                               "
    1.12 +comment "|   - and have the same alignment requirements for uint32_t.  "
    1.13 +comment "|  You will have to check by yourself (for now).              "
    1.14 +endif # LIBC_glibc && LIBC_LOCALES
    1.15 +
    1.16  if KERNEL_linux
    1.17  
    1.18  choice LIBC_GLIBC_SUPPORTED_KERNEL
     2.1 --- a/scripts/build/libc/glibc.sh	Fri Jul 29 14:42:20 2011 +0200
     2.2 +++ b/scripts/build/libc/glibc.sh	Fri Jul 29 15:30:53 2011 +0200
     2.3 @@ -55,3 +55,73 @@
     2.4  do_libc_check_config() {
     2.5      :
     2.6  }
     2.7 +
     2.8 +# Extract the files required for the libc locales
     2.9 +# Nothing to do
    2.10 +do_libc_locales_extract() {
    2.11 +    :
    2.12 +}
    2.13 +
    2.14 +# Build and install the libc locales
    2.15 +do_libc_locales() {
    2.16 +    local src_dir="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}"
    2.17 +    local -a extra_config
    2.18 +    local glibc_cflags
    2.19 +
    2.20 +    mkdir -p "${CT_BUILD_DIR}/build-localedef"
    2.21 +    cd "${CT_BUILD_DIR}/build-localedef"
    2.22 +
    2.23 +    CT_DoLog EXTRA "Configuring C library localedef"
    2.24 +
    2.25 +    if [ "${CT_LIBC_EGLIBC_HAS_PKGVERSION_BUGURL}" = "y" ]; then
    2.26 +        extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
    2.27 +        [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
    2.28 +    fi
    2.29 +
    2.30 +    CT_DoLog DEBUG "Extra config args passed: '${extra_config[*]}'"
    2.31 +
    2.32 +    glibc_cflags="-O2 -fno-stack-protector"
    2.33 +    case "${CT_LIBC_ENABLE_FORTIFIED_BUILD}" in
    2.34 +        y)  ;;
    2.35 +        *)  glibc_cflags+=" -U_FORTIFY_SOURCE";;
    2.36 +    esac
    2.37 +
    2.38 +    # ./configure is misled by our tools override wrapper for bash
    2.39 +    # so just tell it where the real bash is _on_the_target_!
    2.40 +    # Notes:
    2.41 +    # - ${ac_cv_path_BASH_SHELL} is only used to set BASH_SHELL
    2.42 +    # - ${BASH_SHELL}            is only used to set BASH
    2.43 +    # - ${BASH}                  is only used to set the shebang
    2.44 +    #                            in two scripts to run on the target
    2.45 +    # So we can safely bypass bash detection at compile time.
    2.46 +    # Should this change in a future eglibc release, we'd better
    2.47 +    # directly mangle the generated scripts _after_ they get built,
    2.48 +    # or even after they get installed... eglibc is such a sucker...
    2.49 +    echo "ac_cv_path_BASH_SHELL=/bin/bash" >>config.cache
    2.50 +
    2.51 +    # Configure with --prefix the way we want it on the target...
    2.52 +
    2.53 +    CT_DoExecLog CFG                                                \
    2.54 +    CFLAGS="${glibc_cflags}"                                        \
    2.55 +    "${src_dir}/configure"                                          \
    2.56 +        --prefix=/usr                                               \
    2.57 +        --cache-file="$(pwd)/config.cache"                          \
    2.58 +        --without-cvs                                               \
    2.59 +        --disable-profile                                           \
    2.60 +        --without-gd                                                \
    2.61 +        --disable-debug                                             \
    2.62 +        "${extra_config[@]}"
    2.63 +
    2.64 +    CT_DoLog EXTRA "Building C library localedef"
    2.65 +    CT_DoExecLog ALL make ${JOBSFLAGS}
    2.66 +
    2.67 +    # The target's endianness and uint32_t alignment should be passed as options
    2.68 +    # to localedef, but glibc's localedef does not support these options, which
    2.69 +    # means that the locale files generated here will be suitable for the target
    2.70 +    # only if it has the same endianness and uint32_t alignment as the host's.
    2.71 +
    2.72 +    CT_DoLog EXTRA "Installing C library locales"
    2.73 +    CT_DoExecLog ALL make ${JOBSFLAGS}                              \
    2.74 +                          install_root="${CT_SYSROOT_DIR}"          \
    2.75 +                          localedata/install-locales
    2.76 +}