use $(LIBENSCVECTOR) instead of libensc_vector.a
[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>[,<min-version>])
55 dnl        <conditional> ... automake-conditional which will be set when
56 dnl                          dietlibc shall be enabled
57 dnl        provides:
58 dnl        * $ENSC_VERSION_DIETLIBC_NUM and
59 dnl        * $ENSC_VERSION_DIETLIBC
60
61 AC_DEFUN([ENSC_ENABLE_DIETLIBC],
62 [
63         AC_MSG_CHECKING([whether to enable dietlibc])
64         AC_ARG_ENABLE([dietlibc],
65                       [AC_HELP_STRING([--disable-dietlibc],
66                                       [do not use dietlibc (default: use dietlibc)])],
67                       [case "$enableval" in
68                           yes)  use_dietlibc=forced;;
69                           no)   use_dietlibc=forced_no;;
70                           *)    AC_MSG_ERROR(['$enableval' is not a valid value for --enable-dietlibc]);;
71                        esac],
72                       [: ${DIET:=diet}
73                        which "$DIET" >/dev/null 2>/dev/null && use_dietlibc=detected || use_dietlibc=detected_no])
74
75         if test "$use_dietlibc" = detected -a '$2'; then
76             _dietlibc_ver=$(${DIET:-diet} -v 2>&1 | sed '1p;d')
77             _dietlibc_ver=${_dietlibc_ver##*diet version }
78             _dietlibc_ver=${_dietlibc_ver##*dietlibc-}
79             _dietlibc_ver_maj=${_dietlibc_ver%%.*}
80             _dietlibc_ver_min=${_dietlibc_ver##*.}
81             _dietlibc_ver_min=${_dietlibc_ver_min%%[[!0-9]]*}
82             _dietlibc_cmp=$2
83             _dietlibc_cmp_maj=${_dietlibc_cmp%%.*}
84             _dietlibc_cmp_min=${_dietlibc_cmp##*.}
85
86             ENSC_VERSION_DIETLIBC=$_dietlibc_ver_maj.$_dietlibc_ver_min
87
88             let _dietlibc_ver=_dietlibc_ver_maj*1000+_dietlibc_ver_min 2>/dev/null || _dietlibc_ver=0
89             let _dietlibc_cmp=_dietlibc_cmp_maj*1000+_dietlibc_cmp_min
90
91             test $_dietlibc_ver -ge $_dietlibc_cmp || use_dietlibc=detected_old
92         else
93             ENSC_VERSION_DIETLIBC=
94             _dietlibc_ver=-1
95         fi
96
97         ENSC_VERSION_DIETLIBC_NUM=$_dietlibc_ver
98         ensc_have_dietlibc=no
99
100         case x"$use_dietlibc" in
101             xdetected)
102                 AM_CONDITIONAL($1, true)
103                 AC_MSG_RESULT([yes (autodetected, $ENSC_VERSION_DIETLIBC)])
104                 ensc_have_dietlibc=yes
105                 ;;
106             xforced)
107                 AM_CONDITIONAL($1, true)
108                 AC_MSG_RESULT([yes (forced)])
109                 ensc_have_dietlibc=yes
110                 ;;
111             xdetected_no)
112                 AM_CONDITIONAL($1, false)
113                 AC_MSG_RESULT([no (detected)])
114                 ;;
115             xdetected_old)
116                 AM_CONDITIONAL($1, false)
117                 AC_MSG_RESULT([no (too old; $2+ required, $ENSC_VERSION_DIETLIBC found)])
118                 ;;
119             xforced_no)
120                 AM_CONDITIONAL($1, false)
121                 AC_MSG_RESULT([no (forced)])
122                 ;;
123             *)
124                 AC_MSG_ERROR([internal error, use_dietlibc was "$use_dietlibc"])
125                 ;;
126         esac
127
128         if test x"$ensc_have_dietlibc" != xno; then
129                 _ENSC_DIETLIBC_C99
130         fi
131 ])
132
133
134 dnl Usage: ENSC_DIETLIBC_SANITYCHECK
135 AC_DEFUN([ENSC_DIETLIBC_SANITYCHECK],
136 [
137         AC_REQUIRE([AC_CANONICAL_HOST])
138         AC_REQUIRE([ENSC_ENABLE_DIETLIBC])
139
140         if test "$host_cpu" = x86_64 -a $ENSC_VERSION_DIETLIBC_NUM -le 0027; then
141                 AC_MSG_WARN([***                                                             ***])
142                 AC_MSG_WARN([*** dietlibc<=0.27 is known to be broken for x86_64 systems     ***])
143                 AC_MSG_WARN([*** please make sure that at least the environ.S fix is applied ***])
144                 AC_MSG_WARN([*** and lib/__nice.c added                                      ***])
145                 AC_MSG_WARN([***                                                             ***])
146         fi
147 ])