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
5 # Add the definitions common to glibc and eglibc
10 # do_libc_min_kernel_config
11 . "${CT_LIB_DIR}/scripts/build/libc/glibc-eglibc.sh-common"
19 addons_list=($(do_libc_add_ons_list " "))
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
28 for addon in "${addons_list[@]}"; do
29 # Never ever try to download these add-ons,
30 # they've always been internal
35 if ! CT_GetFile "glibc-${addon}-${CT_LIBC_VERSION}" \
36 {ftp,http}://ftp.gnu.org/gnu/glibc \
37 ftp://gcc.gnu.org/pub/glibc/releases \
38 ftp://gcc.gnu.org/pub/glibc/snapshots
40 # Some add-ons are bundled with glibc, others are
41 # bundled in their own tarball. Eg. NPTL is internal,
42 # while LinuxThreads was external. Also, for old
43 # versions of glibc, the libidn add-on was external,
44 # but with version >=2.10, it is internal.
45 CT_DoLog DEBUG "Addon '${addon}' could not be downloaded."
46 CT_DoLog DEBUG "We'll see later if we can find it in the source tree"
53 # There is nothing to do for glibc check config
54 do_libc_check_config() {
58 # Extract the files required for the libc locales
60 do_libc_locales_extract() {
64 # Build and install the libc locales
66 local src_dir="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}"
70 mkdir -p "${CT_BUILD_DIR}/build-localedef"
71 cd "${CT_BUILD_DIR}/build-localedef"
73 CT_DoLog EXTRA "Configuring C library localedef"
75 if [ "${CT_LIBC_EGLIBC_HAS_PKGVERSION_BUGURL}" = "y" ]; then
76 extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
77 [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
80 CT_DoLog DEBUG "Extra config args passed: '${extra_config[*]}'"
82 glibc_cflags="-O2 -fno-stack-protector"
83 case "${CT_LIBC_ENABLE_FORTIFIED_BUILD}" in
85 *) glibc_cflags+=" -U_FORTIFY_SOURCE";;
88 # ./configure is misled by our tools override wrapper for bash
89 # so just tell it where the real bash is _on_the_target_!
91 # - ${ac_cv_path_BASH_SHELL} is only used to set BASH_SHELL
92 # - ${BASH_SHELL} is only used to set BASH
93 # - ${BASH} is only used to set the shebang
94 # in two scripts to run on the target
95 # So we can safely bypass bash detection at compile time.
96 # Should this change in a future eglibc release, we'd better
97 # directly mangle the generated scripts _after_ they get built,
98 # or even after they get installed...
99 echo "ac_cv_path_BASH_SHELL=/bin/bash" >>config.cache
101 # Configure with --prefix the way we want it on the target...
104 CFLAGS="${glibc_cflags}" \
105 "${src_dir}/configure" \
107 --cache-file="$(pwd)/config.cache" \
114 CT_DoLog EXTRA "Building C library localedef"
115 CT_DoExecLog ALL make ${JOBSFLAGS}
117 # The target's endianness and uint32_t alignment should be passed as options
118 # to localedef, but glibc's localedef does not support these options, which
119 # means that the locale files generated here will be suitable for the target
120 # only if it has the same endianness and uint32_t alignment as the host's.
122 CT_DoLog EXTRA "Installing C library locales"
123 CT_DoExecLog ALL make ${JOBSFLAGS} \
124 install_root="${CT_SYSROOT_DIR}" \
125 localedata/install-locales