- AC_MSG_CHECKING([for $path kernel version])
- patchlevel=`sed -n 's/^PATCHLEVEL = //p' "$path/Makefile"`
- sublevel=`sed -n 's/^SUBLEVEL = //p' "$path/Makefile"`
+ # Debian breaks kernel headers into "source" header and "build" headers.
+ # We want the source headers, but $KBUILD26 gives us the "build" headers.
+ # Use heuristics to find the source headers.
+ AC_MSG_CHECKING([for Linux 2.6 source directory])
+ KSRC26=$KBUILD26
+ if test ! -e $KSRC26/include/linux/kernel.h; then
+ KSRC26=`(cd $KBUILD26 && pwd -P) | sed 's,-[[^-]]*$,-common,'`
+ if test ! -e $KSRC26/include/linux/kernel.h; then
+ AC_MSG_ERROR([cannot find source directory])
+ fi
+ fi
+ AC_MSG_RESULT([$KSRC26])
+
+ AC_MSG_CHECKING([for kernel version])
+ patchlevel=`sed -n 's/^PATCHLEVEL = //p' "$KSRC26/Makefile"`
+ sublevel=`sed -n 's/^SUBLEVEL = //p' "$KSRC26/Makefile"`
+ if test -z "$patchlevel" || test -z "$sublevel"; then
+ AC_ERROR([cannot determine kernel version])
+ fi