DEVEL15-linux-2624-20071123
[openafs.git] / src / cf / linux-test1.m4
1 # AC_TRY_KBUILD26([INCLUDES], [FUNCTION-BODY],
2 #                 [ACTION-IF-SUCCESS], [ACTION-IF-FAILURE])
3 #
4 AC_DEFUN([AC_TRY_KBUILD26],[  rm -fr conftest.dir
5   if test "x$ac_linux_kbuild_requires_extra_cflags" = "xyes" ; then
6     CFLAGS_PREFIX='EXTRA_'
7   fi
8   if mkdir conftest.dir &&
9     cat >conftest.dir/Makefile <<_ACEOF &&
10 ${CFLAGS_PREFIX}CFLAGS += $CPPFLAGS
11
12 obj-m += conftest.o
13 _ACEOF
14     cat >conftest.dir/conftest.c <<\_ACEOF &&
15 /* confdefs.h */
16 _ACEOF
17     cat confdefs.h >>conftest.dir/conftest.c &&
18     cat >>conftest.dir/conftest.c <<\_ACEOF &&
19 /* end confdefs.h */
20 #include <linux/module.h>
21 $1
22
23 void conftest(void)
24
25 $2
26
27
28 MODULE_LICENSE("http://www.openafs.org/dl/license10.html");
29 _ACEOF
30     echo make -C $LINUX_KERNEL_PATH M=$SRCDIR_PARENT/conftest.dir modules KBUILD_VERBOSE=1 >&AS_MESSAGE_LOG_FD
31     make -C $LINUX_KERNEL_PATH M=$SRCDIR_PARENT/conftest.dir modules KBUILD_VERBOSE=1 >&AS_MESSAGE_LOG_FD 2>conftest.err
32     then [$3]
33     else
34       sed '/^ *+/d' conftest.err >&AS_MESSAGE_LOG_FD
35       echo "$as_me: failed using Makefile:" >&AS_MESSAGE_LOG_FD
36       sed 's/^/| /' conftest.dir/Makefile >&AS_MESSAGE_LOG_FD
37       echo "$as_me: and program was:" >&AS_MESSAGE_LOG_FD
38       sed 's/^/| /' conftest.dir/conftest.c >&AS_MESSAGE_LOG_FD
39       [$4]
40   fi; rm -fr conftest.err conftest.dir])
41
42   
43 # AC_TRY_KBUILD24([INCLUDES], [FUNCTION-BODY],
44 #                 [ACTION-IF-SUCCESS], [ACTION-IF-FAILURE])
45 #
46 AC_DEFUN([AC_TRY_KBUILD24], [
47   ac_save_CPPFLAGS="$CPPFLAGS"
48   CPPFLAGS="-I$LINUX_KERNEL_PATH/include -D__KERNEL__ $CPPFLAGS"
49   AC_TRY_COMPILE([$1], [$2], [$3], [$4])
50   CPPFLAGS="$ac_save_CPPFLAGS"])
51
52
53 # AC_TRY_KBUILD([INCLUDES], [FUNCTION-BODY],
54 #               [ACTION-IF-SUCCESS], [ACTION-IF-FAILURE])
55 #
56 AC_DEFUN([AC_TRY_KBUILD], [
57   if test $AFS_SYSKVERS -ge 26 ; then
58     AC_TRY_KBUILD26([$1], [$2], [$3], [$4])
59   else
60     AC_TRY_KBUILD24([$1], [$2], [$3], [$4])
61   fi])
62
63 AC_DEFUN([LINUX_KERNEL_COMPILE_WORKS], [
64   AC_MSG_CHECKING([for linux kernel module build works])
65   AC_TRY_KBUILD(
66 [#include <linux/sched.h>
67 #include <linux/fs.h>],
68     [],:,AC_MSG_RESULT(no)
69     AC_MSG_FAILURE([Fix problem or use --disable-kernel-module...]))
70   AC_MSG_RESULT(yes)])
71
72 AC_DEFUN([LINUX_KBUILD_USES_EXTRA_CFLAGS], [
73   AC_MSG_CHECKING([if linux kbuild requires EXTRA_CFLAGS])
74   save_CPPFLAGS="$CPPFLAGS"
75   CPPFLAGS=-Wall
76   AC_TRY_KBUILD(
77 [#include <linux/sched.h>
78 #include <linux/fs.h>],
79     [],
80     ac_linux_kbuild_requires_extra_cflags=no,
81     ac_linux_kbuild_requires_extra_cflags=yes)
82     CPPFLAGS="$save_CPPFLAGS"
83     AC_MSG_RESULT($ac_linux_kbuild_requires_extra_cflags)])