fixed auto-case
[util-vserver.git] / util-vserver / m4 / ensc_syscallnr.m4
1 dnl $Id$
2
3 dnl Copyright (C) 2004 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_SYSCALLNR(<syscall>,<default>)
19
20 AC_DEFUN([ENSC_SYSCALLNR],
21 [
22         AC_REQUIRE([ENSC_KERNEL_HEADERS])
23         AC_REQUIRE([AC_PROG_EGREP])
24
25         AC_CACHE_CHECK([for number of syscall '$1'], [ensc_cv_value_syscall_$1],
26         [
27                 AC_LANG_PUSH(C)
28                 AC_EGREP_CPP(ensc_cv_value_syscall_$1=auto, [
29 #include <asm/unistd.h>
30 #ifdef __NR_$1
31 ensc_cv_value_syscall_$1=auto
32 #endif
33 ],
34                         [ensc_cv_value_syscall_$1=auto], [
35                         AC_LANG_CONFTEST([
36 #include <asm/unistd.h>
37 #ifdef __NR_$1
38 ensc_cv_value_syscall_$1=__NR_$1
39 #else
40 ensc_cv_value_syscall_$1=$2
41 #endif
42 ])
43                         eval $($CPP $CPPFLAGS -I$ensc_cv_path_kernelheaders conftest.c | $EGREP -x 'ensc_cv_value_syscall_$1=[[1-9]][[0-9]]*')
44                         if test x"$ensc_cv_value_syscall_$1" = x; then
45                                 AC_MSG_ERROR(
46 [Can not determine value of __NR_$1; please verify your glibc/kernelheaders, and/or set CPPFLAGS='-D=__NR_$1=<value>' environment when calling configure.])
47                         fi
48                 ])
49                 AC_LANG_POP
50         ])
51
52         if test x"$ensc_cv_value_syscall_$1" != xauto; then
53                 AC_DEFINE_UNQUOTED(ENSC_SYSCALL__NR_$1, $ensc_cv_value_syscall_$1, [The number of the $1 syscall])
54         fi
55 ])