*** empty log message ***
[arla.git] / cf / check-kernel.m4
blob52f2604c82764216920344d290b15a26f9d95011
1 dnl
2 dnl $Id$
3 dnl
5 dnl there are two different heuristics for doing the kernel tests
6 dnl a) running nm and greping the output
7 dnl b) trying linking against the kernel
9 dnl AC_CHECK_KERNEL(name, cv, magic, [includes])
10 AC_DEFUN([AC_CHECK_KERNEL],
11 [AC_MSG_CHECKING([for $1 in kernel])
12 AC_CACHE_VAL([$2],
14 if expr "$target_os" : "darwin" > /dev/null 2>&1; then
15   if nm $KERNEL | egrep "\\<_?$1\\>" >/dev/null 2>&1; then
16     eval "$2=yes"
17   else
18     eval "$2=no"
19   fi
20 elif expr "$target_os" : "osf" >/dev/null 2>&1; then
21   if nm  $KERNEL | egrep "^$1 " > /dev/null 2>&1; then
22     eval "$2=yes"
23   else
24     eval "$2=no"
25   fi
26 elif expr "$target_os" : "freebsd" >/dev/null 2>&1; then
27   if nm  $KERNEL | egrep "T $1" > /dev/null 2>&1; then
28     eval "$2=yes"
29   else
30     eval "$2=no"
31   fi
32 elif expr "$target_os" : "dragonfly" >/dev/null 2>&1; then
33   if nm  $KERNEL | egrep "T $1" > /dev/null 2>&1; then
34     eval "$2=yes"
35   else
36     eval "$2=no"
37   fi
38 elif expr "$target_os" : "netbsd" >/dev/null 2>&1; then
39   if nm  $KERNEL | egrep "T _?$1" > /dev/null 2>&1; then
40     eval "$2=yes"
41   else
42     eval "$2=no"
43   fi
44 else
45 cat > conftest.$ac_ext <<EOF
46 dnl This sometimes fails to find confdefs.h, for some reason.
47 dnl [#]line __oline__ "[$]0"
48 [#]line __oline__ "configure"
49 #include "confdefs.h"
51 int _foo() {
52 return foo();
54 int foo() {
55 $3;
56 return 0; }
57 EOF
58 save_CFLAGS="$CFLAGS"
59 CFLAGS="$CFLAGS $test_KERNEL_CFLAGS $KERNEL_CPPFLAGS"
60 if AC_TRY_EVAL(ac_compile) && AC_TRY_EVAL(ac_kernel_ld) && test -s conftest; then
61   eval "$2=yes"
62 else
63   eval "$2=no"
64   echo "configure: failed program was:" >&AC_FD_CC
65   cat conftest.$ac_ext >&AC_FD_CC
67 CFLAGS="$save_CFLAGS"
68 rm -f conftest*
69 fi])
71 eval ac_res=\$$2
72 AC_MSG_RESULT($ac_res)
73 if test "$ac_res" = yes; then
74   foo=HAVE_KERNEL_[]upcase($1)
75   AC_DEFINE_UNQUOTED($foo, 1)