scripts/build/libc/glibc.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Aug 02 18:26:53 2011 +0200 (2011-08-02)
changeset 2592 4908eb2b6f17
parent 2504 3fc114996b20
child 3041 b9f695c2f5b7
permissions -rw-r--r--
scripts/functions: cvs retrieval first tries the mirror for tarballs

The cvs download helper looks for the local tarballs dir to see if it
can find a pre-downloaded tarball, and if it does not find it, does
the actual fetch to upstream via cvs.

In the process, it does not even try to get a tarball from the local
mirror, which can be useful if the mirror has been pre-populated
manually (or with a previously downloaded tree).

Fake a tarball get with the standard tarball-download helper, but
without specifying any upstream URL, which makes the helper directly
try the LAN mirror.

Of course, if no mirror is specified, no URL wil be available, and
the standard cvs retrieval will kick in.

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