Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / cf / linux-kernel-path.m4
1 AC_DEFUN([OPENAFS_LINUX_KERNEL_PATH],[
2 if test "x$with_linux_kernel_headers" != "x"; then
3 LINUX_KERNEL_PATH="$with_linux_kernel_headers"
4 else
5 for utsdir in "/lib/modules/`uname -r`/build" \
6 "/lib/modules/`uname -r`/source" \
7 "/usr/src/linux"; do
8 LINUX_KERNEL_PATH="$utsdir"
9 for utsfile in "include/generated/utsrelease.h" \
10 "include/linux/utsrelease.h" \
11 "include/linux/version.h" \
12 "include/linux/version-up.h"; do
13 if grep "UTS_RELEASE" "$utsdir/$utsfile" >/dev/null 2>&1; then
14 break 2
15 fi
16 done
17 done
18 fi
19 if test "x$with_linux_kernel_build" != "x"; then
20 LINUX_KERNEL_BUILD="$with_linux_kernel_build"
21 else
22 LINUX_KERNEL_BUILD=$LINUX_KERNEL_PATH
23 fi
24 if test -f "$LINUX_KERNEL_BUILD/include/generated/utsrelease.h"; then
25 linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/generated/utsrelease.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1`
26 LINUX_VERSION="$linux_kvers"
27 else
28 if test -f "$LINUX_KERNEL_BUILD/include/linux/utsrelease.h"; then
29 linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/linux/utsrelease.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1`
30 LINUX_VERSION="$linux_kvers"
31 else
32 if test -f "$LINUX_KERNEL_BUILD/include/linux/version.h"; then
33 linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/linux/version.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1`
34 if test "x$linux_kvers" = "x"; then
35 if test -f "$LINUX_KERNEL_BUILD/include/linux/version-up.h"; then
36 linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/linux/version-up.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1`
37 if test "x$linux_kvers" = "x"; then
38 AC_MSG_ERROR(Linux headers lack version definition [2])
39 exit 1
40 else
41 LINUX_VERSION="$linux_kvers"
42 fi
43 else
44 AC_MSG_ERROR(Linux headers lack version definition)
45 exit 1
46 fi
47 else
48 LINUX_VERSION="$linux_kvers"
49 fi
50 else
51 enable_kernel_module="no"
52 fi
53 fi
54 fi
55 if test ! -f "$LINUX_KERNEL_BUILD/include/generated/autoconf.h" &&
56 test ! -f "$LINUX_KERNEL_BUILD/include/linux/autoconf.h"; then
57 enable_kernel_module="no"
58 fi
59 if test "x$enable_kernel_module" = "xno"; then
60 if test "x$with_linux_kernel_headers" != "x"; then
61 AC_MSG_ERROR(No usable linux headers found at $LINUX_KERNEL_PATH)
62 exit 1
63 else
64 AC_MSG_WARN(No usable linux headers found at $LINUX_KERNEL_PATH so disabling kernel module)
65 fi
66 fi
67 dnl do we need to determine SUBARCH from autoconf.h
68 SUBARCH=default
69 ])