scripts/build/libc/eglibc.sh
author Daniel Zimmermann <netzimme@gmail.com>
Sat Nov 16 16:16:51 2013 +0100 (2013-11-16)
changeset 3251 ec603d1371b9
parent 3162 e51eb0a614c7
child 3270 dff359adf15c
permissions -rw-r--r--
libc/{glibc,eglibc}: Don't download glibc-ports when not available

Don't download glibc-ports when glibc or eglibc version greater than 2.16,
because the "ports" source is mainline in the glibc or eglibc since version 2.17.

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