From patchwork Fri Jul 4 03:40:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roland McGrath X-Patchwork-Id: 367014 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A564E140121 for ; Fri, 4 Jul 2014 13:42:25 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:content-type :content-transfer-encoding:from:to:subject:message-id:date; q= dns; s=default; b=yN5LLf1GpooN5Nth0nCcev8o2YHDFtigSaAOr+ZOmSCsLH nOqYqIWHEdha9LowOUjZZbUqgd3o/J1I0SzrryV391sf6772eAL4cIufR68cZySo qUxrMUVKmnZBg8KeEDE6+STYukaMlo9oGhTDfZOadLEzIPat1qL+0QmuytXj8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:content-type :content-transfer-encoding:from:to:subject:message-id:date; s= default; bh=Buu5yvXN6sj/1KoVg3w+ygU4q6E=; b=ASu4abr4ABekOuaHX1l2 lqUbB910T6/Peusj3cCyjaK4H8LoRIrmZmG1WBvZdJ62wO5vIknPImif0X7RrGf4 3OKKpHJX6gxZh2n3wN/ujxSjoEMejHMJF6Xg0ICmumIuf2oWsS1XfGjqiNw817pN moxOUEif/uRDCVtJtry1PSo= Received: (qmail 7648 invoked by alias); 4 Jul 2014 03:41:58 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 6604 invoked by uid 89); 4 Jul 2014 03:40:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: topped-with-meat.com MIME-Version: 1.0 From: Roland McGrath To: "GNU C. Library" Subject: [COMMITTED PATCH] Robustify Linux kernel headers configure checks Message-Id: <20140704034012.6BA6B2C3988@topped-with-meat.com> Date: Thu, 3 Jul 2014 20:40:12 -0700 (PDT) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=SvUDtp+0 c=1 sm=1 tr=0 a=WkljmVdYkabdwxfqvArNOQ==:117 a=14OXPxybAAAA:8 a=poyKbl3u2MsA:10 a=Z6MIti7PxpgA:10 a=kj9zAlcOel0A:10 a=hOe2yjtxAAAA:8 a=Mode5w9Hfi0ejAKisjsA:9 a=CjuIK1q_8ugA:10 Previously the configure check would happily pass when no kernel headers were findable at all. Thanks, Roland * sysdeps/unix/sysv/linux/configure.ac: Use AC_TRY_COMPILE rather than AC_EGREP_CPP for kernel header checks, so they only succeed if including actually works right. * sysdeps/unix/sysv/linux/configure: Regenerated. --- a/sysdeps/unix/sysv/linux/configure +++ b/sysdeps/unix/sysv/linux/configure @@ -37,137 +37,6 @@ if test -n "$sysheaders"; then CPPFLAGS="$CPPFLAGS $SYSINCLUDES" fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if ${ac_cv_path_GREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_GREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_GREP=$GREP -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if ${ac_cv_path_EGREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_EGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_EGREP=$EGREP -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking installed Linux kernel header files" >&5 $as_echo_n "checking installed Linux kernel header files... " >&6; } if ${libc_cv_linux2632+:} false; then : @@ -177,17 +46,22 @@ else /* end confdefs.h. */ #include #if !defined LINUX_VERSION_CODE || LINUX_VERSION_CODE < (2 *65536+ 6 *256+ 32) /* 2.6.32 */ -eat flaming death +# error kernel headers missing or too old #endif +int +main () +{ + + ; + return 0; +} _ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "eat flaming death" >/dev/null 2>&1; then : - libc_cv_linux2632='TOO OLD!' -else +if ac_fn_c_try_compile "$LINENO"; then : libc_cv_linux2632='2.6.32 or later' +else + libc_cv_linux2632='missing or too old!' fi -rm -f conftest* - +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_linux2632" >&5 $as_echo "$libc_cv_linux2632" >&6; } @@ -231,17 +105,22 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if LINUX_VERSION_CODE < $decnum -eat flaming death +# error kernel headers too old #endif +int +main () +{ + + ; + return 0; +} _ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "eat flaming death" >/dev/null 2>&1; then : - libc_minimum_kernel='too old!' -else +if ac_fn_c_try_compile "$LINENO"; then : libc_minimum_kernel=ok +else + libc_minimum_kernel='too old!' fi -rm -f conftest* - +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_minimum_kernel" >&5 $as_echo "$libc_minimum_kernel" >&6; } if test "$libc_minimum_kernel" = ok; then --- a/sysdeps/unix/sysv/linux/configure.ac +++ b/sysdeps/unix/sysv/linux/configure.ac @@ -8,14 +8,14 @@ if test -n "$sysheaders"; then fi define([libc_cv_linuxVER], [libc_cv_linux]patsubst(LIBC_LINUX_VERSION,[\.]))dnl AC_CACHE_CHECK(installed Linux kernel header files, libc_cv_linuxVER, [dnl -AC_EGREP_CPP([eat flaming death], [#include +AC_TRY_COMPILE([#include #if !defined LINUX_VERSION_CODE || LINUX_VERSION_CODE < ]dnl patsubst(LIBC_LINUX_VERSION,[^\([^.]*\)\.\([^.]*\)\.\([^.]*\)$],dnl [ (\1 *65536+ \2 *256+ \3) /* \1.\2.\3 */])[ -eat flaming death -#endif], - libc_cv_linuxVER='TOO OLD!', - libc_cv_linuxVER='LIBC_LINUX_VERSION or later')]) +# error kernel headers missing or too old +#endif], [], + [libc_cv_linuxVER='LIBC_LINUX_VERSION or later'], + [libc_cv_linuxVER='missing or too old!'])]) if test "$libc_cv_linuxVER" != 'LIBC_LINUX_VERSION or later'; then AC_MSG_ERROR([GNU libc requires kernel header files from Linux LIBC_LINUX_VERSION or later to be installed before configuring. @@ -52,10 +52,10 @@ changequote(,)dnl decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 65536 + \2 * 256 + \3)/'`; abinum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`; changequote([,])dnl -AC_EGREP_CPP([eat flaming death], [#include +AC_TRY_COMPILE([#include #if LINUX_VERSION_CODE < $decnum -eat flaming death -#endif], libc_minimum_kernel='too old!', libc_minimum_kernel=ok) +# error kernel headers too old +#endif], [], [libc_minimum_kernel=ok], [libc_minimum_kernel='too old!']) AC_MSG_RESULT($libc_minimum_kernel) if test "$libc_minimum_kernel" = ok; then AC_DEFINE_UNQUOTED(__LINUX_KERNEL_VERSION, $decnum)