From 0ec3b7e122f45593ed03135373559479d5ec0b3e Mon Sep 17 00:00:00 2001 From: "Brian J. Murrell" Date: Mon, 8 Mar 2010 14:53:13 -0800 Subject: [PATCH] When no kernel source has been pointed to, first attempt to use /lib/modules/$(uname -r)/source. This will likely fail when building under a mock (http://fedoraproject.org/wiki/Projects/Mock) chroot environment since `uname -r` will report the running kernel which likely is not the kernel in your chroot. To cleanly handle this we fallback to using the first kernel in your chroot. The kernel-devel package which contains all the kernel headers and a few build products such as Module.symver{s} is all the is required. Full source is not needed. --- config/kernel.m4 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/config/kernel.m4 b/config/kernel.m4 index 9f5dd6894a..303ab4cd7c 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -76,8 +76,14 @@ AC_DEFUN([ZFS_AC_KERNEL], [ AC_MSG_CHECKING([kernel source directory]) if test -z "$kernelsrc"; then - sourcelink=`ls -1d /usr/src/kernels/* /usr/src/linux-* \ - 2>/dev/null | grep -v obj | tail -1` + headersdir="/lib/modules/$(uname -r)/build" + if test -e "$headersdir"; then + sourcelink=$(readlink -f "$headersdir") + else + sourcelink=$(ls -1d /usr/src/kernels/* \ + /usr/src/linux-* \ + 2>/dev/null | grep -v obj | tail -1) + fi if test -e $sourcelink; then kernelsrc=`readlink -f ${sourcelink}`