This commit was generated by cvs2svn to compensate for changes in r2826,
[util-vserver.git] / m4 / ensc_kerneldir.m4
1 dnl $Id: ensc_kerneldir.m4,v 1.3 2004/02/14 01:20:35 ensc Exp $
2
3 dnl Copyright (C) 2002 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
4 dnl  
5 dnl This program is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; version 2 of the License.
8 dnl  
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl GNU General Public License for more details.
13 dnl  
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program; if not, write to the Free Software
16 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18 dnl Usage: ENSC_KERNEL_HEADERS(<var>)
19 dnl        <var> ... basedir of kernel-headers (without the '/linux');
20 dnl                  this value will be AC_SUBST'ed
21
22 AC_DEFUN([_ENSC_KERNEL_DIR],
23 [
24         AC_CACHE_CHECK([for linux kernel dir], [ensc_cv_path_kerneldir],
25         [
26 AC_ARG_WITH([kerneldir],
27             [AC_HELP_STRING([--with-kerneldir=DIR],
28                             [assume kernelsources in DIR (default: /lib/modules/<current>/build)])],
29             [case "$withval" in
30                 yes|no) AC_MSG_ERROR(['$withval' is not a valid value for kerneldir]);;
31                 *)      ensc_cv_path_kerneldir=$withval;;
32              esac],
33             [ensc_cv_path_kerneldir=
34              for i in /lib/modules/$(uname -r)/build /usr/src/linux /usr; do
35                 test -e $i/include/linux/version.h && { ensc_cv_path_kerneldir=$i; break; }
36              done])
37         ])
38
39         test "$ensc_cv_path_kerneldir" -a -e "$ensc_cv_path_kerneldir"/include/linux/version.h || {
40                 AC_MSG_ERROR([Can not find kernelsources])
41         }
42 ])
43
44 AC_DEFUN([ENSC_KERNEL_HEADERS],
45 [
46         AC_REQUIRE([_ENSC_KERNEL_DIR])
47
48         AC_CACHE_CHECK([for linux kernel headers], [ensc_cv_path_kernelheaders],
49         [
50                 ensc_cv_path_kernelheaders=$ensc_cv_path_kerneldir/include
51         ])
52
53         if test x"$1" != x; then
54                 $1=$ensc_cv_path_kernelheaders
55                 AC_SUBST($1)
56         fi
57 ])