minor cosmetical cleanups...
[util-vserver.git] / util-vserver / m4 / ensc_dietlibc.m4
1 dnl $Id$
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 AC_DEFUN([_ENSC_DIETLIBC_C99],
19 [
20         AH_TEMPLATE([ENSC_DIETLIBC_C99], [Define to 1 if dietlibc supports C99])
21
22         AC_CACHE_CHECK([whether dietlibc supports C99], [ensc_cv_c_dietlibc_c99],
23         [
24                 _ensc_dietlibc_c99_old_CFLAGS=$CFLAGS
25                 _ensc_dietlibc_c99_old_CC=$CC
26
27                 CFLAGS="-std=c99"
28                 CC="${DIET:-diet} $CC"
29
30                 AC_LANG_PUSH(C)
31                 AC_COMPILE_IFELSE([/* */],[
32                         AC_COMPILE_IFELSE([
33                                 #include <stdint.h>
34                                 #include <sys/cdefs.h>
35                                 #if defined(inline)
36                                 #  error 'inline' badly defined
37                                 #endif
38                                 volatile uint64_t       a;
39                         ],
40                         [ensc_cv_c_dietlibc_c99=yes],
41                         [ensc_cv_c_dietlibc_c99=no])],
42                         [ensc_cv_c_dietlibc_c99='skipped (compiler does not support C99)'])
43                 AC_LANG_POP
44
45                 CC=$_ensc_dietlibc_c99_old_CC
46                 CFLAGS=$_ensc_dietlibc_c99_old_CFLAGS
47         ])
48
49         if test x"$ensc_cv_c_dietlibc_c99" = xyes; then
50                 AC_DEFINE(ENSC_DIETLIBC_C99,1)
51         fi
52 ])
53
54 dnl Usage: ENSC_ENABLE_DIETLIBC(<conditional>)
55 dnl        <conditional> ... automake-conditional which will be set when
56 dnl                          dietlibc shall be enabled
57
58 AC_DEFUN([ENSC_ENABLE_DIETLIBC],
59 [
60         AC_MSG_CHECKING([whether to enable dietlibc])
61         AC_ARG_ENABLE([dietlibc],
62                       [AC_HELP_STRING([--disable-dietlibc],
63                                       [do not use dietlibc (default: use dietlibc)])],
64                       [case "$enableval" in
65                           yes)  use_dietlibc=forced;;
66                           no)   use_dietlibc=forced_no;;
67                           *)    AC_MSG_ERROR(['$enableval' is not a valid value for --enable-dietlibc]);;
68                        esac],
69                       [: ${DIET:=diet}
70                        which "$DIET" >/dev/null 2>/dev/null && use_dietlibc=detected || use_dietlibc=detected_no])
71
72         ensc_have_dietlibc=no
73         case x"$use_dietlibc" in
74             xdetected)
75                 AM_CONDITIONAL($1, true)
76                 AC_MSG_RESULT([yes (autodetected)])
77                 ensc_have_dietlibc=yes
78                 ;;
79             xforced)
80                 AM_CONDITIONAL($1, true)
81                 AC_MSG_RESULT([yes (forced)])
82                 ensc_have_dietlibc=yes
83                 ;;
84             xdetected_no)
85                 AM_CONDITIONAL($1, false)
86                 AC_MSG_RESULT([no (detected)])
87                 ;;
88             xforced_no)
89                 AM_CONDITIONAL($1, false)
90                 AC_MSG_RESULT([no (forced)])
91                 ;;
92             *)
93                 AC_MSG_ERROR([internal error, use_dietlibc was "$use_dietlibc"])
94                 ;;
95         esac
96
97         if test x"$ensc_have_dietlibc" != xno; then
98                 _ENSC_DIETLIBC_C99
99         fi
100 ])