30de1c2db8662a931c651c57321741fe81896e32
[util-vserver.git] / m4 / ensc_dietlibc_compat.m4
1 dnl $Id: ensc_dietlibc_compat.m4,v 1.4 2005/04/24 20:28:23 ensc Exp $
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 AC_DEFUN([ENSC_DIETLIBC_NEED_COMPAT],
19 [
20         AC_REQUIRE([ENSC_ENABLE_DIETLIBC])
21         AC_REQUIRE([ENSC_SYSCALL_ALTERNATIVE])
22         AC_CACHE_CHECK([whether dietlibc needs '-lcompat'], [ensc_cv_c_dietlibc_compat],
23         [
24                 AC_LANG_PUSH(C)
25                 ensc_dietlibc_need_compat_old_CC=$CC
26                 CC="${DIET:-diet} $CC"
27                 AC_LINK_IFELSE([
28                         AC_LANG_PROGRAM([
29 #include "$srcdir/lib/syscall-wrap.h"
30 #include <errno.h>
31
32 #define __NR_foo0               42
33 #define __NR_foo1               42
34 #define __NR_foo2               42
35 #define __NR_foo3               42
36 #define __NR_foo4               42
37 #define __NR_foo5               42
38 inline static _syscall0(int, foo0)
39 inline static _syscall1(int, foo1, int, a)
40 inline static _syscall2(int, foo2, int, a, int, b)
41 inline static _syscall3(int, foo3, int, a, int, b, int, c)
42 inline static _syscall4(int, foo4, int, a, int, b, int, c, int, d)
43 inline static _syscall5(int, foo5, int, a, int, b, int, c, int, d, int, e)
44 ],
45                         [foo0(); foo1(0); foo2(0,0); foo3(0,0,0); foo4(0,0,0,0); foo5(0,0,0,0,0);])],
46                         [ensc_cv_c_dietlibc_compat=no],
47                         [ensc_cv_c_dietlibc_compat=yes])
48                 CC=$ensc_dietlibc_need_compat_old_CC
49                 AC_LANG_POP
50         ])
51
52         if test x"$1" != x; then
53                 AM_CONDITIONAL($1, test x"$ensc_cv_c_dietlibc_compat" = xyes)
54         fi
55 ])