])
dnl check for the major/minor version of the Linux source by checking
-dnl the headers
+dnl the Makefile
dnl first argument is the linux directory
dnl sets LINUX_VERSION_MAJOR and LINUX_VERSION_MINOR
AC_DEFUN([AS_LINUX_VERSION_MAJOR_MINOR],
LINUX_DIR=[$1]
AC_MSG_CHECKING([Linux major/minor version])
- if [[ ! -f "${LINUX_DIR}/include/linux/version.h" ]];then
- AC_MSG_ERROR([The header file include/linux/version.h does not exist.
-For 2.6 kernels, it can be generated by running 'make prepare' in
-the kernel source directory.])
+ if [[ ! -f "${LINUX_DIR}/Makefile" ]];then
+ AC_MSG_ERROR([The Linux kernel Makefile does not exist.])
fi
dnl the next set of tests is for figuring out version major/minor
- dnl we make sure we have the right version.h by faking out CFLAGS
- dnl since we want to avoid including linux/version.h and acidentally
- dnl pick up /usr/include/linux
- dnl we still add ${LINUX_DIR}/include so the Red Hat version can pick
- dnl up linux/rhversion.h
- ac_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -I${LINUX_DIR}/include/linux -I${LINUX_DIR}/include"
- dnl make sure we find version.h and it contains LINUX_VERSION_CODE
- AC_COMPILE_IFELSE(AC_LANG_PROGRAM([
-#include "version.h"
-int code = LINUX_VERSION_CODE;
-]),
- :, AC_MSG_ERROR([${LINUX_DIR}/include/linux/version.h does not contain LINUX_VERSION_CODE]))
-
-
- dnl figure out the linux kernel version major and minor
- dnl using the LINUX_VERSION_CODE defined in include/linux/version.h
- AC_RUN_IFELSE(AC_LANG_PROGRAM([
-#include "version.h"
-#define KERNEL_VERSION_MAJOR(code) ((code) >> 16)
-],[
- return KERNEL_VERSION_MAJOR(LINUX_VERSION_CODE);
-]),
- LINUX_VERSION_MAJOR=0,
- LINUX_VERSION_MAJOR=$?)
- AC_RUN_IFELSE(AC_LANG_PROGRAM([
-#include "version.h"
-#define KERNEL_VERSION_MINOR(code) (((code) >> 8) % (2 << 8))
-],[
- return KERNEL_VERSION_MINOR(LINUX_VERSION_CODE);
-]),
- LINUX_VERSION_MINOR=0,
- LINUX_VERSION_MINOR=$?)
+ dnl use VERSION and PATCHLEVEL in the kernel Makefile
+ LINUX_VERSION_MAJOR=`sed -n 's/^VERSION = \([[0-9]]*\)/\1/p' "${LINUX_DIR}/Makefile"`
+ LINUX_VERSION_MINOR=`sed -n 's/^PATCHLEVEL = \([[0-9]]*\)/\1/p' "${LINUX_DIR}/Makefile"`
+ if [[ -z "$LINUX_VERSION_MAJOR" -o -z "$LINUX_VERSION_MINOR" ]]; then
+ AC_MSG_ERROR([No major/minor version information found in Linux kernel Makefile.])
+ fi
AC_MSG_RESULT($LINUX_VERSION_MAJOR.$LINUX_VERSION_MINOR)
- dnl restore CFLAGS
- CFLAGS="$ac_save_CFLAGS"
])
# COMEDI_CHECK_LINUX_KBUILD([LINUX_SOURCE_PATH], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])