Recently distributions such as Debian have split their kernel
source/headers trees into a common and arch-specific trees, and the
input.h header which the previous configure code was looking for
was in the common tree, while modules should be built referring to
the arch tree, resulting in a misdetection of the kernel dir and an
inability to detect the kernel version.

Solve this by reworking the kernel tree detection logic to look for the
version header files directly, and take the opportunity to check for the
kernel version at the same time.

Signed-off-by: Giuseppe Bilotta <[email protected]>
---
 configure.in |  135 ++++++++++++++++++++++++++++------------------------------
 1 files changed, 65 insertions(+), 70 deletions(-)

diff --git a/configure.in b/configure.in
index da8f78d..7c6dc2c 100644
--- a/configure.in
+++ b/configure.in
@@ -112,86 +112,81 @@ else
                [WCM_KERNEL_DIR="$withval"])
 
        AC_MSG_CHECKING(for kernel source/headers)
+       WCM_KERNEL_DIR_CANDIDATES=
        if test "$WCM_KERNEL_DIR" = "yes" -o -z "$WCM_KERNEL_DIR"; then
-               WCM_KERNEL_DIR=
                dnl Kernel source not specified, guess where it is
-               for i in /lib/modules/`uname -r`/source /lib/modules/`uname 
-r`/build \
+               WCM_KERNEL_DIR_CANDIDATES="/lib/modules/`uname -r`/source 
/lib/modules/`uname -r`/build \
                        /usr/src/linux /usr/src/linux-`uname -r` \
-                       /usr/src/linux-2.6; do
-                       if test -f "$i/include/linux/input.h"; then
-                               WCM_KERNEL_DIR=$i
-                               WCM_ENV_KERNEL=yes
-                               AC_MSG_RESULT($WCM_KERNEL_DIR)
-                               break
-                       fi
-               done
-               if test -z "$WCM_KERNEL_DIR"; then
-                       AC_MSG_RESULT(not found)
-                       echo "***"
-                       echo "*** WARNING:"
-                       echo "*** Unable to guess kernel source directory"
-                       echo "***   Looked at /lib/modules/`uname -r`/source, 
/lib/modules/`uname -r`/build,"
-                       echo "***     /usr/src/linux, /usr/src/linux-`uname 
-r`, and"
-                       echo "***     /usr/src/linux-2.6"
-                       echo "*** Kernel modules will not be built"
-                       echo "***"
-               fi
+                       /usr/src/linux-2.6"
+               WCM_KERNEL_DIR_USER=no
        elif test "$WCM_KERNEL_DIR" != "no"; then
-               if test -f "$WCM_KERNEL_DIR/include/linux/input.h"; then
-                       WCM_ENV_KERNEL=yes
-                       AC_MSG_RESULT([yes, $WCM_KERNEL_DIR])
-               else
-                       AC_MSG_ERROR([Provided kernel path is invalid])
-               fi
-       else
-               WCM_KERNEL_DIR=
-               AC_MSG_RESULT(no)
+               WCM_KERNEL_DIR_CANDIATES="'$WCM_KERNEL_DIR'"
+               WCM_KERNEL_DIR_USER=yes
        fi
-
-       dnl Check which version of the driver we should compile
-       if test -n "$WCM_KERNEL_DIR"; then
-               AC_MSG_CHECKING(kernel version)
+       if test -n "$WCM_KERNEL_DIR_CANDIDATES"; then
+               WCM_KERNEL_DIR=
                MODUTS=
-               for a in "$WCM_KERNEL_DIR/include/linux/version.h" \
-                       "$WCM_KERNEL_DIR/include/generated/utsrelease.h" \
-                       "$WCM_KERNEL_DIR/include/linux/utsrelease.h"; do
-                       if test -f $a; then
-                               MODUTS=`grep UTS_RELEASE $a | sed -e 
's/^[[^"]]*"\([[^"]]*\).*$/\1/g'`
-                       fi
-                       test -n "$MODUTS" && break
-               done
-               if test -z "$MODUTS"; then
-                       AC_MSG_WARN(unable to identify kernel version)
-               else
-                       AC_MSG_RESULT([$MODUTS])
-                       MINOR=`echo $MODUTS | sed 
's/[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\).*/\1/'`
-                       if echo $MODUTS | grep "^2.4" >/dev/null; then
-                               AC_MSG_WARN([support for kernel 2.4.x has been 
dropped after 0.8.2])
-                       elif echo $MODUTS | grep "^2.6" >/dev/null; then
-                               if test $MINOR -ge 9; then
-                                       case $MINOR in
-                                               9) WCM_KERNEL_VER="2.6.9";;
-                                               10) WCM_KERNEL_VER="2.6.10";;
-                                               11|12) WCM_KERNEL_VER="2.6.11";;
-                                               13) WCM_KERNEL_VER="2.6.13";;
-                                               14) WCM_KERNEL_VER="2.6.14";;
-                                               15) WCM_KERNEL_VER="2.6.15";;
-                                               16|17) WCM_KERNEL_VER="2.6.16";;
-                                               18) WCM_KERNEL_VER="2.6.18";;
-                                               19|20|21) 
WCM_KERNEL_VER="2.6.19";;
-                                               22|23) WCM_KERNEL_VER="2.6.22";;
-                                               24|25) WCM_KERNEL_VER="2.6.24";;
-                                               26) WCM_KERNEL_VER="2.6.26";;
-                                               27|28|29) 
WCM_KERNEL_VER="2.6.27";;
-                                               *) WCM_KERNEL_VER="2.6.30";;
-                                       esac
-                               else
-                                       AC_MSG_WARN([support for kernels older 
than 2.6.9 has been dropped after 0.8.2])
+               for i in $WCM_KERNEL_DIR_CANDIDATES; do
+                       for a in "$i/include/linux/version.h" \
+                               "$i/include/generated/utsrelease.h" \
+                               "$i/include/linux/utsrelease.h"; do
+                               if test -f $a; then
+                                       MODUTS=`grep UTS_RELEASE $a | sed -e 
's/^[[^"]]*"\([[^"]]*\).*$/\1/g'`
+                               fi
+                               if test -n "$MODUTS"; then
+                                       WCM_KERNEL_DIR="$i"
+                                       WCM_ENV_KERNEL=yes
+                                       AC_MSG_RESULT([yes, $WCM_KERNEL_DIR, 
version $MODUTS])
+                                       MINOR=`echo $MODUTS | sed 
's/[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\).*/\1/'`
+                                       if echo $MODUTS | grep "^2.4" 
>/dev/null; then
+                                               AC_MSG_WARN([support for kernel 
2.4.x has been dropped after 0.8.2])
+                                       elif echo $MODUTS | grep "^2.6" 
>/dev/null; then
+                                               if test $MINOR -ge 9; then
+                                                       case $MINOR in
+                                                               9) 
WCM_KERNEL_VER="2.6.9";;
+                                                               10) 
WCM_KERNEL_VER="2.6.10";;
+                                                               11|12) 
WCM_KERNEL_VER="2.6.11";;
+                                                               13) 
WCM_KERNEL_VER="2.6.13";;
+                                                               14) 
WCM_KERNEL_VER="2.6.14";;
+                                                               15) 
WCM_KERNEL_VER="2.6.15";;
+                                                               16|17) 
WCM_KERNEL_VER="2.6.16";;
+                                                               18) 
WCM_KERNEL_VER="2.6.18";;
+                                                               19|20|21) 
WCM_KERNEL_VER="2.6.19";;
+                                                               22|23) 
WCM_KERNEL_VER="2.6.22";;
+                                                               24|25) 
WCM_KERNEL_VER="2.6.24";;
+                                                               26) 
WCM_KERNEL_VER="2.6.26";;
+                                                               27|28|29) 
WCM_KERNEL_VER="2.6.27";;
+                                                               *) 
WCM_KERNEL_VER="2.6.30";;
+                                                       esac
+                                               else
+                                                       AC_MSG_WARN([support 
for kernels older than 2.6.9 has been dropped after 0.8.2])
+                                               fi
+                                       else
+                                               AC_MSG_WARN(kernel version 
$MODUTS not supported)
+                                       fi
+                                       break
                                fi
+                       done
+                       test -n "$WCM_KERNEL_DIR" && break
+               done
+               if test -z "$WCM_KERNEL_DIR"; then
+                       if test "$WCM_KERNEL_DIR_USER" = "yes"; then
+                               AC_MSG_ERROR([Provided kernel path is invalid])
                        else
-                               AC_MSG_WARN(kernel version $MODUTS not 
supported)
+                               AC_MSG_RESULT(not found)
+                               echo "***"
+                               echo "*** WARNING:"
+                               echo "*** Unable to guess kernel source 
directory"
+                               echo "***   Looked at /lib/modules/`uname 
-r`/source, /lib/modules/`uname -r`/build,"
+                               echo "***     /usr/src/linux, 
/usr/src/linux-`uname -r`, and"
+                               echo "***     /usr/src/linux-2.6"
+                               echo "*** Kernel modules will not be built"
+                               echo "***"
                        fi
                fi
+       else
+               WCM_KERNEL_DIR=
+               AC_MSG_RESULT(no)
        fi
 
        dnl Check if we have support for modules in the kernel, needed if
-- 
1.7.0.3.513.gc8ed0


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to