scripts/build/libc/glibc.sh
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Mon Jan 06 20:05:14 2014 +0100 (2014-01-06)
changeset 3275 eacd3115e674
parent 3251 ec603d1371b9
permissions -rw-r--r--
libc/glibc: fix downloading addons

Do to glibc what we did to eglibc in #dff359adf15c.

Only (very) old versions of glibc have other external addons,
and they are no longer meaningful.

But for consistency, do the change nonetheless.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
     1 # This file adds functions to build glibc
     2 # Copyright 2007 Yann E. MORIN
     3 # Licensed under the GPL v2. See COPYING in the root of this package
     4 
     5 # Add the definitions common to glibc and eglibc
     6 #   do_libc_extract
     7 #   do_libc_start_files
     8 #   do_libc
     9 #   do_libc_add_ons_list
    10 #   do_libc_min_kernel_config
    11 . "${CT_LIB_DIR}/scripts/build/libc/glibc-eglibc.sh-common"
    12 
    13 # Download glibc
    14 do_libc_get() {
    15     local date
    16     local version
    17     local -a addons_list
    18 
    19     addons_list=($(do_libc_add_ons_list " "))
    20 
    21     # Main source
    22     CT_GetFile "glibc-${CT_LIBC_VERSION}"               \
    23                {ftp,http}://ftp.gnu.org/gnu/glibc       \
    24                ftp://gcc.gnu.org/pub/glibc/releases     \
    25                ftp://gcc.gnu.org/pub/glibc/snapshots
    26 
    27     # C library addons
    28     for addon in "${addons_list[@]}"; do
    29         # Never ever try to download these add-ons,
    30         # they've always been internal
    31         case "${addon}" in
    32             nptl)   continue;;
    33         esac
    34 
    35         case "${addon}:${CT_LIBC_GLIBC_PORTS_EXTERNAL}" in
    36             ports:y)    ;;
    37             ports:*)    continue;;
    38         esac
    39 
    40         if ! CT_GetFile "glibc-${addon}-${CT_LIBC_VERSION}"     \
    41                         {ftp,http}://ftp.gnu.org/gnu/glibc      \
    42                         ftp://gcc.gnu.org/pub/glibc/releases    \
    43                         ftp://gcc.gnu.org/pub/glibc/snapshots
    44         then
    45             # Some add-ons are bundled with glibc, others are
    46             # bundled in their own tarball. Eg. NPTL is internal,
    47             # while LinuxThreads was external. Also, for old
    48             # versions of glibc, the libidn add-on was external,
    49             # but with version >=2.10, it is internal.
    50             CT_DoLog DEBUG "Addon '${addon}' could not be downloaded."
    51             CT_DoLog DEBUG "We'll see later if we can find it in the source tree"
    52         fi
    53     done
    54 
    55     return 0
    56 }
    57 
    58 # There is nothing to do for glibc check config
    59 do_libc_check_config() {
    60     :
    61 }
    62 
    63 # Extract the files required for the libc locales
    64 # Nothing to do
    65 do_libc_locales_extract() {
    66     :
    67 }
    68 
    69 # Build and install the libc locales
    70 do_libc_locales() {
    71     local src_dir="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}"
    72     local -a extra_config
    73     local glibc_cflags
    74 
    75     mkdir -p "${CT_BUILD_DIR}/build-localedef"
    76     cd "${CT_BUILD_DIR}/build-localedef"
    77 
    78     CT_DoLog EXTRA "Configuring C library localedef"
    79 
    80     if [ "${CT_LIBC_EGLIBC_HAS_PKGVERSION_BUGURL}" = "y" ]; then
    81         extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
    82         [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
    83     fi
    84 
    85     CT_DoLog DEBUG "Extra config args passed: '${extra_config[*]}'"
    86 
    87     glibc_cflags="-O2 -fno-stack-protector"
    88     case "${CT_LIBC_ENABLE_FORTIFIED_BUILD}" in
    89         y)  ;;
    90         *)  glibc_cflags+=" -U_FORTIFY_SOURCE";;
    91     esac
    92 
    93     # ./configure is misled by our tools override wrapper for bash
    94     # so just tell it where the real bash is _on_the_target_!
    95     # Notes:
    96     # - ${ac_cv_path_BASH_SHELL} is only used to set BASH_SHELL
    97     # - ${BASH_SHELL}            is only used to set BASH
    98     # - ${BASH}                  is only used to set the shebang
    99     #                            in two scripts to run on the target
   100     # So we can safely bypass bash detection at compile time.
   101     # Should this change in a future eglibc release, we'd better
   102     # directly mangle the generated scripts _after_ they get built,
   103     # or even after they get installed...
   104     echo "ac_cv_path_BASH_SHELL=/bin/bash" >>config.cache
   105 
   106     # Configure with --prefix the way we want it on the target...
   107 
   108     CT_DoExecLog CFG                                                \
   109     CFLAGS="${glibc_cflags}"                                        \
   110     "${src_dir}/configure"                                          \
   111         --prefix=/usr                                               \
   112         --cache-file="$(pwd)/config.cache"                          \
   113         --without-cvs                                               \
   114         --disable-profile                                           \
   115         --without-gd                                                \
   116         --disable-debug                                             \
   117         "${extra_config[@]}"
   118 
   119     CT_DoLog EXTRA "Building C library localedef"
   120     CT_DoExecLog ALL make ${JOBSFLAGS}
   121 
   122     # The target's endianness and uint32_t alignment should be passed as options
   123     # to localedef, but glibc's localedef does not support these options, which
   124     # means that the locale files generated here will be suitable for the target
   125     # only if it has the same endianness and uint32_t alignment as the host's.
   126 
   127     CT_DoLog EXTRA "Installing C library locales"
   128     CT_DoExecLog ALL make ${JOBSFLAGS}                              \
   129                           install_root="${CT_SYSROOT_DIR}"          \
   130                           localedata/install-locales
   131 }