scripts/build/libc/eglibc.sh
author "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
Mon Apr 16 15:25:36 2012 +0200 (2012-04-16)
changeset 2941 13e40098fffc
parent 2776 5f557056c530
child 3041 b9f695c2f5b7
permissions -rw-r--r--
cc/gcc: update Linaro GCC revisions to 2012.04

Update Linaro GCC with the latest available revisions.

The 4.7 revision is also released, but the infrastructure is not yet ready for
it in CT-NG.

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