gentoo: use /var/run for new /run compatibility
[util-vserver.git] / m4 / ensc_syscallnr.m4
1 dnl $Id$
2
3 dnl Copyright (C) 2004, 2005, 2009
4 dnl     Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
5 dnl
6 dnl This program is free software; you can redistribute it and/or modify
7 dnl it under the terms of the GNU General Public License as published by
8 dnl the Free Software Foundation; version 2 and/or 3 of the License.
9 dnl
10 dnl This program is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 dnl GNU General Public License for more details.
14 dnl
15 dnl You should have received a copy of the GNU General Public License
16 dnl along with this program; if not, write to the Free Software
17 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 dnl Usage: ENSC_SYSCALLNR(<syscall>,<default>[,<fallback>])
20
21 AC_DEFUN([ENSC_SYSCALLNR],
22 [
23         AC_REQUIRE([AC_PROG_CPP])
24         AC_REQUIRE([AC_PROG_EGREP])
25
26         AC_CACHE_CHECK([for number of syscall '$1'], [ensc_cv_value_syscall_$1],
27         [
28                 AC_LANG_PUSH(C)
29                 AC_LANG_CONFTEST([
30 #ifdef ENSC_SYSCALL_FALLBACK
31 #  include ENSC_SYSCALL_FALLBACK
32 #else
33 #  include <asm/unistd.h>
34 #endif
35 #ifdef __NR_$1
36 ensc_syscall_tmp_nr=__NR_$1;
37 ensc_syscall_tmp_src=ENSC_MARK
38 #endif
39 ])
40                 ensc_syscall_tmp_nr=
41                 ensc_syscall_tmp_src=
42                 test x"$ensc_syscall_tmp_nr" != x || \
43                         eval $($CPP $CPPFLAGS -D ENSC_MARK='glibc'                                    conftest.c | $EGREP '^ensc_syscall_tmp_(nr=[[1-9]][[0-9]]*;|src=.*)$')
44                 test x"$ensc_syscall_tmp_nr" != x -o x'$3' = x || \
45                         eval $($CPP $CPPFLAGS -D ENSC_MARK='fallback' -D ENSC_SYSCALL_FALLBACK='"$3"' conftest.c | $EGREP '^ensc_syscall_tmp_(nr=[[1-9]][[0-9]]*;|src=.*)$')
46                 test "$ensc_syscall_tmp_nr" || {
47                         ensc_syscall_tmp_nr=$2
48                         ensc_syscall_tmp_src=default
49                 }
50
51                 if test x"$ensc_syscall_tmp_nr" = x; then
52                         AC_MSG_ERROR(
53 [Can not determine value of __NR_$1; please verify your glibc/kernelheaders, and/or set CPPFLAGS='-D__NR_$1=<value>' environment when calling configure.])
54                 fi
55                 AC_LANG_POP
56
57                 ensc_cv_value_syscall_$1="$ensc_syscall_tmp_nr/$ensc_syscall_tmp_src"
58         ])
59
60         ensc_syscall_tmp_nr=${ensc_cv_value_syscall_$1%/*}
61         ensc_syscall_tmp_src=${ensc_cv_value_syscall_$1#*/}
62
63         if test x"$ensc_syscall_tmp_src" != x'glibc'; then
64                 AC_DEFINE_UNQUOTED(ENSC_SYSCALL__NR_$1, $ensc_syscall_tmp_nr, [The number of the $1 syscall])
65         fi
66 ])