scripts/build/libc/glibc.sh
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Mon Feb 25 21:19:31 2013 +0100 (2013-02-25)
changeset 3185 f89f8e6f8766
parent 3041 b9f695c2f5b7
child 3251 ec603d1371b9
permissions -rw-r--r--
Makefile: fix parrallel (-j) installs

Currently, we would remove previously installed patches before
installing the new ones. Unfortunately, that does not play well
with heavily parallel installs.

Now, we consider it is the responsibility of the user to first
uninstall any previous version before installing a new one.

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