Always use kbuild for all Linux kernel configure probes
authorAaron M. Ucko <ucko@debian.org>
Tue, 7 Jul 2009 00:41:49 +0000 (17:41 -0700)
committerDerrick Brashear <shadow@dementia.org>
Fri, 10 Jul 2009 14:33:46 +0000 (08:33 -0600)
Some Linux kernel probes for the existence of header files were done
with file existence checks (test -f).  This breaks if the kernel build
system is stacking multiple directories of headers together with
compile-time -I include path options, as is the case for the current
Debian Linux header packages.  Instead, always use kbuild to check
whether a kernel header is available.

Similarly, use AC_TRY_KBUILD instead of AC_TRY_COMPILE when checking
for an SELinux kernel, since AC_TRY_COMPILE doesn't call into kbuild
and won't get the correct kernel header paths.

This is part of the fix for Debian Bug#521745 and has been included in
the Debian package since 1.4.10+dfsg1-1.

Reviewed-on: http://gerrit.openafs.org/5
Verified-by: Russ Allbery <rra@stanford.edu>
Verified-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>

src/cf/linux-test3.m4

index 8c3b296..ba0aaa3 100644 (file)
@@ -1,12 +1,8 @@
 AC_DEFUN([LINUX_KERNEL_LINUX_SYSCALL_H],[
   AC_MSG_CHECKING(for linux/syscall.h in kernel)
-  if test -f "${LINUX_KERNEL_PATH}/include/linux/syscall.h"; then
-    ac_linux_syscall=yes
-    AC_MSG_RESULT($ac_linux_syscall)
-  else
-    ac_linux_syscall=no
-    AC_MSG_RESULT($ac_linux_syscall)
-  fi
+  AC_TRY_KBUILD([#include <linux/syscall.h>], [],
+    [ac_linux_syscall=yes], [ac_linux_syscall=no])
+  AC_MSG_RESULT($ac_linux_syscall)
 ])
 
 AC_DEFUN([LINUX_NEED_RHCONFIG],[
@@ -16,17 +12,16 @@ if test "x$enable_redhat_buildsys" = "xyes"; then
   AC_MSG_WARN(Configured to build from a Red Hat SPEC file)
 else
   AC_MSG_CHECKING(for redhat kernel configuration)
-  if test -f "${LINUX_KERNEL_PATH}/include/linux/rhconfig.h"; then
-    ac_linux_rhconfig=yes
+  AC_TRY_KBUILD([#include <linux/rhconfig.h>], [],
+    [ac_linux_rhconfig=yes], [ac_linux_rhconfig=no])
+  AC_MSG_RESULT($ac_linux_rhconfig)
+  if test x"$ac_linux_rhconfig" = xyes; then
     RHCONFIG_SP="-D__BOOT_KERNEL_UP=1 -D__BOOT_KERNEL_SMP=0"
     RHCONFIG_MP="-D__BOOT_KERNEL_UP=0 -D__BOOT_KERNEL_SMP=1"
     AC_MSG_RESULT($ac_linux_rhconfig)
     if test ! -f "/boot/kernel.h"; then
         AC_MSG_WARN([/boot/kernel.h does not exist. build may fail])
     fi
-  else
-    ac_linux_rhconfig=no
-    AC_MSG_RESULT($ac_linux_rhconfig)
   fi
 fi
 AC_SUBST(RHCONFIG_SP)
@@ -76,11 +71,9 @@ AC_SUBST(MPS)
 
 AC_DEFUN([LINUX_KERNEL_SELINUX],[
 AC_MSG_CHECKING(for SELinux kernel)
-save_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="-I${LINUX_KERNEL_PATH}/include $CPPFLAGS"
 AC_CACHE_VAL(ac_cv_linux_kernel_is_selinux,
 [
-AC_TRY_COMPILE(
+AC_TRY_KBUILD(
   [#include <linux/autoconf.h>],
   [#ifndef CONFIG_SECURITY_SELINUX
    #error not SELINUX
@@ -88,15 +81,11 @@ AC_TRY_COMPILE(
   ac_cv_linux_kernel_is_selinux=yes,
   ac_cv_linux_kernel_is_selinux=no)])
 AC_MSG_RESULT($ac_cv_linux_kernel_is_selinux)
-CPPFLAGS="$save_CPPFLAGS"])
+])
 
 AC_DEFUN([LINUX_KERNEL_LINUX_SEQ_FILE_H],[
   AC_MSG_CHECKING(for linux/seq_file.h in kernel)
-  if test -f "${LINUX_KERNEL_PATH}/include/linux/seq_file.h"; then
-    ac_linux_seq_file=yes
-    AC_MSG_RESULT($ac_linux_seq_file)
-  else
-    ac_linux_seq_file=no
-    AC_MSG_RESULT($ac_linux_seq_file)
-  fi
+  AC_TRY_KBUILD([#include <linux/seq_file.h>], [],
+    [ac_linux_seq_file=yes], [ac_linux_seq_file=no])
+  AC_MSG_RESULT($ac_linux_seq_file)
 ])