-DKBUILD_BASENAME=\$(shell basename \$< .c)"]
AC_SUBST(COMEDI_CFLAGS)
-COMEDI_CHECK_PCMCIA_PROBE([$LINUX_DIR], [ENABLE_PCMCIA="yes"], [ENABLE_PCMCIA="no"])
+COMEDI_CHECK_PCMCIA_PROBE([$LINUX_SRC_DIR], [ENABLE_PCMCIA="yes"], [ENABLE_PCMCIA="no"])
#disable pcmcia by default until someone updates it to current kernel api
ENABLE_PCMCIA="no"
AC_ARG_ENABLE([pcmcia],[ --disable-pcmcia Disable support for PCMCIA devices],
AC_MSG_NOTICE([USB support disabled])
AM_CONDITIONAL(CONFIG_USB,false)
fi
-COMEDI_CHECK_LINUX_KBUILD([$LINUX_DIR], [ENABLE_KBUILD="yes"], [ENABLE_KBUILD="no"])
+COMEDI_CHECK_LINUX_KBUILD([$LINUX_SRC_DIR], [ENABLE_KBUILD="yes"], [ENABLE_KBUILD="no"])
AC_ARG_ENABLE([kbuild], [ --enable-kbuild Force use (or not) of kernel's Kbuild system to build modules (needs recent 2.6 kernel)],
[ENABLE_KBUILD=$enableval], [])
AM_CONDITIONAL([CONFIG_KBUILD], [test ${ENABLE_KBUILD} = "yes"])
-COMEDI_CHECK_HAVE_MUTEX_H([$LINUX_DIR], [HAVE_MUTEX_H="yes"], [HAVE_MUTEX_H="no"])
+COMEDI_CHECK_HAVE_MUTEX_H([$LINUX_SRC_DIR], [HAVE_MUTEX_H="yes"], [HAVE_MUTEX_H="no"])
AS_LINUX_CONFIG_OPTION_MODULE(CONFIG_ISA)
AS_LINUX_CONFIG_OPTION_MODULE(CONFIG_PCI)
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
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
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 End of search list.
dnl override the LINUX_MACHINE value if he did
AS_LINUX_RPM_TARGET()
- dnl find the kernel source tree for the given uname -r
+ dnl find the kernel build tree for the given uname -r
AS_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)
dnl check if user supplied a config file; if not, guess a good one
])
-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
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
+ AC_MSG_RESULT([no])
+ LINUX_SRC_DIR="$1"
+ else
+ AC_MSG_RESULT([yes])
+ 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
AC_DEFUN([COMEDI_CHECK_LINUX_KBUILD],
[
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 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
])
# COMEDI_CHECK_PCMCIA_PROBE([LINUX_SOURCE_PATH], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])