Extend automatic enabling of Kbuild mechanism back as far as kernel 2.6.10
authorIan Abbott <abbotti@mev.co.uk>
Mon, 10 Jul 2006 15:39:48 +0000 (15:39 +0000)
committerIan Abbott <abbotti@mev.co.uk>
Mon, 10 Jul 2006 15:39:48 +0000 (15:39 +0000)
(which is the first Kbuild enabled kernel supported by Comedi) and also
enable Kbuild mechanism if separate kernel source and build directories
are in use.

It ought to be possible to use the Kbuild mechanism back as far as kernel
2.6.8 by checking for the script/mkmakefile file (that's what I tried first,
actually), but use of the Kbuild mechanism for 2.6.8 and 2.6.9 is currently
incompatible with Comedi's build mechanism (I tried it).

m4/as-linux.m4

index 5449fa2566ee427f9624220500060592a805a119..0d9ba40bebbf502cd6f65b969c8c504d4756b10c 100644 (file)
@@ -678,12 +678,23 @@ AC_DEFUN([AS_LINUX_VERSION_MAJOR_MINOR],
 # Check if kernel source tree is recent enough to support "Kbuild" files.
 AC_DEFUN([COMEDI_CHECK_LINUX_KBUILD],
 [
-       AC_MSG_CHECKING([for Kbuild in $1])
-       if test -a $1/Kbuild; then
+       AC_MSG_CHECKING([for Kbuild support in $1])
+       dnl For combined kernel source and build directory,
+       dnl if $1/scripts/Makefile.build refers to $(<something>)/Kbuild
+       dnl then we support Kbuild (2.6.10 onwards).
+       dnl For separate kernel source and build directory, if $1/Makefile
+       dnl contains KERNELOUTPUT variable then this is from a separate
+       dnl kernel build directory, so Kbuild is required
+       dnl (but it will not work prior to 2.6.10).
+       if grep -q '/Kbuild' "$1/scripts/Makefile.build" 2>/dev/null; then
+               AC_MSG_RESULT([yes])
+               $2
+       else if grep -q '^KERNELOUTPUT *:=' "$1/Makefile" 2>/dev/null; then
                AC_MSG_RESULT([yes])
                $2
        else
                AC_MSG_RESULT([no])
                $3
        fi
+       fi
 ])