1.1 --- a/scripts/build/libc/glibc-eglibc.sh-common Sat Jan 22 22:37:25 2011 +0100
1.2 +++ b/scripts/build/libc/glibc-eglibc.sh-common Sat Jan 22 22:35:02 2011 +0100
1.3 @@ -134,7 +134,7 @@
1.4 # We don't need to be conditional on wether the user did set different
1.5 # values, as they CT_LIBC_GLIBC_EXTRA_CONFIG is passed after extra_config
1.6
1.7 - extra_config+=("--enable-kernel=$(echo ${CT_LIBC_GLIBC_MIN_KERNEL} |sed -r -e 's/^([^.]+\.[^.]+\.[^.]+)(|\.[^.]+)$/\1/;')")
1.8 + extra_config+=("$(do_libc_min_kernel_config)")
1.9
1.10 case "${CT_THREADS}" in
1.11 nptl) extra_config+=("--with-__thread" "--with-tls");;
1.12 @@ -252,3 +252,37 @@
1.13 addons_list="${addons_list%%${sep}}"
1.14 echo "${addons_list##${sep}}"
1.15 }
1.16 +
1.17 +# Compute up the minimum supported Linux kernel version
1.18 +do_libc_min_kernel_config() {
1.19 + local min_kernel_config
1.20 +
1.21 + case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
1.22 + *--enable-kernel*) ;;
1.23 + *) if [ "${CT_LIBC_GLIBC_KERNEL_VERSION_AS_HEADERS}" = "y" ]; then
1.24 + # We can't rely on the kernel version from the configuration,
1.25 + # because it might not be available if the user uses pre-installed
1.26 + # headers. On the other hand, both method will have the kernel
1.27 + # version installed in "usr/include/linux/version.h" in the sys-root.
1.28 + # Parse that instead of having two code-paths.
1.29 + version_code_file="${CT_SYSROOT_DIR}/usr/include/linux/version.h"
1.30 + if [ ! -f "${version_code_file}" -o ! -r "${version_code_file}" ]; then
1.31 + CT_Abort "Linux version is unavailable in installed headers files"
1.32 + fi
1.33 + version_code="$( grep -E LINUX_VERSION_CODE "${version_code_file}" \
1.34 + |cut -d ' ' -f 3 \
1.35 + )"
1.36 + version=$(((version_code>>16)&0xFF))
1.37 + patchlevel=$(((version_code>>8)&0xFF))
1.38 + sublevel=$((version_code&0xFF))
1.39 + min_kernel_config="${version}.${patchlevel}.${sublevel}"
1.40 + elif [ "${CT_LIBC_GLIBC_KERNEL_VERSION_CHOSEN}" = "y" ]; then
1.41 + # Trim the fourth part of the linux version, keeping only the first three numbers
1.42 + min_kernel_config="$( echo "${CT_LIBC_GLIBC_MIN_KERNEL_VERSION}" \
1.43 + |sed -r -e 's/^([^.]+\.[^.]+\.[^.]+)(|\.[^.]+)$/\1/;')" \
1.44 + )"
1.45 + fi
1.46 + echo "--enable-kernel=${min_kernel_config}"
1.47 + ;;
1.48 + esac
1.49 +}