7deea944f884b85d212b99df012216689e32eb21
[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], [
5   rm -fr conftest.dir
6   if mkdir conftest.dir; then
7   cd conftest.dir
8     cat >Makefile <<_ACEOF
9 CFLAGS += $CPPFLAGS
10
11 obj-m += conftest.o
12 _ACEOF
13     cat >conftest.c <<\_ACEOF
14 #include <linux/module.h>
15 $1
16
17 void conftest(void)
18
19 $2
20
21
22 MODULE_LICENSE("http://www.openafs.org/dl/license10.html");
23 _ACEOF
24     cd ..
25   fi
26   AS_IF(AC_RUN_LOG([make -C $LINUX_KERNEL_PATH M=`pwd`/conftest.dir modules > /dev/null]),
27       [$3], [$4])
28   rm -fr conftest.dir])
29
30   
31 # AC_TRY_KBUILD24([INCLUDES], [FUNCTION-BODY],
32 #                 [ACTION-IF-SUCCESS], [ACTION-IF-FAILURE])
33 #
34 AC_DEFUN([AC_TRY_KBUILD24], [
35   ac_save_CPPFLAGS="$CPPFLAGS"
36   CPPFLAGS="-I$LINUX_KERNEL_PATH/include -D__KERNEL__ $CPPFLAGS"
37   AC_TRY_COMPILE([$1], [$2], [$3], [$4])
38   CPPFLAGS="$ac_save_CPPFLAGS"])
39
40
41 # AC_TRY_KBUILD([INCLUDES], [FUNCTION-BODY],
42 #               [ACTION-IF-SUCCESS], [ACTION-IF-FAILURE])
43 #
44 AC_DEFUN([AC_TRY_KBUILD], [
45   if test -f $LINUX_KERNEL_PATH/scripts/Makefile.build; then
46     AC_TRY_KBUILD26([$1], [$2], [$3], [$4])
47   else
48     AC_TRY_KBUILD24([$1], [$2], [$3], [$4])
49   fi])