scripts/build/libc/eglibc.sh
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Fri Jan 03 17:10:09 2014 +0100 (2014-01-03)
changeset 3270 dff359adf15c
parent 3251 ec603d1371b9
permissions -rw-r--r--
libc/eglibc: fix downloading of localedef addon

For the versions of eglibc where the ports addon is not external (ie,
all versions after, and including 2.17), we would fail to download the
localedef addon, since the test did not care about the addon we were
about to download, only whether the ports addon was external or not.

Fix that by skipping the ports addon only if that's the addon we're
trying to download.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
yann@850
     1
# eglibc build functions (initially by Thomas JOURDAN).
yann@850
     2
yann@2270
     3
# Add the definitions common to glibc and eglibc
yann@2483
     4
#   do_libc_extract
yann@2270
     5
#   do_libc_start_files
yann@2270
     6
#   do_libc
yann@2270
     7
#   do_libc_add_ons_list
yann@2483
     8
#   do_libc_min_kernel_config
yann@2270
     9
. "${CT_LIB_DIR}/scripts/build/libc/glibc-eglibc.sh-common"
yann@2270
    10
yann@2495
    11
# Download glibc
yann@2495
    12
# eglibc is only available through subversion, there are no
yann@2495
    13
# snapshots available.
yann@2495
    14
do_libc_get() {
yann@2495
    15
    local addon
benoit@2586
    16
    local -a extra_addons
bryanhundven@2520
    17
    local svn_base
bryanhundven@2520
    18
bryanhundven@2520
    19
    if [ "${CT_EGLIBC_HTTP}" = "y" ]; then
bryanhundven@2520
    20
        svn_base="http://www.eglibc.org/svn"
bryanhundven@2520
    21
    else
bryanhundven@2520
    22
        svn_base="svn://svn.eglibc.org"
bryanhundven@2520
    23
    fi
yann@850
    24
yann@850
    25
    case "${CT_LIBC_VERSION}" in
yann@2495
    26
        trunk)  svn_base+="/trunk";;
yann@2495
    27
        *)      svn_base+="/branches/eglibc-${CT_LIBC_VERSION}";;
yann@850
    28
    esac
yann@850
    29
yann@2495
    30
    CT_GetSVN "eglibc-${CT_LIBC_VERSION}"   \
yann@2495
    31
              "${svn_base}/libc"            \
yann@2495
    32
              "${CT_EGLIBC_REVISION:-HEAD}"
yann@850
    33
benoit@2586
    34
    if [ "${CT_LIBC_LOCALES}" = "y" ]; then
benoit@2586
    35
        extra_addons+=("localedef")
benoit@2586
    36
    fi
benoit@2586
    37
benoit@2586
    38
    for addon in $(do_libc_add_ons_list " ") "${extra_addons[@]}"; do
yann@2504
    39
        # Never ever try to download these add-ons,
yann@2504
    40
        # they've always been internal
yann@2504
    41
        case "${addon}" in
yann@2504
    42
            nptl)   continue;;
yann@2504
    43
        esac
yann@2504
    44
yann@3270
    45
        case "${addon}:${CT_LIBC_GLIBC_PORTS_EXTERNAL}" in
yann@3270
    46
            ports:y)    ;;
yann@3270
    47
            ports:*)    continue;;
netzimme@3251
    48
        esac
netzimme@3251
    49
yann@2496
    50
        if ! CT_GetSVN "eglibc-${addon}-${CT_LIBC_VERSION}" \
yann@2496
    51
                       "${svn_base}/${addon}"               \
yann@2496
    52
                       "${CT_EGLIBC_REVISION:-HEAD}"
yann@2496
    53
        then
yann@2496
    54
            # Some add-ons are bundled with the main sources
yann@2496
    55
            # so failure to download them is expected
yann@2496
    56
            CT_DoLog DEBUG "Addon '${addon}' could not be downloaded."
yann@2496
    57
            CT_DoLog DEBUG "We'll see later if we can find it in the source tree"
yann@2496
    58
        fi
yann@850
    59
    done
yann@850
    60
}
yann@850
    61
avrac@1569
    62
# Copy user provided eglibc configuration file if provided
yann@850
    63
do_libc_check_config() {
avrac@1569
    64
    if [ "${CT_EGLIBC_CUSTOM_CONFIG}" != "y" ]; then
avrac@1569
    65
        return 0
avrac@1569
    66
    fi
avrac@1569
    67
avrac@1569
    68
    CT_DoStep INFO "Checking C library configuration"
avrac@1569
    69
avrac@1569
    70
    CT_TestOrAbort "You did not provide an eglibc config file!" \
avrac@1569
    71
        -n "${CT_EGLIBC_OPTION_GROUPS_FILE}" -a \
avrac@1569
    72
        -f "${CT_EGLIBC_OPTION_GROUPS_FILE}"
avrac@1569
    73
avrac@1569
    74
    CT_DoExecLog ALL cp "${CT_EGLIBC_OPTION_GROUPS_FILE}" "${CT_CONFIG_DIR}/eglibc.config"
avrac@1569
    75
avrac@1569
    76
    # NSS configuration
avrac@1569
    77
    if grep -E '^OPTION_EGLIBC_NSSWITCH[[:space:]]*=[[:space:]]*n' "${CT_EGLIBC_OPTION_GROUPS_FILE}" >/dev/null 2>&1; then
avrac@1569
    78
        CT_DoLog DEBUG "Using fixed-configuration nsswitch facility"
avrac@1569
    79
avrac@1569
    80
        if [ "${CT_EGLIBC_BUNDLED_NSS_CONFIG}" = "y" ]; then
avrac@1569
    81
            nss_config="${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}/nss/fixed-nsswitch.conf"
avrac@1569
    82
        else
avrac@1569
    83
            nss_config="${CT_EGLIBC_NSS_CONFIG_FILE}"
avrac@1569
    84
        fi
avrac@1569
    85
        CT_TestOrAbort "NSS config file not found!" -n "${nss_config}" -a -f "${nss_config}"
avrac@1569
    86
avrac@1569
    87
        CT_DoExecLog ALL cp "${nss_config}" "${CT_CONFIG_DIR}/nsswitch.config"
avrac@1569
    88
        echo "OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG = ${CT_CONFIG_DIR}/nsswitch.config" \
avrac@1569
    89
            >> "${CT_CONFIG_DIR}/eglibc.config"
avrac@1569
    90
avrac@1569
    91
        if [ "${CT_EGLIBC_BUNDLED_NSS_FUNCTIONS}" = "y" ]; then
avrac@1569
    92
            nss_functions="${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}/nss/fixed-nsswitch.functions"
avrac@1569
    93
        else
avrac@1569
    94
            nss_functions="${CT_EGLIBC_NSS_FUNCTIONS_FILE}"
avrac@1569
    95
        fi
avrac@1569
    96
        CT_TestOrAbort "NSS functions file not found!" -n "${nss_functions}" -a -f "${nss_functions}"
avrac@1569
    97
avrac@1569
    98
        CT_DoExecLog ALL cp "${nss_functions}" "${CT_CONFIG_DIR}/nsswitch.functions"
avrac@1569
    99
        echo "OPTION_EGLIBC_NSSWITCH_FIXED_FUNCTIONS = ${CT_CONFIG_DIR}/nsswitch.functions" \
avrac@1569
   100
            >> "${CT_CONFIG_DIR}/eglibc.config"
avrac@1569
   101
    else
avrac@1569
   102
        CT_DoLog DEBUG "Using full-blown nsswitch facility"
avrac@1569
   103
    fi
avrac@1569
   104
avrac@1569
   105
    CT_EndStep
yann@850
   106
}
benoit@2586
   107
benoit@2586
   108
# Extract the files required for the libc locales
benoit@2586
   109
do_libc_locales_extract() {
benoit@2586
   110
    CT_Extract "eglibc-localedef-${CT_LIBC_VERSION}"
benoit@2586
   111
    CT_Patch "eglibc" "localedef-${CT_LIBC_VERSION}"
benoit@2586
   112
}
benoit@2586
   113
benoit@2586
   114
# Build and install the libc locales
benoit@2586
   115
do_libc_locales() {
benoit@2586
   116
    local libc_src_dir="${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}"
benoit@2586
   117
    local src_dir="${CT_SRC_DIR}/eglibc-localedef-${CT_LIBC_VERSION}"
benoit@2586
   118
    local -a extra_config
benoit@2586
   119
    local -a localedef_opts
benoit@2586
   120
benoit@2586
   121
    mkdir -p "${CT_BUILD_DIR}/build-localedef"
benoit@2586
   122
    cd "${CT_BUILD_DIR}/build-localedef"
benoit@2586
   123
benoit@2586
   124
    CT_DoLog EXTRA "Configuring C library localedef"
benoit@2586
   125
benoit@2586
   126
    if [ "${CT_LIBC_EGLIBC_HAS_PKGVERSION_BUGURL}" = "y" ]; then
benoit@2586
   127
        extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
benoit@2586
   128
        [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
benoit@2586
   129
    fi
benoit@2586
   130
benoit@2586
   131
    CT_DoLog DEBUG "Extra config args passed: '${extra_config[*]}'"
benoit@2586
   132
benoit@2586
   133
    # ./configure is misled by our tools override wrapper for bash
benoit@2586
   134
    # so just tell it where the real bash is _on_the_target_!
benoit@2586
   135
    # Notes:
benoit@2586
   136
    # - ${ac_cv_path_BASH_SHELL} is only used to set BASH_SHELL
benoit@2586
   137
    # - ${BASH_SHELL}            is only used to set BASH
benoit@2586
   138
    # - ${BASH}                  is only used to set the shebang
benoit@2586
   139
    #                            in two scripts to run on the target
benoit@2586
   140
    # So we can safely bypass bash detection at compile time.
benoit@2586
   141
    # Should this change in a future eglibc release, we'd better
benoit@2586
   142
    # directly mangle the generated scripts _after_ they get built,
yann@3041
   143
    # or even after they get installed...
benoit@2586
   144
    echo "ac_cv_path_BASH_SHELL=/bin/bash" >>config.cache
benoit@2586
   145
benoit@2586
   146
    # Configure with --prefix the way we want it on the target...
benoit@2586
   147
benoit@2586
   148
    CT_DoExecLog CFG                                                \
benoit@2809
   149
    CPPFLAGS="-DNOT_IN_libc"                                        \
benoit@2586
   150
    "${src_dir}/configure"                                          \
benoit@2586
   151
        --prefix=/usr                                               \
benoit@2586
   152
        --cache-file="$(pwd)/config.cache"                          \
benoit@2586
   153
        --with-glibc="${libc_src_dir}"                              \
benoit@2586
   154
        "${extra_config[@]}"
benoit@2586
   155
benoit@2586
   156
    CT_DoLog EXTRA "Building C library localedef"
benoit@2586
   157
    CT_DoExecLog ALL make ${JOBSFLAGS}
benoit@2586
   158
benoit@2586
   159
    # Set the localedef endianness option
yann@2776
   160
    case "${CT_ARCH_ENDIAN}" in
yann@2776
   161
        big)    localedef_opts+=(--big-endian);;
yann@2776
   162
        little) localedef_opts+=(--little-endian);;
benoit@2586
   163
    esac
benoit@2586
   164
benoit@2586
   165
    # Set the localedef option for the target's uint32_t alignment in bytes.
benoit@2586
   166
    # This is target-specific, but for now, 32-bit alignment should work for all
benoit@2586
   167
    # supported targets, even 64-bit ones.
benoit@2586
   168
    localedef_opts+=(--uint32-align=4)
benoit@2586
   169
benoit@2586
   170
    CT_DoLog EXTRA "Installing C library locales"
benoit@2586
   171
    CT_DoExecLog ALL make ${JOBSFLAGS}                              \
benoit@2586
   172
                          "LOCALEDEF_OPTS=${localedef_opts[*]}"     \
benoit@2586
   173
                          install_root="${CT_SYSROOT_DIR}"          \
benoit@2586
   174
                          install-locales
benoit@2586
   175
}