3 dnl autostars m4 macro for detecting a Linux source tree (or
4 dnl equivalent) for compiling modules.
6 dnl David Schleef <ds@schleef.org>
7 dnl Frank Mori Hess <fmhess@users.sourceforge.net>
8 dnl Thomas Vander Stichele <thomas@apestaart.org>
14 dnl this macro adds the options
15 dnl --with-linuxdir to specify a kernel build tree location
16 dnl --with-linuxconfig to specify a kernel .config file
17 dnl --with-kernel-release to specify an alternative uname -r
18 dnl --with-machine to specify an alternative uname -m
19 dnl --with-rpm-target to specify to match the given rpm --target option
20 dnl --with-extraversion to specify an EXTRAVERSION override
21 dnl --with-modulesdir to specify the base install location of modules
22 dnl --with-modulesdeveldir to specify the base install location of build stuff
24 dnl this macro defines:
26 dnl The directory where the Linux source resides.
28 dnl The Linux config file
30 dnl $(ARCH) in kernel Makefiles
32 dnl $(AFLAGS) in kernel Makefiles
34 dnl Linker flags used by Linux
36 dnl Archiver flags used by Linux
37 dnl LINUX_CROSS_COMPILE
38 dnl Cross-compiler prefix, if any. (example: "powerpc-linux-")
39 dnl LINUX_KERNELRELEASE
40 dnl Kernel release name (2.4.5-pre4-ac5-rmk), $(KERNELRELEASE) in
43 dnl CFLAGS used by Linux. Includes both $CFLAGS and $MODFLAGS from
44 dnl kernel Makefiles. Also includes warnings and optimization.
46 dnl Compiler used by Linux.
48 dnl Path to linker (possibly with options) used by Linux.
50 dnl Assembler used by Linux.
51 dnl LINUX_MODULE_STYLE
52 dnl Style of module building (2.4.0, 2.6.0, 2.6.6)
54 dnl Module extension (.o or .ko)
56 dnl path to modpost script
58 dnl base install path for kernel modules
60 dnl base install path for kernel module development files
62 dnl End of search list.
65 dnl checks the version, and figures out all flags to use to make modules.
68 dnl check if user supplied a uname -r, and if not use the running one
69 AS_LINUX_KERNEL_RELEASE()
70 dnl check if user supplied a uname -m, and if not use the running one
72 dnl check if the user supplied an rpm target arch
73 dnl override the LINUX_MACHINE value if he did
76 dnl find the kernel source tree for the given uname -r
78 dnl check if user supplied an EXTRAVERSION, and if not get from uname -r
79 AS_LINUX_EXTRAVERSION($LINUX_KERNEL_RELEASE)
80 dnl check if user supplied a config file; if not, guess a good one
81 AS_LINUX_CONFIG($LINUX_DIR, $LINUX_KERNEL_RELEASE, $LINUX_MACHINE)
82 dnl check if we're building on pre-FC2 Red Hat/Fedora,
83 dnl and add some flags if we are
84 AS_CHECK_REDHAT_PRE_FC2()
85 dnl check for where to install modules
86 AS_LINUX_MODULESDIR($LINUX_KERNEL_RELEASE)
87 dnl check for where to install module development files
88 AS_LINUX_MODULESDEVELDIR($LINUX_DIR)
89 dnl check for the MAJOR/MINOR version of Linux
90 AS_LINUX_VERSION_MAJOR_MINOR($LINUX_DIR)
92 dnl now call the correct macro to get compiler flags
93 dnl the versioned AS_LINUX macros just use the global variables
94 dnl this could be cleaned up later on if we feel like it
95 case $LINUX_VERSION_MAJOR.$LINUX_VERSION_MINOR in
103 AC_MSG_ERROR([Unknown Linux major.minor $LINUX_VERSION_MAJOR.$LINUX_VERSION_MINOR])
109 dnl check if we can find a source dir for the Linux kernel
110 dnl defines LINUX_DIR to the absolute location of a usable kernel source tree
111 AC_DEFUN([AS_LINUX_DIR],
113 AC_ARG_WITH([linuxdir],
114 [AC_HELP_STRING([--with-linuxdir=DIR],
115 [specify path to Linux source directory])],
116 [LINUX_DIR="${withval}"],
119 if test "${LINUX_DIR}" != "default" ; then
120 AS_TRY_LINUX_DIR([${LINUX_DIR}], , AC_MSG_ERROR([Linux dir not found]) )
123 if test "${LINUX_DIR}" = "default" ; then
124 dir="/lib/modules/$LINUX_KERNEL_RELEASE/build";
125 AS_TRY_LINUX_DIR([${dir}], [LINUX_DIR=${dir}], )
127 if test "${LINUX_DIR}" = "default" ; then
129 AS_TRY_LINUX_DIR([${dir}], [LINUX_DIR=${dir}], )
131 if test "${LINUX_DIR}" = "default" ; then
132 dir="/usr/src/linux";
133 AS_TRY_LINUX_DIR([${dir}], [LINUX_DIR=${dir}], )
136 if test "${LINUX_DIR}" = "default" ; then
137 AC_MSG_ERROR([Linux source directory not found])
143 dnl check if the given candidate path for a linux source tree is usable
144 AC_DEFUN([AS_TRY_LINUX_DIR],
145 [AC_MSG_CHECKING(for Linux in $1)
147 if test -f "$1/Makefile" ; then
155 AC_MSG_RESULT($result)
158 dnl allow for specifying a kernel release (uname -r) to build for
159 dnl use uname -r of running one if not specified
160 dnl store result in LINUX_KERNEL_RELEASE
161 AC_DEFUN([AS_LINUX_KERNEL_RELEASE],
163 AC_ARG_WITH([kernel-release],
164 [AC_HELP_STRING([--with-kernel-release=RELEASE],
165 [specify the "uname -r"-value to build for])],
166 [LINUX_KERNEL_RELEASE="${withval}"],
167 [LINUX_KERNEL_RELEASE=`uname -r`])
168 if test "x$LINUX_KERNEL_RELEASE" = "xyes";
170 LINUX_KERNEL_RELEASE=`uname -r`
172 AC_MSG_NOTICE([Using $LINUX_KERNEL_RELEASE as the uname -r value])
175 dnl allow for specifying a machine (uname -m) to build for
176 dnl use uname -, of running one if not specified
177 dnl store result in LINUX_MACHINE
178 AC_DEFUN([AS_LINUX_MACHINE],
180 AC_ARG_WITH([machine],
181 [AC_HELP_STRING([--with-machine=MACHINE],
182 [specify the "uname -m"-value to build for])],
183 [LINUX_MACHINE="${withval}"],
184 [LINUX_MACHINE=`uname -m`])
185 if test "x$LINUX_MACHINE" = "xyes";
187 LINUX_MACHINE=`uname -r`
189 AC_MSG_NOTICE([Using $LINUX_MACHINE as the uname -m value])
191 dnl allow for specifying an rpm target arch
192 dnl if none specified, try to guess one from running rpm querying for
193 dnl the kernel with the uname -r
194 dnl this is so configure without arguments works out of the box
195 dnl FIXME: investigate if uname -p is a correct guess for this, and if
196 dnl we should have a flag for specifying it instead
198 dnl this macro possibly overrides LINUX_MACHINE
200 dnl first argument is the kernel release building for
201 AC_DEFUN([AS_LINUX_RPM_TARGET],
203 RELEASE=$LINUX_KERNEL_RELEASE
204 AC_ARG_WITH([rpm-target],
205 [AC_HELP_STRING([--with-rpm-target=TARGET],
206 [specify the target arch to build for])],
207 [LINUX_RPM_TARGET="${withval}"],
209 if test "x$LINUX_RPM_TARGET" = "x"
211 dnl if we have rpm, try to guess the target of the kernel
212 dnl we want to build for using rpm
213 AC_PATH_PROG(RPM, rpm, yes, no)
214 if test "x$RPM" != "xno" ; then
215 AC_MSG_CHECKING([if rpm can be used to query packages])
216 if rpm -qa >/dev/null 2>/dev/null ; then
221 AC_MSG_RESULT($rpm_check)
223 if test "x$rpm_check" = yes ; then
224 if rpm -q kernel-$RELEASE > /dev/null
226 LINUX_RPM_TARGET=`rpm -q --queryformat %{arch} kernel-$RELEASE`
228 AC_MSG_NOTICE([Cannot guess target arch, consider setting it using --with-rpm-target])
234 dnl now override LINUX_MACHINE if LINUX_RPM_TARGET is set
235 if test "x$LINUX_RPM_TARGET" != "x"
237 dnl override LINUX_MACHINE based on this
238 dnl FIXME: add other possible Red Hat/Fedora/rpm targets here
240 case "$LINUX_RPM_TARGET" in
241 i?86) LINUX_MACHINE=i386;;
242 athlon) LINUX_MACHINE=i386;;
243 x86_64) LINUX_MACHINE=x86_64;;
245 if test "x$LINUX_MACHINE" = "x"
247 AC_MSG_ERROR(Could not guess uname -m value from target $LINUX_RPM_TARGET)
253 dnl allow for specifying an override for EXTRAVERSION
254 dnl if none specified, make it from the passed-in KERNEL_RELEASE (uname -r)
255 dnl resulting value is stored in LINUX_EXTRAVERSION
256 dnl first argument is the uname -r string to use as a fallback
257 AC_DEFUN([AS_LINUX_EXTRAVERSION],
260 dnl extract the default by getting everything after first -
261 LINUX_EXTRAVERSION="-`echo $KERNEL_RELEASE | cut -d- -f 2-`"
262 AC_ARG_WITH([extraversion],
263 [AC_HELP_STRING([--with-extraversion=FILE],
264 [specify override for kernel EXTRAVERSION])],
265 [LINUX_EXTRAVERSION="${withval}"],)
269 dnl check if we can find a config file for the Linux kernel
270 dnl defines LINUX_CONFIG to the absolute location of a usable
271 dnl kernel source config file
273 dnl for rpm distros, it can try and guess the correct config file by
274 dnl checking the global LINUX_RPM_TARGET variable set somewhere else
275 dnl (FIXME: move this to an argument instead ?)
277 dnl first argument is LINUX_DIR to check for possible configs
278 dnl second argument is kernel-release (uname -r)
279 dnl third argument is machine (uname -m)
281 AC_DEFUN([AS_LINUX_CONFIG],
286 AC_ARG_WITH([linuxconfig],
287 [AC_HELP_STRING([--with-linuxconfig=FILE],
288 [specify path to Linux configuration file])],
289 [LINUX_CONFIG="${withval}"],
290 [LINUX_CONFIG=default])
292 dnl if a file got specified, try it as a linux config file
293 if test "${LINUX_CONFIG}" != "default" ; then
294 AS_TRY_LINUX_CONFIG($LINUX_CONFIG, $MACHINE,
295 ,, AC_MSG_ERROR([Linux config not found]) )
298 dnl if no file specified, first check for the regular .config file
299 dnl in LINUX_DIR created by manual configuration
300 if test "${LINUX_CONFIG}" = "default" ; then
301 file="$LINUX_DIR/.config";
302 AS_TRY_LINUX_CONFIG($file, $MACHINE,
303 [LINUX_CONFIG=${file}], )
305 dnl second, try to guess what config file to use for the current kernel
306 dnl FIXME: the possible arch is from rpmbuild --target, and is
307 dnl different from the value of ARCH (Makefile) or MACHINE (uname -m)
308 dnl so we should have a redhat flag to specify the target to find
309 dnl the correct config file
310 if test "${LINUX_CONFIG}" = "default" && test "x$LINUX_RPM_TARGET" != "x"; then
311 dnl Red Hat stores configuration files for their built kernels
312 dnl named kernel-(version)-(arch)(extra).config
313 dnl where arch is athlon, i386, i586, i686, x86_64
314 dnl and (extra) is empty or -smp, -BOOT, -bigmem
315 dnl haven't seen combinations of extra yet as of FC1
316 KVERSION=`echo $KERNEL_RELEASE | cut -d- -f1`
318 echo $KERNEL_RELEASE | grep smp && EXTRA="-smp"
319 echo $KERNEL_RELEASE | grep bigmem && EXTRA="-bigmem"
320 echo $KERNEL_RELEASE | grep BOOT && EXTRA="-BOOT"
321 file="$LINUX_DIR/configs/kernel-$KVERSION-$LINUX_RPM_TARGET$EXTRA.config"
322 AS_TRY_LINUX_CONFIG($file, $MACHINE,
323 [LINUX_CONFIG=${file}], )
325 if test "${LINUX_CONFIG}" = "default" ; then
327 The kernel source tree at ${LINUX_DIR} is not configured,
328 and no configuration files in config/ matching your kernel were found.
329 Fix before continuing or specify a config file using --with-configfile.])
332 AC_SUBST(LINUX_CONFIG)
335 dnl check if the given candidate config file is usable
336 dnl FIXME: it would be nice if it could check if it matches the
337 dnl given machine (uname -m)
338 AC_DEFUN([AS_TRY_LINUX_CONFIG],
342 AC_MSG_CHECKING($CFG)
344 if test -f "$CFG" ; then
346 ifelse([$3], , :, [$3])
349 ifelse([$4], , :, [$4])
351 AC_MSG_RESULT($result)
354 dnl check if RED_HAT_LINUX_KERNEL is defined
355 dnl pre-FC2 RH/Fedora defines this in linux/rhconfig.h
356 dnl included from linux/version.h
357 dnl if this is present, a few extra defines need to be present to make sure
358 dnl symbol versioning is correct
359 dnl uses LINUX_DIR to find rhconfig.h
360 AC_DEFUN([AS_CHECK_REDHAT_PRE_FC2],
362 AC_MSG_CHECKING(Pre-FC2 Red Hat/Fedora kernel)
363 HAVE_REDHAT_KERNEL=false
364 ac_save_CFLAGS="$CFLAGS"
365 CFLAGS="$CFLAGS -I${LINUX_DIR}/include/linux"
366 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([
367 #include "rhconfig.h"
368 int code = RED_HAT_LINUX_KERNEL;
370 AC_MSG_RESULT(found); HAVE_REDHAT_KERNEL=true,
371 AC_MSG_RESULT(not found))
373 CFLAGS="$ac_save_CFLAGS"
375 dnl check for Red Hat define flags to use - see /sbin/mkkerneldoth
377 dnl initialize the booleans we want to detect
384 dnl get variables from the currently running kernel as default
385 KERNEL_TYPE=`uname -r | sed 's_^.*\(smp\|enterprise\|bigmem\|hugemem\)$_\1_;t;s_.*__;'`
386 KERNEL_RELEASE=`uname -r | sed 's|smp\|enterprise\|bigmem\|hugemem||g'`
387 KERNEL_ARCH=`uname -m`
389 dnl check the config file and override KERNEL_ARCH
390 AS_CHECK_LINUX_CONFIG_OPTION(CONFIG_M386, KERNEL_ARCH=i386)
391 AS_CHECK_LINUX_CONFIG_OPTION(CONFIG_M586, KERNEL_ARCH=i586)
392 AS_CHECK_LINUX_CONFIG_OPTION(CONFIG_M686, KERNEL_ARCH=i686)
393 dnl for some reason the i686 bigmem config file has PENTIUM
394 AS_CHECK_LINUX_CONFIG_OPTION(CONFIG_MPENTIUMIII, KERNEL_ARCH=i686)
395 AS_CHECK_LINUX_CONFIG_OPTION(CONFIG_MK7, KERNEL_ARCH=athlon)
397 dnl check the config file and override KERNEL_TYPE
398 AS_CHECK_LINUX_CONFIG_OPTION(CONFIG_SMP, KERNEL_TYPE=smp)
399 dnl bigmem is also smp, so this check is done after smp to override
400 AS_CHECK_LINUX_CONFIG_OPTION(CONFIG_HIGHMEM64G, KERNEL_TYPE=bigmem)
402 dnl FIXME: need to check hugemem and enterprise config files, which
403 dnl aren't provided in Fedora Core 1 !
405 case "$KERNEL_TYPE" in
407 enterprise) ENTERPRISE='1';;
409 hugemem) HUGEMEM='1';;
412 REDHAT_CFLAGS="-D__MODULE_KERNEL_$KERNEL_ARCH=1"
413 REDHAT_CFLAGS="$REDHAT_CFLAGS -D__BOOT_KERNEL_ENTERPRISE=$ENTERPRISE"
414 REDHAT_CFLAGS="$REDHAT_CFLAGS -D__BOOT_KERNEL_UP=$UP"
415 REDHAT_CFLAGS="$REDHAT_CFLAGS -D__BOOT_KERNEL_SMP=$SMP"
416 REDHAT_CFLAGS="$REDHAT_CFLAGS -D__BOOT_KERNEL_BIGMEM=$BIGMEM"
417 REDHAT_CFLAGS="$REDHAT_CFLAGS -D__BOOT_KERNEL_HUGEMEM=$HUGEMEM"
419 LINUX_REDHAT_CFLAGS="$REDHAT_CFLAGS"
421 AC_SUBST(LINUX_KERNEL_TYPE, "$KERNEL_TYPE")
424 dnl add an argument to specify/override the module install path
425 dnl if nothing specified, it will be /lib/modules/(kernelrel)
426 AC_DEFUN([AS_LINUX_MODULESDIR],
429 AC_ARG_WITH([modulesdir],
430 [AC_HELP_STRING([--with-modulesdir=DIR],
431 [specify path to kernel-specific modules install directory])],
432 [MODULESDIR="${withval}"],
433 [MODULESDIR=default])
435 if test "${MODULESDIR}" = "default" ; then
436 MODULESDIR="/lib/modules/${KERNEL_RELEASE}"
438 dnl make it available to Makefiles so it can be used in ...dir
439 AC_SUBST(modulesdir, $MODULESDIR)
440 AC_MSG_NOTICE([Putting kernel modules under ${MODULESDIR}])
443 dnl add an argument to specify/override the module devel install path
444 dnl if nothing specified, it will be the passed in LINUXDIR)
445 AC_DEFUN([AS_LINUX_MODULESDEVELDIR],
448 AC_ARG_WITH([modulesdeveldir],
449 [AC_HELP_STRING([--with-modulesdeveldir=DIR],
450 [specify path to kernel-specific module development install directory])],
451 [MODULESDEVELDIR="${withval}"],
452 [MODULESDEVELDIR=default])
454 if test "${MODULESDEVELDIR}" = "default" ; then
455 MODULESDEVELDIR="${LINUXDIR}"
457 dnl make it available to Makefiles so it can be used in ...dir
458 AC_SUBST(modulesdeveldir, $MODULESDEVELDIR)
459 AC_MSG_NOTICE([Putting kernel module development files under ${MODULESDEVELDIR}])
462 AC_DEFUN([AS_LINUX_2_6],
464 AC_MSG_CHECKING(for Linux CFLAGS)
467 tmpdir=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
468 test -n "$tmpdir" && test -d "$tmpdir"
471 tmpdir=./confstat$$-$RANDOM
472 (umask 077 && mkdir $tmpdir)
475 echo "$me: cannot create a temporary directory in ." >&2
476 { (exit 1); exit 1; }
481 cat >${tmpdir}/Makefile <<EOF
484 \$(obj)/fake.c: flags
489 echo LINUX_ARCH=\"\$(ARCH)\" >>\$(obj)/flags
490 echo LINUX_AFLAGS=\"\$(AFLAGS)\" | sed 's,include,"\$(LINUXDIR)/include",g'>>\$(obj)/flags
491 echo LINUX_LDFLAGS=\"\" >>\$(obj)/flags
492 echo LINUX_ARFLAGS=\"\$(ARFLAGS)\" >>\$(obj)/flags
493 echo LINUX_CROSS_COMPILE=\"\$(CROSS_COMPILE)\" >>\$(obj)/flags
494 echo LINUX_KERNELRELEASE=\"\$(KERNELRELEASE)\" >>\$(obj)/flags
495 echo LINUX_CFLAGS=\"\$(CFLAGS) \$(CPPFLAGS)\" \
496 | sed -e 's,-Iinclude,-I\$(LINUXDIR)/include,g' -e 's,-include include,-include \$(LINUXDIR)/include,g' >>\$(obj)/flags
497 echo LINUX_CFLAGS_MODULE=\"\$(CFLAGS_MODULE)\" >>\$(obj)/flags
498 echo LINUX_CC=\"\$(CC)\" >>\$(obj)/flags
499 echo LINUX_LD=\"\$(LD) \$(LDFLAGS) \$(LDFLAGS_MODULE)\" >>\$(obj)/flags
500 echo LINUX_AS=\"\$(AS)\" >>\$(obj)/flags
503 echo ${MAKE-make} -C ${LINUX_DIR} V=1 SUBDIRS=${tmpdir} LINUXDIR=${LINUX_DIR} modules >&5 2>&5
504 ${MAKE-make} -C ${LINUX_DIR} V=1 SUBDIRS=${tmpdir} LINUXDIR=${LINUX_DIR} modules >&5 2>&5
508 LINUX_MODULE_EXT=".ko"
509 LINUX_MODULE_STYLE="2.6.6"
511 LINUX_CFLAGS="$LINUX_CFLAGS $LINUX_CFLAGS_MODULE"
514 AC_SUBST(LINUX_AFLAGS)
515 AC_SUBST(LINUX_LDFLAGS)
516 AC_SUBST(LINUX_ARFLAGS)
517 AC_SUBST(LINUX_CROSS_COMPILE)
518 AC_SUBST(LINUX_KERNELRELEASE)
519 AC_SUBST(LINUX_CFLAGS)
523 AC_SUBST(LINUX_MODULE_EXT)
524 AC_SUBST(LINUX_MODULE_STYLE)
525 AC_SUBST(LINUX_MODPOST)
527 AC_MSG_RESULT([$LINUX_CFLAGS])
529 AC_PATH_PROG([LINUX_MODPOST], ["modpost"], ["no"], ["$LINUX_DIR/scripts:$LINUX_DIR/scripts/mod"])
533 AC_DEFUN([AS_LINUX_2_4],
535 AC_MSG_CHECKING(for Linux 2.4 make flags)
536 dnl we try to figure out the CFLAGS by invoking the Makefile on
538 dnl we use the correct config file by substituting the MAKEFILES
539 dnl Makefile variable, which originally points to .config
541 if [[ ! -e "${LINUX_DIR}/.hdepend" ]];then
543 No .hdepend file found, you may need to run 'make dep' on the kernel source before continuing.])
547 tmpdir=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
548 test -n "$tmpdir" && test -d "$tmpdir"
551 tmpdir=./confstat$$-$RANDOM
552 (umask 077 && mkdir $tmpdir)
555 echo "$me: cannot create a temporary directory in ." >&2
556 { (exit 1); exit 1; }
560 #sed "s|\.config|${CONFIG_FILE}|g" ${LINUX_DIR}/Makefile >$tmpdir/Makefile
561 cat >$tmpdir/Makefile <<EOF
563 @echo LINUX_ARCH=\"\$(ARCH)\"
564 @echo LINUX_AFLAGS=\"\$(AFLAGS)\" | sed 's_Iinclude_I\"\$(LINUXDIR)/include\"_g'
565 @echo LINUX_LDFLAGS=\"\"
566 @echo LINUX_ARFLAGS=\"\$(ARFLAGS)\"
567 @echo LINUX_CROSS_COMPILE=\"\$(CROSS_COMPILE)\"
568 @echo LINUX_KERNELRELEASE=\"\$(KERNELRELEASE)\"
569 @echo LINUX_CFLAGS=\"\$(CFLAGS)\" | sed 's_Iinclude_I\"\$(LINUXDIR)/include\"_g'
570 @echo LINUX_MODFLAGS=\"\$(MODFLAGS)\"
571 @echo LINUX_CC=\"\$(CC)\"
572 @echo LINUX_LD=\"\$(LD) \$(LDFLAGS)\"
573 @echo LINUX_AS=\"\$(AS)\"
575 make -C ${LINUX_DIR} SUBDIRS=${tmpdir} modules | grep ^LINUX_ >${tmpdir}/ack
577 echo make modules with LINUX_DIR=$(LINUX_DIR) failed.
583 LINUX_MODULE_EXT=".o"
584 LINUX_MODULE_STYLE="2.4.0"
586 LINUX_CFLAGS="$LINUX_CFLAGS $LINUX_MODFLAGS"
588 dnl if we have REDHAT_CFLAGS, put them in LINUX_CFLAGS
589 if test "x$REDHAT_CFLAGS" != "x";
591 LINUX_CFLAGS="$LINUX_CFLAGS $REDHAT_CFLAGS"
594 AC_SUBST(LINUX_AFLAGS)
595 AC_SUBST(LINUX_LDFLAGS)
596 AC_SUBST(LINUX_ARFLAGS)
597 AC_SUBST(LINUX_CROSS_COMPILE)
598 AC_SUBST(LINUX_KERNELRELEASE)
599 AC_SUBST(LINUX_CFLAGS)
603 AC_SUBST(LINUX_MODULE_EXT)
604 AC_SUBST(LINUX_MODULE_STYLE)
608 AC_MSG_CHECKING(for Linux 2.4 CFLAGS)
609 AC_MSG_RESULT($LINUX_CFLAGS)
610 AC_MSG_CHECKING(for Linux 2.4 LDFLAGS)
611 AC_MSG_RESULT($LINUX_LDFLAGS)
614 AC_DEFUN([AS_CHECK_LINUX_CONFIG_OPTION],
616 AC_MSG_CHECKING([Linux config option $1])
618 if grep '^$1=y$' ${LINUX_CONFIG} >/dev/null 2>/dev/null; then
621 else if grep '^$1=m$' ${LINUX_CONFIG} >/dev/null 2>/dev/null; then
630 AC_MSG_RESULT([$result])
633 AC_DEFUN([AS_LINUX_CONFIG_OPTION],
635 AS_CHECK_LINUX_CONFIG_OPTION([$1],
640 AM_CONDITIONAL([$1],[test "${$1}" = yes])
643 AC_DEFUN([AS_LINUX_CONFIG_OPTION_MODULE],
645 AS_CHECK_LINUX_CONFIG_OPTION([$1],
650 AM_CONDITIONAL([$1],[test "${$1}" = yes -o "${$1}" = module])
653 dnl check for the major/minor version of the Linux source by checking
655 dnl first argument is the linux directory
656 dnl sets LINUX_VERSION_MAJOR and LINUX_VERSION_MINOR
657 AC_DEFUN([AS_LINUX_VERSION_MAJOR_MINOR],
660 AC_MSG_CHECKING([Linux major/minor version])
662 if [[ ! -f "${LINUX_DIR}/Makefile" ]];then
663 AC_MSG_ERROR([The Linux kernel Makefile does not exist.])
665 dnl the next set of tests is for figuring out version major/minor
666 dnl use VERSION and PATCHLEVEL in the kernel Makefile
667 LINUX_VERSION_MAJOR=`sed -n 's/^VERSION = \([[0-9]]*\)/\1/p' "${LINUX_DIR}/Makefile"`
668 LINUX_VERSION_MINOR=`sed -n 's/^PATCHLEVEL = \([[0-9]]*\)/\1/p' "${LINUX_DIR}/Makefile"`
669 if [[ -z "$LINUX_VERSION_MAJOR" -o -z "$LINUX_VERSION_MINOR" ]]; then
670 AC_MSG_ERROR([No major/minor version information found in Linux kernel Makefile.])
672 AC_MSG_RESULT($LINUX_VERSION_MAJOR.$LINUX_VERSION_MINOR)
675 # COMEDI_CHECK_LINUX_KBUILD([LINUX_SOURCE_PATH], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
676 # -------------------------------------------------------------
678 # Check if kernel source tree is recent enough to support "Kbuild" files.
679 AC_DEFUN([COMEDI_CHECK_LINUX_KBUILD],
681 AC_MSG_CHECKING([for Kbuild support in $1])
682 dnl For combined kernel source and build directory,
683 dnl if $1/scripts/Makefile.build refers to $(<something>)/Kbuild
684 dnl then we support Kbuild (2.6.10 onwards).
685 dnl For separate kernel source and build directory, if $1/Makefile
686 dnl contains KERNELOUTPUT variable then this is from a separate
687 dnl kernel build directory, so Kbuild is required
688 dnl (but it will not work prior to 2.6.10).
689 if grep -q '/Kbuild' "$1/scripts/Makefile.build" 2>/dev/null; then
692 else if grep -q '^KERNELOUTPUT *:=' "$1/Makefile" 2>/dev/null; then
702 # COMEDI_CHECK_PCMCIA_PROBE([LINUX_SOURCE_PATH], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
703 # -------------------------------------------------------------
705 # Check if kernel pcmcia support is new enough to have a probe member in the pcmcia_driver
707 AC_DEFUN([COMEDI_CHECK_PCMCIA_PROBE],
709 AC_REQUIRE([AC_PROG_EGREP])
710 AC_MSG_CHECKING([$1 for probe in pcmcia_driver struct])
711 cat "$1/include/pcmcia/ds.h" | tr \\n ' ' | [$EGREP "struct[[:space:]]+pcmcia_driver[[:space:]]*[{][^}]*probe"] > /dev/null