scripts/build/libc/glibc.sh
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Mon Jan 06 20:05:14 2014 +0100 (2014-01-06)
changeset 3275 eacd3115e674
parent 3251 ec603d1371b9
permissions -rw-r--r--
libc/glibc: fix downloading addons

Do to glibc what we did to eglibc in #dff359adf15c.

Only (very) old versions of glibc have other external addons,
and they are no longer meaningful.

But for consistency, do the change nonetheless.

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