Changed the headers of usbdux, usbduxfast and usbduxsigma
[comedi.git] / m4 / as-linux.m4
index ab8ef36ea227c3356e92b514c6b4ee292a27e6ea..93107ea92627858d5d986ed08aa9f04e57fc9f5d 100644 (file)
@@ -13,6 +13,7 @@ dnl AS_LINUX()
 dnl
 dnl this macro adds the options
 dnl --with-linuxdir        to specify a kernel build tree location
+dnl --with-linuxsrcdir     to specify a kernel source tree location
 dnl --with-linuxconfig     to specify a kernel .config file
 dnl --with-kernel-release  to specify an alternative uname -r
 dnl --with-machine         to specify an alternative uname -m
@@ -23,7 +24,9 @@ dnl --with-modulesdeveldir to specify the base install location of build stuff
 
 dnl this macro defines:
 dnl LINUX_DIR
-dnl   The directory where the Linux source resides.
+dnl   The directory where the Linux build tree resides.
+dnl LINUX_SRC_DIR
+dnl   The directory where the Linux source tree resides.
 dnl CONFIG_FILE
 dnl   The Linux config file
 dnl LINUX_ARCH
@@ -54,11 +57,11 @@ dnl LINUX_MODULE_EXT
 dnl   Module extension (.o or .ko)
 dnl LINUX_MODPOST
 dnl   path to modpost script
-dnl modulesdir
+dnl MODULESDIR
 dnl   base install path for kernel modules
-dnl modulesdeveldir
+dnl MODULESDEVELDIR
 dnl   base install path for kernel module development files
-dnl 
+dnl
 dnl End of search list.
 
 dnl main entry point
@@ -68,32 +71,36 @@ AC_DEFUN([AS_LINUX],
        dnl check if user supplied a uname -r, and if not use the running one
        AS_LINUX_KERNEL_RELEASE()
        dnl check if user supplied a uname -m, and if not use the running one
-       AS_LINUX_MACHINE()       
+       AS_LINUX_MACHINE()
        dnl check if the user supplied an rpm target arch
        dnl override the LINUX_MACHINE value if he did
-       AS_LINUX_RPM_TARGET()    
-        
-       dnl find the kernel source tree for the given uname -r   
+       AS_LINUX_RPM_TARGET()
+
+       dnl find the kernel build tree for the given uname -r
        AS_LINUX_DIR()
+       dnl override kernel release uname -r value with info from build tree
+       AS_LINUX_OVERRIDE_KERNEL_RELEASE($LINUX_DIR)
+       dnl find the kernel source tree from the build tree or --with-linuxsrcdir
+       AS_LINUX_SRC_DIR($LINUX_DIR)
        dnl check if user supplied an EXTRAVERSION, and if not get from uname -r
-       AS_LINUX_EXTRAVERSION($LINUX_KERNEL_RELEASE)     
+       AS_LINUX_EXTRAVERSION($LINUX_KERNEL_RELEASE)
        dnl check if user supplied a config file; if not, guess a good one
-       AS_LINUX_CONFIG($LINUX_DIR, $LINUX_KERNEL_RELEASE, $LINUX_MACHINE)       
+       AS_LINUX_CONFIG($LINUX_DIR, $LINUX_KERNEL_RELEASE, $LINUX_MACHINE)
        dnl check if we're building on pre-FC2 Red Hat/Fedora,
-       dnl and add some flags if we are         
-       AS_CHECK_REDHAT_PRE_FC2()        
+       dnl and add some flags if we are
+       AS_CHECK_REDHAT_PRE_FC2()
        dnl check for where to install modules
        AS_LINUX_MODULESDIR($LINUX_KERNEL_RELEASE)
        dnl check for where to install module development files
        AS_LINUX_MODULESDEVELDIR($LINUX_DIR)
-       dnl check for the MAJOR/MINOR version of Linux   
+       dnl check for the MAJOR/MINOR version of Linux
        AS_LINUX_VERSION_MAJOR_MINOR($LINUX_DIR)
 
        dnl now call the correct macro to get compiler flags
        dnl the versioned AS_LINUX macros just use the global variables
        dnl this could be cleaned up later on if we feel like it
        case $LINUX_VERSION_MAJOR.$LINUX_VERSION_MINOR in
-               2.6)
+               2.6 | 3.[[0-9]]*)
                        AS_LINUX_2_6()
                        ;;
                2.[[01234]])
@@ -106,18 +113,18 @@ AC_DEFUN([AS_LINUX],
 ])
 
 
-dnl check if we can find a source dir for the Linux kernel
-dnl defines LINUX_DIR to the absolute location of a usable kernel source tree
+dnl check if we can find a build dir for the Linux kernel
+dnl defines LINUX_DIR to the absolute location of a usable kernel build tree
 AC_DEFUN([AS_LINUX_DIR],
 [
        AC_ARG_WITH([linuxdir],
                [AC_HELP_STRING([--with-linuxdir=DIR],
-                       [specify path to Linux source directory])],
+                       [specify path to Linux build directory])],
                [LINUX_DIR="${withval}"],
                [LINUX_DIR=default])
 
        if test "${LINUX_DIR}" != "default" ; then
-               AS_TRY_LINUX_DIR([${LINUX_DIR}], , AC_MSG_ERROR([Linux dir not found]) )
+               AS_TRY_LINUX_DIR([${LINUX_DIR}], , AC_MSG_ERROR([Linux build dir not found]) )
        fi
 
        if test "${LINUX_DIR}" = "default" ; then
@@ -134,15 +141,71 @@ AC_DEFUN([AS_LINUX_DIR],
        fi
 
        if test "${LINUX_DIR}" = "default" ; then
-               AC_MSG_ERROR([Linux source directory not found])
+               AC_MSG_ERROR([Linux build directory not found])
        fi
 
        AC_SUBST(LINUX_DIR)
 ])
 
-dnl check if the given candidate path for a linux source tree is usable
+dnl check if the given candidate path for a linux build tree is usable
 AC_DEFUN([AS_TRY_LINUX_DIR],
-       [AC_MSG_CHECKING(for Linux in $1)
+       [AC_MSG_CHECKING(for Linux build in $1)
+
+       if test -f "$1/Makefile" ; then
+               result=yes
+               $2
+       else
+               result="not found"
+               $3
+       fi
+
+       AC_MSG_RESULT($result)
+])
+
+dnl get the kernel source directory
+dnl $1 is the kernel build directory
+dnl defines LINUX_SRC_DIR to the absolute location of kernel source tree
+AC_DEFUN([AS_LINUX_SRC_DIR],
+[
+       AC_ARG_WITH([linuxsrcdir],
+               [AC_HELP_STRING([--with-linuxsrcdir=DIR],
+                       [specify path to Linux source directory])],
+               [LINUX_SRC_DIR="${withval}"],
+               [LINUX_SRC_DIR=default])
+
+       if test "${LINUX_SRC_DIR}" != "default" ; then
+               AS_TRY_LINUX_SRC_DIR([${LINUX_SRC_DIR}], , AC_MSG_ERROR([Linux source dir not found]) )
+       fi
+
+       if test "${LINUX_SRC_DIR}" = "default" ; then
+               AC_MSG_CHECKING(for separate Linux source and build directory)
+               dir=`sed -n -e 's/^KERNELSRC *:= *\(.*\)/\1/p' "$1/Makefile"`
+               if test -z "$dir"; then
+                       # 2.6.25
+                       dir=`sed -n -e 's/^MAKEARGS *:= *-C *\([[^[:space:]]]*\).*/\1/p' "$1/Makefile"`
+               fi
+               if test -z "$dir"; then
+                       AC_MSG_RESULT([no])
+                       LINUX_SRC_DIR="$1"
+               else
+                       AC_MSG_RESULT([yes])
+                       case "$dir" in
+                       .*) dir="$1/$dir" ;;
+                       esac
+                       AS_TRY_LINUX_SRC_DIR([${dir}], [LINUX_SRC_DIR=${dir}], )
+               fi
+       fi
+
+       if test "${LINUX_SRC_DIR}" = "default" ; then
+               AC_MSG_ERROR([Linux source directory not found])
+       fi
+
+       AC_SUBST(LINUX_SRC_DIR)
+])
+
+dnl check if the given candidate path for a linux source tree is usable
+AC_DEFUN([AS_TRY_LINUX_SRC_DIR],
+       [AC_MSG_CHECKING(for Linux source in $1)
 
        if test -f "$1/Makefile" ; then
                result=yes
@@ -172,8 +235,30 @@ AC_DEFUN([AS_LINUX_KERNEL_RELEASE],
         AC_MSG_NOTICE([Using $LINUX_KERNEL_RELEASE as the uname -r value])
 ])
 
+dnl replaces LINUX_KERNEL_RELEASE once the Linux build directory is known
+dnl first argument is the Linux build directory
+AC_DEFUN([AS_LINUX_OVERRIDE_KERNEL_RELEASE],
+[
+       INCDIR="$1/include"
+       UTSINC="${INCDIR}/linux/utsrelease.h"
+       if ! test -f "${UTSINC}"; then
+               UTSINC="${INCDIR}/linux/version.h"
+       fi
+       if test -f "${UTSINC}"; then
+               RELEASE=`echo UTS_RELEASE | cat "${UTSINC}" - |
+                       /lib/cpp -I "${INCDIR}" | tail -n 1 |
+                       sed 's/^"\(.*\)"$/\1/'`
+               if test "${RELEASE}" != "UTS_RELEASE" -a "${RELEASE}" != "" \
+                       -a "${RELEASE}" != "${LINUX_KERNEL_RELEASE}"; then
+                       AC_MSG_NOTICE([Overriding uname -r value with ${RELEASE}])
+                       LINUX_KERNEL_RELEASE="${RELEASE}"
+               fi
+
+       fi
+])
+
 dnl allow for specifying a machine (uname -m) to build for
-dnl use uname -, of running one if not specified
+dnl use uname -m, of running one if not specified
 dnl store result in LINUX_MACHINE
 AC_DEFUN([AS_LINUX_MACHINE],
 [
@@ -184,7 +269,7 @@ AC_DEFUN([AS_LINUX_MACHINE],
                [LINUX_MACHINE=`uname -m`])
         if test "x$LINUX_MACHINE" = "xyes";
         then
-               LINUX_MACHINE=`uname -r`
+               LINUX_MACHINE=`uname -m`
         fi
         AC_MSG_NOTICE([Using $LINUX_MACHINE as the uname -m value])
 ])
@@ -210,23 +295,13 @@ AC_DEFUN([AS_LINUX_RPM_TARGET],
        then
                dnl if we have rpm, try to guess the target of the kernel
                dnl we want to build for using rpm
-               AC_PATH_PROG(RPM, rpm, yes, no)
+               AC_PATH_PROG([RPM], [rpm], [no])
                if test "x$RPM" != "xno" ; then
-                       AC_MSG_CHECKING([if rpm can be used to query packages])
-                       if rpm -qa >/dev/null 2>/dev/null ; then
-                         rpm_check=yes
+                       if $RPM -q kernel-$RELEASE > /dev/null
+                       then
+                         LINUX_RPM_TARGET=`$RPM -q --queryformat %{arch} kernel-$RELEASE`
                        else
-                         rpm_check=no
-                       fi
-                       AC_MSG_RESULT($rpm_check)
-
-                       if test "x$rpm_check" = yes ; then
-                         if rpm -q kernel-$RELEASE > /dev/null
-                         then
-                           LINUX_RPM_TARGET=`rpm -q --queryformat %{arch} kernel-$RELEASE`
-                         else
-                           AC_MSG_NOTICE([Cannot guess target arch, consider setting it using --with-rpm-target])
-                         fi
+                         AC_MSG_NOTICE([Cannot guess target arch, consider setting it using --with-rpm-target])
                        fi
                fi
        fi
@@ -381,7 +456,7 @@ int code = RED_HAT_LINUX_KERNEL;
        BIGMEM='0'
        HUGEMEM='0'
 
-       dnl get variables from the currently running kernel as default 
+       dnl get variables from the currently running kernel as default
        KERNEL_TYPE=`uname -r | sed 's_^.*\(smp\|enterprise\|bigmem\|hugemem\)$_\1_;t;s_.*__;'`
        KERNEL_RELEASE=`uname -r | sed 's|smp\|enterprise\|bigmem\|hugemem||g'`
        KERNEL_ARCH=`uname -m`
@@ -498,10 +573,11 @@ flags:
        echo LINUX_CC=\"\$(CC)\" >>\$(obj)/flags
        echo LINUX_LD=\"\$(LD) \$(LDFLAGS) \$(LDFLAGS_MODULE)\" >>\$(obj)/flags
        echo LINUX_AS=\"\$(AS)\" >>\$(obj)/flags
+       echo LINUX_MODLIB=\"\$(MODLIB)\" >>\$(obj)/flags
 EOF
 
-       echo ${MAKE-make} -C ${LINUX_DIR} V=1 SUBDIRS=${tmpdir} LINUXDIR=${LINUX_DIR} MODVERDIR=${tmpdir} modules >&5 2>&5
-       ${MAKE-make} -C ${LINUX_DIR} V=1 SUBDIRS=${tmpdir} LINUXDIR=${LINUX_DIR} MODVERDIR=${tmpdir} modules >&5 2>&5
+       echo ${MAKE-make} -C ${LINUX_DIR} V=1 SUBDIRS=${tmpdir} LINUXDIR=${LINUX_DIR} modules >&5 2>&5
+       ${MAKE-make} -C ${LINUX_DIR} V=1 SUBDIRS=${tmpdir} LINUXDIR=${LINUX_DIR} modules >&5 2>&5
        . ${tmpdir}/flags
        rm -rf ${tmpdir}
 
@@ -523,9 +599,10 @@ EOF
        AC_SUBST(LINUX_MODULE_EXT)
        AC_SUBST(LINUX_MODULE_STYLE)
        AC_SUBST(LINUX_MODPOST)
+       AC_SUBST(LINUX_MODLIB)
 
        AC_MSG_RESULT([$LINUX_CFLAGS])
-       
+
        AC_PATH_PROG([LINUX_MODPOST], ["modpost"], ["no"], ["$LINUX_DIR/scripts:$LINUX_DIR/scripts/mod"])
 ])
 
@@ -651,7 +728,7 @@ AC_DEFUN([AS_LINUX_CONFIG_OPTION_MODULE],
 ])
 
 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],
@@ -659,48 +736,17 @@ 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])
@@ -709,8 +755,215 @@ int code = LINUX_VERSION_CODE;
 # 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 If $1/scripts/Makefile.build refers to $(<something>)/Kbuild
+       dnl then we support Kbuild (2.6.10 onwards).
+       if grep -q '/Kbuild' "$1/scripts/Makefile.build" 2>/dev/null; then
+               AC_MSG_RESULT([yes])
+               $2
+       else
+               AC_MSG_RESULT([no])
+               $3
+       fi
+])
+
+# COMEDI_CHECK_PCMCIA_PROBE([LINUX_SOURCE_PATH], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# -------------------------------------------------------------
+#
+# Check if kernel pcmcia support is new enough to have a probe member in the pcmcia_driver
+# struct.
+AC_DEFUN([COMEDI_CHECK_PCMCIA_DRIVER_PROBE],
+[
+       AC_REQUIRE([AC_PROG_EGREP])
+       AC_MSG_CHECKING([$1 for probe in pcmcia_driver struct])
+       cat "$1/include/pcmcia/ds.h" | tr \\n ' ' | [$EGREP "struct[[:space:]]+pcmcia_driver[[:space:]]*[{][^}]*probe"] > /dev/null
+       if (($?)); then
+               AC_MSG_RESULT([no])
+               $3
+       else
+               AC_MSG_RESULT([yes])
+               $2
+       fi
+])
+
+# COMEDI_CHECK_PCMCIA_DRIVER_NAME([LINUX_SOURCE_PATH], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# -------------------------------------------------------------
+#
+# Check if kernel pcmcia support is new enough to have a name member in the pcmcia_driver
+# struct.
+AC_DEFUN([COMEDI_CHECK_PCMCIA_DRIVER_NAME],
+[
+       AC_REQUIRE([AC_PROG_EGREP])
+       AC_MSG_CHECKING([$1 for name in pcmcia_driver struct])
+       cat "$1/include/pcmcia/ds.h" | tr \\n ' ' | [$EGREP "struct[[:space:]]+pcmcia_driver[[:space:]]*[{][^}]*name"] > /dev/null
+       if (($?)); then
+               AC_MSG_RESULT([no])
+               $3
+       else
+               AC_MSG_RESULT([yes])
+               $2
+       fi
+])
+
+# COMEDI_CHECK_PCMCIA_LOOP_TUPLE([LINUX_SOURCE_PATH], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# -------------------------------------------------------------
+#
+# Check if kernel pcmcia support is new enough to have the pcmcia_loop_tuple
+# function.
+AC_DEFUN([COMEDI_CHECK_PCMCIA_LOOP_TUPLE],
+[
+       AC_MSG_CHECKING([$1 for pcmcia_loop_tuple function])
+       if [grep -q 'int[[:space:]]\+pcmcia_loop_tuple[[:space:]]*(' "$1/include/pcmcia/ds.h"] 2>/dev/null ; then
+               AC_MSG_RESULT([yes])
+               $2
+       else
+               AC_MSG_RESULT([no])
+               $3
+       fi
+])
+
+# COMEDI_CHECK_DS_DEV_NODE_T([LINUX_SOURCE_PATH], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# -------------------------------------------------------------
+#
+# Check if kernel pcmcia support is old enough to have the dev_node_t type
+# in pcmcia/ds.h.
+AC_DEFUN([COMEDI_CHECK_DS_DEV_NODE_T],
+[
+       AC_MSG_CHECKING([$1 for dev_node_t in pcmcia/ds.h (removed in 2.6.35)])
+       if [grep -q dev_node_t "$1/include/pcmcia/ds.h"] 2>/dev/null ; then
+               AC_MSG_RESULT([yes])
+               $2
+       else
+               AC_MSG_RESULT([no])
+               $3
+       fi
+])
+
+# COMEDI_CHECK_CS_IRQ_REQ_T([LINUX_SOURCE_PATH], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# -------------------------------------------------------------
+#
+# Check if kernel pcmcia support is old enough to have the irq_req_t type
+# in pcmcia/cs.h.
+AC_DEFUN([COMEDI_CHECK_CS_IRQ_REQ_T],
+[
+       AC_MSG_CHECKING([$1 for irq_req_t in pcmcia/cs.h (removed in 2.6.35)])
+       if [grep -q irq_req_t "$1/include/pcmcia/cs.h"] 2>/dev/null ; then
+               AC_MSG_RESULT([yes])
+               $2
+       else
+               AC_MSG_RESULT([no])
+               $3
+       fi
+])
+
+# COMEDI_CHECK_CS_IO_REQ_T([LINUX_SOURCE_PATH], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# -------------------------------------------------------------
+#
+# Check if kernel pcmcia support is old enough to have the io_req_t type
+# in pcmcia/cs.h.
+AC_DEFUN([COMEDI_CHECK_CS_IO_REQ_T],
+[
+       AC_MSG_CHECKING([$1 for io_req_t in pcmcia/cs.h (removed in 2.6.36)])
+       if [grep -q io_req_t "$1/include/pcmcia/cs.h"] 2>/dev/null ; then
+               AC_MSG_RESULT([yes])
+               $2
+       else
+               AC_MSG_RESULT([no])
+               $3
+       fi
+])
+
+# COMEDI_CHECK_CS_MEMREQ_T([LINUX_SOURCE_PATH], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# -------------------------------------------------------------
+#
+# Check if kernel pcmcia support is old enough to have the memreq_t type
+# in pcmcia/cs.h.
+AC_DEFUN([COMEDI_CHECK_CS_MEMREQ_T],
+[
+       AC_MSG_CHECKING([$1 for memreq_t in pcmcia/cs.h (removed in 2.6.36)])
+       if [grep -q memreq_t "$1/include/pcmcia/cs.h"] 2>/dev/null ; then
+               AC_MSG_RESULT([yes])
+               $2
+       else
+               AC_MSG_RESULT([no])
+               $3
+       fi
+])
+
+# COMEDI_CHECK_HAVE_CS_TYPES_H([LINUX_SOURCE_PATH], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# -------------------------------------------------------------
+#
+# Check if kernel has <pcmcia/cs_types.h> file.
+AC_DEFUN([COMEDI_CHECK_HAVE_CS_TYPES_H],
+[
+       AC_MSG_CHECKING([$1 for include/pcmcia/cs_types.h (removed in 2.6.36)])
+       if test -f "$1/include/pcmcia/cs_types.h"; then
+               AC_MSG_RESULT([yes])
+               $2
+       else
+               AC_MSG_RESULT([no])
+               $3
+       fi
+])
+
+# COMEDI_CHECK_HAVE_CS_H([LINUX_SOURCE_PATH], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# -------------------------------------------------------------
+#
+# Check if kernel has <pcmcia/cs.h> file.
+AC_DEFUN([COMEDI_CHECK_HAVE_CS_H],
+[
+       AC_MSG_CHECKING([$1 for include/pcmcia/cs.h (removed in 2.6.37)])
+       if test -f "$1/include/pcmcia/cs.h"; then
+               AC_MSG_RESULT([yes])
+               $2
+       else
+               AC_MSG_RESULT([no])
+               $3
+       fi
+])
+
+# COMEDI_CHECK_HAVE_MUTEX_H([LINUX_SOURCE_PATH], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# -------------------------------------------------------------
+#
+# Check if kernel has <linux/mutex.h> file.
+AC_DEFUN([COMEDI_CHECK_HAVE_MUTEX_H],
+[
+       AC_MSG_CHECKING([$1 for include/linux/mutex.h])
+       if test -f "$1/include/linux/mutex.h"; then
+               AC_MSG_RESULT([yes])
+               $2
+       else
+               AC_MSG_RESULT([no])
+               $3
+       fi
+])
+
+# COMEDI_CHECK_HAVE_LINUX_SEMAPHORE_H([LINUX_SOURCE_PATH], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# -------------------------------------------------------------
+#
+# Check if kernel has <linux/semaphore.h> file.
+AC_DEFUN([COMEDI_CHECK_HAVE_LINUX_SEMAPHORE_H],
+[
+       AC_MSG_CHECKING([$1 for include/linux/semaphore.h])
+       if test -f "$1/include/linux/semaphore.h"; then
+               AC_MSG_RESULT([yes])
+               $2
+       else
+               AC_MSG_RESULT([no])
+               $3
+       fi
+])
+
+# COMEDI_CHECK_HAVE_GENERIC_BOOL_TYPE([LINUX_SOURCE_PATH], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+#
+# -------------------------------------------------------------
+# Check if kernel is new enough to have generic 'bool' type in <linux/types.h>
+# and 'false' and 'true' enum constants in <linux/stddef.h>.  This was added
+# in vanilla 2.6.19, but backported to RHEL5 2.6.18.
+AC_DEFUN([COMEDI_CHECK_HAVE_GENERIC_BOOL_TYPE],
+[
+       AC_MSG_CHECKING([$1 for 'bool' in include/linux/types.h])
+       if grep -q 'bool;' "$1/include/linux/types.h" 2>/dev/null; then
                AC_MSG_RESULT([yes])
                $2
        else