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 case "${addon}:${CT_LIBC_GLIBC_PORTS_EXTERNAL}" in
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
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"
58 # There is nothing to do for glibc check config
59 do_libc_check_config() {
63 # Extract the files required for the libc locales
65 do_libc_locales_extract() {
69 # Build and install the libc locales
71 local src_dir="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}"
75 mkdir -p "${CT_BUILD_DIR}/build-localedef"
76 cd "${CT_BUILD_DIR}/build-localedef"
78 CT_DoLog EXTRA "Configuring C library localedef"
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}")
85 CT_DoLog DEBUG "Extra config args passed: '${extra_config[*]}'"
87 glibc_cflags="-O2 -fno-stack-protector"
88 case "${CT_LIBC_ENABLE_FORTIFIED_BUILD}" in
90 *) glibc_cflags+=" -U_FORTIFY_SOURCE";;
93 # ./configure is misled by our tools override wrapper for bash
94 # so just tell it where the real bash is _on_the_target_!
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
106 # Configure with --prefix the way we want it on the target...
109 CFLAGS="${glibc_cflags}" \
110 "${src_dir}/configure" \
112 --cache-file="$(pwd)/config.cache" \
119 CT_DoLog EXTRA "Building C library localedef"
120 CT_DoExecLog ALL make ${JOBSFLAGS}
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.
127 CT_DoLog EXTRA "Installing C library locales"
128 CT_DoExecLog ALL make ${JOBSFLAGS} \
129 install_root="${CT_SYSROOT_DIR}" \
130 localedata/install-locales