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