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