scripts/build/libc/eglibc.sh
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Sun May 05 00:01:05 2013 +0200 (2013-05-05)
changeset 3218 3709e61ad85b
parent 3041 b9f695c2f5b7
child 3251 ec603d1371b9
permissions -rw-r--r--
complibs/cloog: add support for the ISL backend

CLooG 0.18+ will use ISL instead of PPL, so we have to configure
adequately depending of which backend is in use.

The Kconfig entries will decide for us which is selected, so we
can rely on either PPL xor ISL to be selected, not both.

Reported-by: "Plotnikov Dmitry" <leitz@ispras.ru>
[Dmitry did a preliminray patch to add ISL support,
which this patch is inspired from]
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@2496
    45
        if ! CT_GetSVN "eglibc-${addon}-${CT_LIBC_VERSION}" \
yann@2496
    46
                       "${svn_base}/${addon}"               \
yann@2496
    47
                       "${CT_EGLIBC_REVISION:-HEAD}"
yann@2496
    48
        then
yann@2496
    49
            # Some add-ons are bundled with the main sources
yann@2496
    50
            # so failure to download them is expected
yann@2496
    51
            CT_DoLog DEBUG "Addon '${addon}' could not be downloaded."
yann@2496
    52
            CT_DoLog DEBUG "We'll see later if we can find it in the source tree"
yann@2496
    53
        fi
yann@850
    54
    done
yann@850
    55
}
yann@850
    56
avrac@1569
    57
# Copy user provided eglibc configuration file if provided
yann@850
    58
do_libc_check_config() {
avrac@1569
    59
    if [ "${CT_EGLIBC_CUSTOM_CONFIG}" != "y" ]; then
avrac@1569
    60
        return 0
avrac@1569
    61
    fi
avrac@1569
    62
avrac@1569
    63
    CT_DoStep INFO "Checking C library configuration"
avrac@1569
    64
avrac@1569
    65
    CT_TestOrAbort "You did not provide an eglibc config file!" \
avrac@1569
    66
        -n "${CT_EGLIBC_OPTION_GROUPS_FILE}" -a \
avrac@1569
    67
        -f "${CT_EGLIBC_OPTION_GROUPS_FILE}"
avrac@1569
    68
avrac@1569
    69
    CT_DoExecLog ALL cp "${CT_EGLIBC_OPTION_GROUPS_FILE}" "${CT_CONFIG_DIR}/eglibc.config"
avrac@1569
    70
avrac@1569
    71
    # NSS configuration
avrac@1569
    72
    if grep -E '^OPTION_EGLIBC_NSSWITCH[[:space:]]*=[[:space:]]*n' "${CT_EGLIBC_OPTION_GROUPS_FILE}" >/dev/null 2>&1; then
avrac@1569
    73
        CT_DoLog DEBUG "Using fixed-configuration nsswitch facility"
avrac@1569
    74
avrac@1569
    75
        if [ "${CT_EGLIBC_BUNDLED_NSS_CONFIG}" = "y" ]; then
avrac@1569
    76
            nss_config="${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}/nss/fixed-nsswitch.conf"
avrac@1569
    77
        else
avrac@1569
    78
            nss_config="${CT_EGLIBC_NSS_CONFIG_FILE}"
avrac@1569
    79
        fi
avrac@1569
    80
        CT_TestOrAbort "NSS config file not found!" -n "${nss_config}" -a -f "${nss_config}"
avrac@1569
    81
avrac@1569
    82
        CT_DoExecLog ALL cp "${nss_config}" "${CT_CONFIG_DIR}/nsswitch.config"
avrac@1569
    83
        echo "OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG = ${CT_CONFIG_DIR}/nsswitch.config" \
avrac@1569
    84
            >> "${CT_CONFIG_DIR}/eglibc.config"
avrac@1569
    85
avrac@1569
    86
        if [ "${CT_EGLIBC_BUNDLED_NSS_FUNCTIONS}" = "y" ]; then
avrac@1569
    87
            nss_functions="${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}/nss/fixed-nsswitch.functions"
avrac@1569
    88
        else
avrac@1569
    89
            nss_functions="${CT_EGLIBC_NSS_FUNCTIONS_FILE}"
avrac@1569
    90
        fi
avrac@1569
    91
        CT_TestOrAbort "NSS functions file not found!" -n "${nss_functions}" -a -f "${nss_functions}"
avrac@1569
    92
avrac@1569
    93
        CT_DoExecLog ALL cp "${nss_functions}" "${CT_CONFIG_DIR}/nsswitch.functions"
avrac@1569
    94
        echo "OPTION_EGLIBC_NSSWITCH_FIXED_FUNCTIONS = ${CT_CONFIG_DIR}/nsswitch.functions" \
avrac@1569
    95
            >> "${CT_CONFIG_DIR}/eglibc.config"
avrac@1569
    96
    else
avrac@1569
    97
        CT_DoLog DEBUG "Using full-blown nsswitch facility"
avrac@1569
    98
    fi
avrac@1569
    99
avrac@1569
   100
    CT_EndStep
yann@850
   101
}
benoit@2586
   102
benoit@2586
   103
# Extract the files required for the libc locales
benoit@2586
   104
do_libc_locales_extract() {
benoit@2586
   105
    CT_Extract "eglibc-localedef-${CT_LIBC_VERSION}"
benoit@2586
   106
    CT_Patch "eglibc" "localedef-${CT_LIBC_VERSION}"
benoit@2586
   107
}
benoit@2586
   108
benoit@2586
   109
# Build and install the libc locales
benoit@2586
   110
do_libc_locales() {
benoit@2586
   111
    local libc_src_dir="${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}"
benoit@2586
   112
    local src_dir="${CT_SRC_DIR}/eglibc-localedef-${CT_LIBC_VERSION}"
benoit@2586
   113
    local -a extra_config
benoit@2586
   114
    local -a localedef_opts
benoit@2586
   115
benoit@2586
   116
    mkdir -p "${CT_BUILD_DIR}/build-localedef"
benoit@2586
   117
    cd "${CT_BUILD_DIR}/build-localedef"
benoit@2586
   118
benoit@2586
   119
    CT_DoLog EXTRA "Configuring C library localedef"
benoit@2586
   120
benoit@2586
   121
    if [ "${CT_LIBC_EGLIBC_HAS_PKGVERSION_BUGURL}" = "y" ]; then
benoit@2586
   122
        extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
benoit@2586
   123
        [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
benoit@2586
   124
    fi
benoit@2586
   125
benoit@2586
   126
    CT_DoLog DEBUG "Extra config args passed: '${extra_config[*]}'"
benoit@2586
   127
benoit@2586
   128
    # ./configure is misled by our tools override wrapper for bash
benoit@2586
   129
    # so just tell it where the real bash is _on_the_target_!
benoit@2586
   130
    # Notes:
benoit@2586
   131
    # - ${ac_cv_path_BASH_SHELL} is only used to set BASH_SHELL
benoit@2586
   132
    # - ${BASH_SHELL}            is only used to set BASH
benoit@2586
   133
    # - ${BASH}                  is only used to set the shebang
benoit@2586
   134
    #                            in two scripts to run on the target
benoit@2586
   135
    # So we can safely bypass bash detection at compile time.
benoit@2586
   136
    # Should this change in a future eglibc release, we'd better
benoit@2586
   137
    # directly mangle the generated scripts _after_ they get built,
yann@3041
   138
    # or even after they get installed...
benoit@2586
   139
    echo "ac_cv_path_BASH_SHELL=/bin/bash" >>config.cache
benoit@2586
   140
benoit@2586
   141
    # Configure with --prefix the way we want it on the target...
benoit@2586
   142
benoit@2586
   143
    CT_DoExecLog CFG                                                \
benoit@2809
   144
    CPPFLAGS="-DNOT_IN_libc"                                        \
benoit@2586
   145
    "${src_dir}/configure"                                          \
benoit@2586
   146
        --prefix=/usr                                               \
benoit@2586
   147
        --cache-file="$(pwd)/config.cache"                          \
benoit@2586
   148
        --with-glibc="${libc_src_dir}"                              \
benoit@2586
   149
        "${extra_config[@]}"
benoit@2586
   150
benoit@2586
   151
    CT_DoLog EXTRA "Building C library localedef"
benoit@2586
   152
    CT_DoExecLog ALL make ${JOBSFLAGS}
benoit@2586
   153
benoit@2586
   154
    # Set the localedef endianness option
yann@2776
   155
    case "${CT_ARCH_ENDIAN}" in
yann@2776
   156
        big)    localedef_opts+=(--big-endian);;
yann@2776
   157
        little) localedef_opts+=(--little-endian);;
benoit@2586
   158
    esac
benoit@2586
   159
benoit@2586
   160
    # Set the localedef option for the target's uint32_t alignment in bytes.
benoit@2586
   161
    # This is target-specific, but for now, 32-bit alignment should work for all
benoit@2586
   162
    # supported targets, even 64-bit ones.
benoit@2586
   163
    localedef_opts+=(--uint32-align=4)
benoit@2586
   164
benoit@2586
   165
    CT_DoLog EXTRA "Installing C library locales"
benoit@2586
   166
    CT_DoExecLog ALL make ${JOBSFLAGS}                              \
benoit@2586
   167
                          "LOCALEDEF_OPTS=${localedef_opts[*]}"     \
benoit@2586
   168
                          install_root="${CT_SYSROOT_DIR}"          \
benoit@2586
   169
                          install-locales
benoit@2586
   170
}