Imported Upstream version 2.5.2p1
[debian/amanda] / config / acinclude.m4i
1 dnl Check if the compiler can handle unsigned long constants, ie 2ul.
2 AC_DEFUN([AMANDA_C_UNSIGNED_LONG_CONSTANTS],
3     [
4         AC_CACHE_CHECK(
5             [for working unsigned long constants],
6             amanda_cv_c_unsigned_long_constants,
7             [
8                 AC_TRY_COMPILE(
9                     [
10                     ],
11                     [
12                         long l = 1ul;
13                     ],
14                     amanda_cv_c_unsigned_long_constants=yes,
15                     amanda_cv_c_unsigned_long_constants=no
16                 )
17             ]
18         )
19         if test "$amanda_cv_c_unsigned_long_constants" = yes; then
20             AC_DEFINE(HAVE_UNSIGNED_LONG_CONSTANTS,1,[Define if the compiler support unsigned long constants. ])
21         fi
22     ]
23 )
24
25 dnl Check for the argument type for shmat() and shmdt()
26 AC_DEFUN([AMANDA_FUNC_SHM_ARG_TYPE],
27     [
28         AC_CACHE_CHECK(
29             [for shmdt() argument type],
30             amanda_cv_shmdt_arg_type,
31             [
32                 if test "$ac_cv_func_shmget" = yes; then
33                     cat <<EOF >conftest.$ac_ext
34 #include "confdefs.h"
35 #ifdef HAVE_SYS_TYPES_H
36 # include <sys/types.h>
37 #endif
38 #ifdef HAVE_SYS_IPC_H
39 # include <sys/ipc.h>
40 #endif
41 #ifdef HAVE_SYS_SHM_H
42 # include <sys/shm.h>
43 #endif
44
45 #ifdef __cplusplus
46 extern "C" void *shmat(int, void *, int);
47 #else
48 void *shmat();
49 #endif
50
51 int main()
52 {
53     int i;
54     return 0;
55 }
56 EOF
57                     ${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext >/dev/null 2>/dev/null
58                     if test $? = 0; then
59                         amanda_cv_shmdt_arg_type=void
60                     else
61                         amanda_cv_shmdt_arg_type=char
62                     fi
63                     rm -f conftest*
64                 else
65                     amanda_cv_shmdt_arg_type=nothing
66                 fi
67             ]
68         )
69         AC_DEFINE_UNQUOTED(SHM_ARG_TYPE,$amanda_cv_shmdt_arg_type,[Define to type of shmget() function argument. ])
70     ]
71 )
72
73 dnl Figure out the select() argument type.
74 AC_DEFUN([AMANDA_FUNC_SELECT_ARG_TYPE],
75     [
76         AC_CACHE_CHECK(
77             [for select() argument type],
78             amanda_cv_select_arg_type,
79             [
80                 rm -f conftest.c
81                 cat <<EOF >conftest.$ac_ext
82 #include "confdefs.h"
83 #ifdef HAVE_SYS_TIME_H
84 # include <sys/time.h>
85 #endif
86 #ifdef HAVE_SYS_TYPES_H
87 # include <sys/types.h>
88 #endif
89 #ifdef HAVE_SYS_SELECT_H
90 #  include <sys/select.h>
91 #endif
92 #ifdef HAVE_SYS_SOCKET_H
93 #  include <sys/socket.h>
94 #endif
95 #ifdef HAVE_UNISTD_H
96 # include <unistd.h>
97 #endif
98
99 int main()
100 {
101 #ifdef FD_SET_POINTER
102         (void)select(0, (fd_set *) 0, (fd_set *) 0, (fd_set *) 0, 0);
103 #else
104         (void)select(0, (int *) 0, (int *) 0, (int *) 0, 0);
105 #endif
106         return 0;
107 }
108 EOF
109
110                 dnl Figure out the select argument type by first trying to
111                 dnl compile with the fd_set argument.  If the compile fails,
112                 dnl then we know to use the int.  If it suceeds, then try to
113                 dnl use the int.  If the int fails, then use fd_set.  If
114                 dnl both suceeed, then do a line count on the number of
115                 dnl lines that the compiler spit out, assuming that the
116                 dnl compile outputing more lines had more errors.
117                 amanda_cv_select_arg_type=no
118                 select_compile="${CC-cc} -c $CFLAGS $CPPFLAGS"
119                 $select_compile -DFD_SET_POINTER conftest.$ac_ext 1>conftest.fd_set 2>&1
120                 if test $? -ne 0; then
121                     amanda_cv_select_arg_type=int
122                 fi
123                 if test "$amanda_cv_select_arg_type" = no; then
124                     $select_compile conftest.$ac_ext 1>conftest.int 2>&1
125                     if test $? -ne 0; then
126                         amanda_cv_select_arg_type=fd_set
127                     fi
128                 fi
129                 if test "$amanda_cv_select_arg_type" = no; then
130                     wc_fdset=`wc -l <conftest.fd_set`
131                     wc_int=`wc -l <conftest.int`
132                     if test "$wc_fdset" -le "$wc_int"; then
133                         amanda_cv_select_arg_type=fd_set
134                     else
135                         amanda_cv_select_arg_type=int
136                     fi
137                 fi
138                 rm -f conftest*
139             ]
140         )
141         AC_DEFINE_UNQUOTED(SELECT_ARG_TYPE,$amanda_cv_select_arg_type,[Define to type of select arguments. ])
142     ]
143 )
144
145 dnl Check if setsockopt can use the SO_SNDTIMEO option.
146 dnl This defines HAVE_SO_SNDTIMEO if setsockopt works
147 dnl with SO_SNDTIMEO.
148 AC_DEFUN([AMANDA_FUNC_SETSOCKOPT_SO_SNDTIMEO],
149     [
150         AC_CACHE_CHECK(
151             [for setsockopt SO_SNDTIMEO option],
152             amanda_cv_setsockopt_SO_SNDTIMEO,
153             [
154                 AC_TRY_RUN(
155                     [
156 #include <sys/types.h>
157 #include <sys/socket.h>
158 #ifdef TIME_WITH_SYS_TIME
159 #  include <sys/time.h>
160 #  include <time.h>
161 #else
162 #  ifdef HAVE_SYS_TIME_H
163 #    include <sys/time.h>
164 #  else
165 #    include <time.h>
166 #  endif
167 #endif
168
169 main() {
170 #ifdef SO_SNDTIMEO
171     int sock = socket(AF_INET, SOCK_STREAM, 0);
172     struct timeval timeout;
173     timeout.tv_sec = 1;
174     timeout.tv_usec = 0;
175     return (setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO,
176              (void *)&timeout, sizeof(timeout)));
177 #else
178     return -1;
179 #endif
180 }
181                     ],
182                     amanda_cv_setsockopt_SO_SNDTIMEO=yes,
183                     amanda_cv_setsockopt_SO_SNDTIMEO=no,
184                     amanda_cv_setsockopt_SO_SNDTIMEO=no
185                 )
186             ]
187         )
188         if test "$amanda_cv_setsockopt_SO_SNDTIMEO" = yes; then
189             AC_DEFINE(HAVE_SO_SNDTIMEO,1,[Define if SO_SNDTIMEO is available. ])
190         fi
191     ]
192 )
193
194 dnl Check for the one or two argument version of gettimeofday.
195 AC_DEFUN([AMANDA_FUNC_GETTIMEOFDAY_ARGS],
196     [
197         AC_REQUIRE([AC_HEADER_TIME])
198         AC_CACHE_CHECK(
199             [for gettimeofday number of arguments],
200             amanda_cv_gettimeofday_args,
201             [
202                 AC_TRY_COMPILE(
203                     [
204 #ifdef TIME_WITH_SYS_TIME
205 #  include <sys/time.h>
206 #  include <time.h>
207 #else
208 #  ifdef HAVE_SYS_TIME_H
209 #    include <sys/time.h>
210 #  else
211 #    include <time.h>
212 #  endif
213 #endif
214                     ],
215                     [
216                         struct timeval val;
217                         struct timezone zone;
218                         gettimeofday(&val, &zone);
219                     ],
220                     amanda_cv_gettimeofday_args=2,
221                     amanda_cv_gettimeofday_args=1
222                 )
223             ]
224         )
225         if test "$amanda_cv_gettimeofday_args" = 2; then
226             AC_DEFINE(HAVE_TWO_ARG_GETTIMEOFDAY,1,[Define if gettimeofday takes two arguments. ])
227         fi
228     ]
229 )
230
231
232
233 dnl Check for if pid_t is a long, int, or short.
234 AC_DEFUN([AMANDA_TYPE_PID_T],
235     [
236         AC_REQUIRE([AC_TYPE_PID_T])
237         AC_CACHE_CHECK([for pid_t type], amanda_cv_pid_type,
238             [
239                 amanda_cv_pid_type=unknown
240                 if test "$ac_cv_type_pid_t" = no; then
241                     amanda_cv_pid_type=int
242                 fi
243                 for TEST_amanda_cv_pid_type in long short int; do
244                     if test $amanda_cv_pid_type = unknown; then
245                         AC_EGREP_CPP(typedef.*${TEST_amanda_cv_pid_type}.*pid_t,
246                             [
247 #include <sys/types.h>
248 #if STDC_HEADERS
249 #include <stdlib.h>
250 #include <stddef.h>
251 #endif
252                             ],
253                         amanda_cv_pid_type=$TEST_amanda_cv_pid_type)
254                     fi
255                     if test $amanda_cv_pid_type = unknown; then
256                         AC_EGREP_CPP(ZZZZ.*${TEST_amanda_cv_pid_type},
257                             [
258 #include <sys/types.h>
259 #if STDC_HEADERS
260 #include <stdlib.h>
261 #include <stddef.h>
262 #endif
263                                 ZZZZ pid_t
264                         ],
265                         amanda_cv_pid_type=$TEST_amanda_cv_pid_type)
266                     fi
267                 done
268                 if test $amanda_cv_pid_type = unknown; then
269                     amanda_cv_pid_type=int
270                 fi
271             ]
272         )
273         case $amanda_cv_pid_type in
274             int)        AC_DEFINE_UNQUOTED(PRINTF_PID_T,"%d",[Define to printf formatting string to print a PID. ]) ;;
275             long)       AC_DEFINE_UNQUOTED(PRINTF_PID_T,"%ld") ;;
276             short)      AC_DEFINE_UNQUOTED(PRINTF_PID_T,"%d") ;;
277         esac
278     ]
279 )
280
281 dnl
282 dnl
283 dnl ICE_CHECK_DECL (FUNCTION, HEADER-FILE...)
284 dnl If FUNCTION is available, define `HAVE_FUNCTION'.  If it is declared
285 dnl in one of the headers named in the whitespace-separated list 
286 dnl HEADER_FILE, define `HAVE_FUNCTION_DECL` (in all capitals).
287 dnl
288 AC_DEFUN([ICE_CHECK_DECL],
289 [
290 ice_have_$1=no
291 AC_CHECK_FUNCS($1, ice_have_$1=yes)
292 if test "${ice_have_$1}" = yes; then
293 AC_MSG_CHECKING(for $1 declaration in $2)
294 AC_CACHE_VAL(ice_cv_have_$1_decl,
295 [
296 ice_cv_have_$1_decl=no
297 changequote(,)dnl
298 ice_re_params='[a-zA-Z_][a-zA-Z0-9_]*'
299 ice_re_word='(^|[^a-zA-Z0-9_])'
300 changequote([,])dnl
301 for header in $2; do
302 # Check for ordinary declaration
303 AC_EGREP_HEADER([${ice_re_word}$1[      ]*\(], $header, 
304         ice_cv_have_$1_decl=yes)
305 if test "$ice_cv_have_$1_decl" = yes; then
306         break
307 fi
308 # Check for "fixed" declaration like "getpid _PARAMS((int))"
309 AC_EGREP_HEADER([${ice_re_word}$1[      ]*$ice_re_params\(\(], $header, 
310         ice_cv_have_$1_decl=yes)
311 if test "$ice_cv_have_$1_decl" = yes; then
312         break
313 fi
314 done
315 ])
316 AC_MSG_RESULT($ice_cv_have_$1_decl)
317 if test "$ice_cv_have_$1_decl" = yes; then
318 AC_DEFINE_UNQUOTED([HAVE_]translit($1,[a-z],[A-Z])[_DECL],1,[Define if $1 is declared. ])
319 fi
320 fi
321 ])dnl
322 dnl Test for the presence of <sys/wait.h>, 'union wait', arg-type of 'wait()'.
323 dnl by T.E.Dickey" , Jim Spath <jspath@mail.bcpl.lib.md.us>
324 dnl
325 dnl     FIXME: These tests should have been in autoconf 1.11!
326 dnl
327 dnl     Note that we cannot simply grep for 'union wait' in the wait.h file,
328 dnl     because some Posix systems turn this on only when a BSD variable is
329 dnl     defined. Since I'm trying to do without special defines, I'll live
330 dnl     with the default behavior of the include-file.
331 dnl
332 dnl     I do _2_ compile checks, because we may have union-wait, but the
333 dnl     prototype for 'wait()' may want an int.
334 dnl
335 dnl     Don't use HAVE_UNION_WAIT, because the autoconf documentation implies
336 dnl     that if we've got union-wait, we'll automatically use it.
337 dnl
338 dnl Garrett Wollman adds:
339 dnl     The tests described above don't quite do the right thing,
340 dnl     since some systems have hacks which allow `union wait' to
341 dnl     still work even though `int' is preferred (and generates
342 dnl     fewer warnings).  Since all of these systems use prototypes,
343 dnl     we can use the prototype of wait(2) to disambiguate them.
344 dnl
345 dnl Alexandre Oliva adds:
346 dnl     A single compile check is enough.  If we don't have union wait,
347 dnl     it's obvious that the test will fail, and that we must use int.
348 dnl     If we do, the prototype (on STDC systems) and WIFEXITED will tell
349 dnl     whether we're supposed to be using union wait instead of int.
350 dnl
351 AC_DEFUN([CF_WAIT],
352 [
353 AC_REQUIRE([AC_TYPE_PID_T])
354 AC_HAVE_HEADERS(sys/wait.h wait.h)
355 AC_CACHE_CHECK([whether wait uses union wait], [cf_cv_arg_union_wait],
356         [AC_TRY_COMPILE([
357 #include <sys/types.h>
358
359 #if HAVE_SYS_WAIT_H
360 # include <sys/wait.h>
361 #else
362 # if HAVE_WAIT_H
363 #  include <wait.h>
364 # endif
365 #endif
366
367 #ifdef __STDC__
368 pid_t wait(union wait *);
369 #endif
370 ], [
371   union wait x; int i;
372   wait(&x); i = WIFEXITED(x)
373 ], [cf_cv_arg_union_wait=yes], [cf_cv_arg_union_wait=no])])
374 if test $cf_cv_arg_union_wait = yes; then
375         AC_DEFINE(WAIT_USES_UNION,1,[Defined if wait() puts the status in a union wait instead of int. ])
376 fi
377 ])dnl
378 AC_DEFUN([CF_WAIT_INT],
379 [
380 AC_REQUIRE([AC_TYPE_PID_T])
381 AC_HAVE_HEADERS(sys/wait.h wait.h)
382 AC_CACHE_CHECK([whether wait uses int], [cf_cv_arg_int],
383         [AC_TRY_COMPILE([
384 #include <sys/types.h>
385
386 #if HAVE_SYS_WAIT_H
387 # include <sys/wait.h>
388 #else
389 # if HAVE_WAIT_H
390 #  include <wait.h>
391 # endif
392 #endif
393
394 #ifdef __STDC__
395 pid_t wait(int *);
396 #endif
397 ], [
398   int x; int i;
399   wait(&x); i = WIFEXITED(x)
400 ], [cf_cv_arg_int=yes], [cf_cv_arg_int=no])])
401 if test $cf_cv_arg_int = yes; then
402         AC_DEFINE(WAIT_USES_INT,1,[Defined if wait() puts the status in a int instead of a union wait. ])
403 fi
404 ])dnl
405
406 dnl @synopsis AX_CREATE_STDINT_H [( HEADER-TO-GENERATE [, HEDERS-TO-CHECK])]
407 dnl
408 dnl the "ISO C9X: 7.18 Integer types <stdint.h>" section requires the
409 dnl existence of an include file <stdint.h> that defines a set of 
410 dnl typedefs, especially uint8_t,int32_t,uintptr_t.
411 dnl Many older installations will not provide this file, but some will
412 dnl have the very same definitions in <inttypes.h>. In other enviroments
413 dnl we can use the inet-types in <sys/types.h> which would define the
414 dnl typedefs int8_t and u_int8_t respectivly.
415 dnl
416 dnl This macros will create a local "_stdint.h" or the headerfile given as 
417 dnl an argument. In many cases that file will just "#include <stdint.h>" 
418 dnl or "#include <inttypes.h>", while in other environments it will provide 
419 dnl the set of basic 'stdint's definitions/typedefs: 
420 dnl   int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t
421 dnl   int_least32_t.. int_fast32_t.. intmax_t
422 dnl which may or may not rely on the definitions of other files,
423 dnl or using the AC_CHECK_SIZEOF macro to determine the actual
424 dnl sizeof each type.
425 dnl
426 dnl if your header files require the stdint-types you will want to create an
427 dnl installable file mylib-int.h that all your other installable header
428 dnl may include. So if you have a library package named "mylib", just use
429 dnl      AX_CREATE_STDINT_H(mylib-int.h) 
430 dnl in configure.ac and go to install that very header file in Makefile.am
431 dnl along with the other headers (mylib.h) - and the mylib-specific headers
432 dnl can simply use "#include <mylib-int.h>" to obtain the stdint-types.
433 dnl
434 dnl Remember, if the system already had a valid <stdint.h>, the generated
435 dnl file will include it directly. No need for fuzzy HAVE_STDINT_H things...
436 dnl
437 dnl @, (status: used on new platforms) (see http://ac-archive.sf.net/gstdint/)
438 dnl @version Id: ax_create_stdint_h.m4,v 1.5 2005/01/06 18:27:27 guidod Exp
439 dnl @author  Guido Draheim <guidod@gmx.de> 
440
441 AC_DEFUN([AX_CHECK_DATA_MODEL],[
442    AC_CHECK_SIZEOF(char)
443    AC_CHECK_SIZEOF(short)
444    AC_CHECK_SIZEOF(int)
445    AC_CHECK_SIZEOF(long)
446    AC_CHECK_SIZEOF(void*)
447    ac_cv_char_data_model=""
448    ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_char"
449    ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_short"
450    ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_int"
451    ac_cv_long_data_model=""
452    ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_int"
453    ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_long"
454    ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_voidp"
455    AC_MSG_CHECKING([data model])
456    case "$ac_cv_char_data_model/$ac_cv_long_data_model" in
457     122/242)     ac_cv_data_model="IP16"  ; n="standard 16bit machine" ;;
458     122/244)     ac_cv_data_model="LP32"  ; n="standard 32bit machine" ;;
459     122/*)       ac_cv_data_model="i16"   ; n="unusual int16 model" ;;
460     124/444)     ac_cv_data_model="ILP32" ; n="standard 32bit unixish" ;;
461     124/488)     ac_cv_data_model="LP64"  ; n="standard 64bit unixish" ;;
462     124/448)     ac_cv_data_model="LLP64" ; n="unusual 64bit unixish" ;;
463     124/*)       ac_cv_data_model="i32"   ; n="unusual int32 model" ;;
464     128/888)     ac_cv_data_model="ILP64" ; n="unusual 64bit numeric" ;;
465     128/*)       ac_cv_data_model="i64"   ; n="unusual int64 model" ;;         
466     222/*2)      ac_cv_data_model="DSP16" ; n="strict 16bit dsptype" ;;
467     333/*3)      ac_cv_data_model="DSP24" ; n="strict 24bit dsptype" ;;
468     444/*4)      ac_cv_data_model="DSP32" ; n="strict 32bit dsptype" ;;
469     666/*6)      ac_cv_data_model="DSP48" ; n="strict 48bit dsptype" ;;
470     888/*8)      ac_cv_data_model="DSP64" ; n="strict 64bit dsptype" ;;
471     222/*|333/*|444/*|666/*|888/*) :
472                  ac_cv_data_model="iDSP"  ; n="unusual dsptype" ;;
473      *)          ac_cv_data_model="none"  ; n="very unusual model" ;;
474    esac
475    AC_MSG_RESULT([$ac_cv_data_model ($ac_cv_long_data_model, $n)])
476 ])
477
478 dnl AX_CHECK_HEADER_STDINT_X([HEADERLIST][,ACTION-IF])
479 AC_DEFUN([AX_CHECK_HEADER_STDINT_X],[
480 AC_CACHE_CHECK([for stdint uintptr_t], [ac_cv_header_stdint_x],[
481  ac_cv_header_stdint_x="" # the 1997 typedefs (inttypes.h)
482   AC_MSG_RESULT([(..)])
483   for i in m4_ifval([$1],[$1],[stdint.h inttypes.h sys/inttypes.h]) ; do
484    unset ac_cv_type_uintptr_t 
485    unset ac_cv_type_uint64_t
486    AC_CHECK_TYPE(uintptr_t,[ac_cv_header_stdint_x=$i],continue,[#include <$i>])
487    AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
488    m4_ifvaln([$1],[$1]) break
489   done
490   AC_MSG_CHECKING([for stdint uintptr_t])
491  ])
492 ])
493
494 AC_DEFUN([AX_CHECK_HEADER_STDINT_O],[
495 AC_CACHE_CHECK([for stdint uint32_t], [ac_cv_header_stdint_o],[
496  ac_cv_header_stdint_o="" # the 1995 typedefs (sys/inttypes.h)
497   AC_MSG_RESULT([(..)])
498   for i in m4_ifval([$1],[$1],[inttypes.h sys/inttypes.h stdint.h]) ; do
499    unset ac_cv_type_uint32_t
500    unset ac_cv_type_uint64_t
501    AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],continue,[#include <$i>])
502    AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
503    m4_ifvaln([$1],[$1]) break
504    break;
505   done
506   AC_MSG_CHECKING([for stdint uint32_t])
507  ])
508 ])
509
510 AC_DEFUN([AX_CHECK_HEADER_STDINT_U],[
511 AC_CACHE_CHECK([for stdint u_int32_t], [ac_cv_header_stdint_u],[
512  ac_cv_header_stdint_u="" # the BSD typedefs (sys/types.h)
513   AC_MSG_RESULT([(..)])
514   for i in m4_ifval([$1],[$1],[sys/types.h inttypes.h sys/inttypes.h]) ; do
515    unset ac_cv_type_u_int32_t
516    unset ac_cv_type_u_int64_t
517    AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],continue,[#include <$i>])
518    AC_CHECK_TYPE(u_int64_t,[and64="/u_int64_t"],[and64=""],[#include<$i>])
519    m4_ifvaln([$1],[$1]) break
520    break;
521   done
522   AC_MSG_CHECKING([for stdint u_int32_t])
523  ])
524 ])
525
526 AC_DEFUN([AX_CREATE_STDINT_H],
527 [# ------ AX CREATE STDINT H -------------------------------------
528 AC_MSG_CHECKING([for stdint types])
529 ac_stdint_h=`echo ifelse($1, , _stdint.h, $1)`
530 # try to shortcircuit - if the default include path of the compiler
531 # can find a "stdint.h" header then we assume that all compilers can.
532 AC_CACHE_VAL([ac_cv_header_stdint_t],[
533 old_CXXFLAGS="$CXXFLAGS" ; CXXFLAGS=""
534 old_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS=""
535 old_CFLAGS="$CFLAGS"     ; CFLAGS=""
536 AC_TRY_COMPILE([#include <stdint.h>],[int_least32_t v = 0;],
537 [ac_cv_stdint_result="(assuming C99 compatible system)"
538  ac_cv_header_stdint_t="stdint.h"; ],
539 [ac_cv_header_stdint_t=""])
540 CXXFLAGS="$old_CXXFLAGS"
541 CPPFLAGS="$old_CPPFLAGS"
542 CFLAGS="$old_CFLAGS" ])
543
544 v="... $ac_cv_header_stdint_h"
545 if test "$ac_stdint_h" = "stdint.h" ; then
546  AC_MSG_RESULT([(are you sure you want them in ./stdint.h?)])
547 elif test "$ac_stdint_h" = "inttypes.h" ; then
548  AC_MSG_RESULT([(are you sure you want them in ./inttypes.h?)])
549 elif test "_$ac_cv_header_stdint_t" = "_" ; then
550  AC_MSG_RESULT([(putting them into $ac_stdint_h)$v])
551 else
552  ac_cv_header_stdint="$ac_cv_header_stdint_t"
553  AC_MSG_RESULT([$ac_cv_header_stdint (shortcircuit)])
554 fi
555
556 if test "_$ac_cv_header_stdint_t" = "_" ; then # can not shortcircuit..
557
558 dnl .....intro message done, now do a few system checks.....
559 dnl btw, all old CHECK_TYPE macros do automatically "DEFINE" a type, 
560 dnl therefore we use the autoconf implementation detail CHECK_TYPE_NEW 
561 dnl instead that is triggered with 3 or more arguments (see types.m4)
562
563 inttype_headers=`echo $2 | sed -e 's/,/ /g'`
564
565 ac_cv_stdint_result="(no helpful system typedefs seen)"
566 AX_CHECK_HEADER_STDINT_X(dnl
567    stdint.h inttypes.h sys/inttypes.h $inttype_headers,
568    ac_cv_stdint_result="(seen uintptr_t$and64 in $i)")
569
570 if test "_$ac_cv_header_stdint_x" = "_" ; then
571 AX_CHECK_HEADER_STDINT_O(dnl,
572    inttypes.h sys/inttypes.h stdint.h $inttype_headers,
573    ac_cv_stdint_result="(seen uint32_t$and64 in $i)")
574 fi
575
576 if test "_$ac_cv_header_stdint_x" = "_" ; then
577 if test "_$ac_cv_header_stdint_o" = "_" ; then
578 AX_CHECK_HEADER_STDINT_U(dnl,
579    sys/types.h inttypes.h sys/inttypes.h $inttype_headers,
580    ac_cv_stdint_result="(seen u_int32_t$and64 in $i)")
581 fi fi
582
583 dnl if there was no good C99 header file, do some typedef checks...
584 if test "_$ac_cv_header_stdint_x" = "_" ; then
585    AC_MSG_CHECKING([for stdint datatype model])
586    AC_MSG_RESULT([(..)])
587    AX_CHECK_DATA_MODEL
588 fi
589
590 if test "_$ac_cv_header_stdint_x" != "_" ; then
591    ac_cv_header_stdint="$ac_cv_header_stdint_x"
592 elif  test "_$ac_cv_header_stdint_o" != "_" ; then
593    ac_cv_header_stdint="$ac_cv_header_stdint_o"
594 elif  test "_$ac_cv_header_stdint_u" != "_" ; then
595    ac_cv_header_stdint="$ac_cv_header_stdint_u"
596 else
597    ac_cv_header_stdint="stddef.h"
598 fi
599
600 AC_MSG_CHECKING([for extra inttypes in chosen header])
601 AC_MSG_RESULT([($ac_cv_header_stdint)])
602 dnl see if int_least and int_fast types are present in _this_ header.
603 unset ac_cv_type_int_least32_t
604 unset ac_cv_type_int_fast32_t
605 AC_CHECK_TYPE(int_least32_t,,,[#include <$ac_cv_header_stdint>])
606 AC_CHECK_TYPE(int_fast32_t,,,[#include<$ac_cv_header_stdint>])
607 AC_CHECK_TYPE(intmax_t,,,[#include <$ac_cv_header_stdint>])
608
609 fi # shortcircut to system "stdint.h"
610 # ------------------ PREPARE VARIABLES ------------------------------
611 if test "$GCC" = "yes" ; then
612 ac_cv_stdint_message="using gnu compiler "`$CC --version | head -1` 
613 else
614 ac_cv_stdint_message="using $CC"
615 fi
616
617 AC_MSG_RESULT([make use of $ac_cv_header_stdint in $ac_stdint_h dnl
618 $ac_cv_stdint_result])
619
620 dnl -----------------------------------------------------------------
621 # ----------------- DONE inttypes.h checks START header -------------
622 AC_CONFIG_COMMANDS([$ac_stdint_h],[
623 AC_MSG_NOTICE(creating $ac_stdint_h : $_ac_stdint_h)
624 ac_stdint=$tmp/_stdint.h
625
626 echo "#ifndef" $_ac_stdint_h >$ac_stdint
627 echo "#define" $_ac_stdint_h "1" >>$ac_stdint
628 echo "#ifndef" _GENERATED_STDINT_H >>$ac_stdint
629 echo "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdint
630 echo "/* generated $ac_cv_stdint_message */" >>$ac_stdint
631 if test "_$ac_cv_header_stdint_t" != "_" ; then 
632 echo "#define _STDINT_HAVE_STDINT_H" "1" >>$ac_stdint
633 echo "#include <stdint.h>" >>$ac_stdint
634 echo "#endif" >>$ac_stdint
635 echo "#endif" >>$ac_stdint
636 else
637
638 cat >>$ac_stdint <<STDINT_EOF
639
640 /* ................... shortcircuit part ........................... */
641
642 #if defined HAVE_STDINT_H || defined _STDINT_HAVE_STDINT_H
643 #include <stdint.h>
644 #else
645 #include <stddef.h>
646
647 /* .................... configured part ............................ */
648
649 STDINT_EOF
650
651 echo "/* whether we have a C99 compatible stdint header file */" >>$ac_stdint
652 if test "_$ac_cv_header_stdint_x" != "_" ; then
653   ac_header="$ac_cv_header_stdint_x"
654   echo "#define _STDINT_HEADER_INTPTR" '"'"$ac_header"'"' >>$ac_stdint
655 else
656   echo "/* #undef _STDINT_HEADER_INTPTR */" >>$ac_stdint
657 fi
658
659 echo "/* whether we have a C96 compatible inttypes header file */" >>$ac_stdint
660 if  test "_$ac_cv_header_stdint_o" != "_" ; then
661   ac_header="$ac_cv_header_stdint_o"
662   echo "#define _STDINT_HEADER_UINT32" '"'"$ac_header"'"' >>$ac_stdint
663 else
664   echo "/* #undef _STDINT_HEADER_UINT32 */" >>$ac_stdint
665 fi
666
667 echo "/* whether we have a BSD compatible inet types header */" >>$ac_stdint
668 if  test "_$ac_cv_header_stdint_u" != "_" ; then
669   ac_header="$ac_cv_header_stdint_u"
670   echo "#define _STDINT_HEADER_U_INT32" '"'"$ac_header"'"' >>$ac_stdint
671 else
672   echo "/* #undef _STDINT_HEADER_U_INT32 */" >>$ac_stdint
673 fi
674
675 echo "" >>$ac_stdint
676
677 if test "_$ac_header" != "_" ; then if test "$ac_header" != "stddef.h" ; then
678   echo "#include <$ac_header>" >>$ac_stdint
679   echo "" >>$ac_stdint
680 fi fi
681
682 echo "/* which 64bit typedef has been found */" >>$ac_stdint
683 if test "$ac_cv_type_uint64_t" = "yes" ; then
684 echo "#define   _STDINT_HAVE_UINT64_T" "1"  >>$ac_stdint
685 else
686 echo "/* #undef _STDINT_HAVE_UINT64_T */" >>$ac_stdint
687 fi
688 if test "$ac_cv_type_u_int64_t" = "yes" ; then
689 echo "#define   _STDINT_HAVE_U_INT64_T" "1"  >>$ac_stdint
690 else
691 echo "/* #undef _STDINT_HAVE_U_INT64_T */" >>$ac_stdint
692 fi
693 echo "" >>$ac_stdint
694
695 echo "/* which type model has been detected */" >>$ac_stdint
696 if test "_$ac_cv_char_data_model" != "_" ; then
697 echo "#define   _STDINT_CHAR_MODEL" "$ac_cv_char_data_model" >>$ac_stdint
698 echo "#define   _STDINT_LONG_MODEL" "$ac_cv_long_data_model" >>$ac_stdint
699 else
700 echo "/* #undef _STDINT_CHAR_MODEL // skipped */" >>$ac_stdint
701 echo "/* #undef _STDINT_LONG_MODEL // skipped */" >>$ac_stdint
702 fi
703 echo "" >>$ac_stdint
704
705 echo "/* whether int_least types were detected */" >>$ac_stdint
706 if test "$ac_cv_type_int_least32_t" = "yes"; then
707 echo "#define   _STDINT_HAVE_INT_LEAST32_T" "1"  >>$ac_stdint
708 else
709 echo "/* #undef _STDINT_HAVE_INT_LEAST32_T */" >>$ac_stdint
710 fi
711 echo "/* whether int_fast types were detected */" >>$ac_stdint
712 if test "$ac_cv_type_int_fast32_t" = "yes"; then
713 echo "#define   _STDINT_HAVE_INT_FAST32_T" "1" >>$ac_stdint
714 else
715 echo "/* #undef _STDINT_HAVE_INT_FAST32_T */" >>$ac_stdint
716 fi
717 echo "/* whether intmax_t type was detected */" >>$ac_stdint
718 if test "$ac_cv_type_intmax_t" = "yes"; then
719 echo "#define   _STDINT_HAVE_INTMAX_T" "1" >>$ac_stdint
720 else
721 echo "/* #undef _STDINT_HAVE_INTMAX_T */" >>$ac_stdint
722 fi
723 echo "" >>$ac_stdint
724
725   cat >>$ac_stdint <<STDINT_EOF
726 /* .................... detections part ............................ */
727
728 /* whether we need to define bitspecific types from compiler base types */
729 #ifndef _STDINT_HEADER_INTPTR
730 #ifndef _STDINT_HEADER_UINT32
731 #ifndef _STDINT_HEADER_U_INT32
732 #define _STDINT_NEED_INT_MODEL_T
733 #else
734 #define _STDINT_HAVE_U_INT_TYPES
735 #endif
736 #endif
737 #endif
738
739 #ifdef _STDINT_HAVE_U_INT_TYPES
740 #undef _STDINT_NEED_INT_MODEL_T
741 #endif
742
743 #ifdef  _STDINT_CHAR_MODEL
744 #if     _STDINT_CHAR_MODEL+0 == 122 || _STDINT_CHAR_MODEL+0 == 124
745 #ifndef _STDINT_BYTE_MODEL
746 #define _STDINT_BYTE_MODEL 12
747 #endif
748 #endif
749 #endif
750
751 #ifndef _STDINT_HAVE_INT_LEAST32_T
752 #define _STDINT_NEED_INT_LEAST_T
753 #endif
754
755 #ifndef _STDINT_HAVE_INT_FAST32_T
756 #define _STDINT_NEED_INT_FAST_T
757 #endif
758
759 #ifndef _STDINT_HEADER_INTPTR
760 #define _STDINT_NEED_INTPTR_T
761 #ifndef _STDINT_HAVE_INTMAX_T
762 #define _STDINT_NEED_INTMAX_T
763 #endif
764 #endif
765
766
767 /* .................... definition part ............................ */
768
769 /* some system headers have good uint64_t */
770 #ifndef _HAVE_UINT64_T
771 #if     defined _STDINT_HAVE_UINT64_T  || defined HAVE_UINT64_T
772 #define _HAVE_UINT64_T
773 #elif   defined _STDINT_HAVE_U_INT64_T || defined HAVE_U_INT64_T
774 #define _HAVE_UINT64_T
775 typedef u_int64_t uint64_t;
776 #endif
777 #endif
778
779 #ifndef _HAVE_UINT64_T
780 /* .. here are some common heuristics using compiler runtime specifics */
781 #if defined __STDC_VERSION__ && defined __STDC_VERSION__ >= 199901L
782 #define _HAVE_UINT64_T
783 #define _HAVE_LONGLONG_UINT64_T
784 typedef long long int64_t;
785 typedef unsigned long long uint64_t;
786
787 #elif !defined __STRICT_ANSI__
788 #if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__
789 #define _HAVE_UINT64_T
790 typedef __int64 int64_t;
791 typedef unsigned __int64 uint64_t;
792
793 #elif defined __GNUC__ || defined __MWERKS__ || defined __ELF__
794 /* note: all ELF-systems seem to have loff-support which needs 64-bit */
795 #if !defined _NO_LONGLONG
796 #define _HAVE_UINT64_T
797 #define _HAVE_LONGLONG_UINT64_T
798 typedef long long int64_t;
799 typedef unsigned long long uint64_t;
800 #endif
801
802 #elif defined __alpha || (defined __mips && defined _ABIN32)
803 #if !defined _NO_LONGLONG
804 #define _HAVE_UINT64_T
805 typedef long int64_t;
806 typedef unsigned long uint64_t;
807 #endif
808   /* compiler/cpu type to define int64_t */
809 #endif
810 #endif
811 #endif
812
813 #if defined _STDINT_HAVE_U_INT_TYPES
814 /* int8_t int16_t int32_t defined by inet code, redeclare the u_intXX types */
815 typedef u_int8_t uint8_t;
816 typedef u_int16_t uint16_t;
817 typedef u_int32_t uint32_t;
818
819 /* glibc compatibility */
820 #ifndef __int8_t_defined
821 #define __int8_t_defined
822 #endif
823 #endif
824
825 #ifdef _STDINT_NEED_INT_MODEL_T
826 /* we must guess all the basic types. Apart from byte-adressable system, */
827 /* there a few 32-bit-only dsp-systems that we guard with BYTE_MODEL 8-} */
828 /* (btw, those nibble-addressable systems are way off, or so we assume) */
829
830 dnl   /* have a look at "64bit and data size neutrality" at */
831 dnl   /* http://unix.org/version2/whatsnew/login_64bit.html */
832 dnl   /* (the shorthand "ILP" types always have a "P" part) */
833
834 #if defined _STDINT_BYTE_MODEL
835 #if _STDINT_LONG_MODEL+0 == 242
836 /* 2:4:2 =  IP16 = a normal 16-bit system                */
837 typedef unsigned char   uint8_t;
838 typedef unsigned short  uint16_t;
839 typedef unsigned long   uint32_t;
840 #ifndef __int8_t_defined
841 #define __int8_t_defined
842 typedef          char    int8_t;
843 typedef          short   int16_t;
844 typedef          long    int32_t;
845 #endif
846 #elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL == 444
847 /* 2:4:4 =  LP32 = a 32-bit system derived from a 16-bit */
848 /* 4:4:4 = ILP32 = a normal 32-bit system                */
849 typedef unsigned char   uint8_t;
850 typedef unsigned short  uint16_t;
851 typedef unsigned int    uint32_t;
852 #ifndef __int8_t_defined
853 #define __int8_t_defined
854 typedef          char    int8_t;
855 typedef          short   int16_t;
856 typedef          int     int32_t;
857 #endif
858 #elif _STDINT_LONG_MODEL+0 == 484 || _STDINT_LONG_MODEL+0 == 488
859 /* 4:8:4 =  IP32 = a 32-bit system prepared for 64-bit    */
860 /* 4:8:8 =  LP64 = a normal 64-bit system                 */
861 typedef unsigned char   uint8_t;
862 typedef unsigned short  uint16_t;
863 typedef unsigned int    uint32_t;
864 #ifndef __int8_t_defined
865 #define __int8_t_defined
866 typedef          char    int8_t;
867 typedef          short   int16_t;
868 typedef          int     int32_t;
869 #endif
870 /* this system has a "long" of 64bit */
871 #ifndef _HAVE_UINT64_T
872 #define _HAVE_UINT64_T
873 typedef unsigned long   uint64_t;
874 typedef          long    int64_t;
875 #endif
876 #elif _STDINT_LONG_MODEL+0 == 448
877 /*      LLP64   a 64-bit system derived from a 32-bit system */
878 typedef unsigned char   uint8_t;
879 typedef unsigned short  uint16_t;
880 typedef unsigned int    uint32_t;
881 #ifndef __int8_t_defined
882 #define __int8_t_defined
883 typedef          char    int8_t;
884 typedef          short   int16_t;
885 typedef          int     int32_t;
886 #endif
887 /* assuming the system has a "long long" */
888 #ifndef _HAVE_UINT64_T
889 #define _HAVE_UINT64_T
890 #define _HAVE_LONGLONG_UINT64_T
891 typedef unsigned long long uint64_t;
892 typedef          long long  int64_t;
893 #endif
894 #else
895 #define _STDINT_NO_INT32_T
896 #endif
897 #else
898 #define _STDINT_NO_INT8_T
899 #define _STDINT_NO_INT32_T
900 #endif
901 #endif
902
903 /*
904  * quote from SunOS-5.8 sys/inttypes.h:
905  * Use at your own risk.  As of February 1996, the committee is squarely
906  * behind the fixed sized types; the "least" and "fast" types are still being
907  * discussed.  The probability that the "fast" types may be removed before
908  * the standard is finalized is high enough that they are not currently
909  * implemented.
910  */
911
912 #if defined _STDINT_NEED_INT_LEAST_T
913 typedef  int8_t    int_least8_t;
914 typedef  int16_t   int_least16_t;
915 typedef  int32_t   int_least32_t;
916 #ifdef _HAVE_UINT64_T
917 typedef  int64_t   int_least64_t;
918 #endif
919
920 typedef uint8_t   uint_least8_t;
921 typedef uint16_t  uint_least16_t;
922 typedef uint32_t  uint_least32_t;
923 #ifdef _HAVE_UINT64_T
924 typedef uint64_t  uint_least64_t;
925 #endif
926   /* least types */
927 #endif
928
929 #if defined _STDINT_NEED_INT_FAST_T
930 typedef  int8_t    int_fast8_t; 
931 typedef  int       int_fast16_t;
932 typedef  int32_t   int_fast32_t;
933 #ifdef _HAVE_UINT64_T
934 typedef  int64_t   int_fast64_t;
935 #endif
936
937 typedef uint8_t   uint_fast8_t; 
938 typedef unsigned  uint_fast16_t;
939 typedef uint32_t  uint_fast32_t;
940 #ifdef _HAVE_UINT64_T
941 typedef uint64_t  uint_fast64_t;
942 #endif
943   /* fast types */
944 #endif
945
946 #ifdef _STDINT_NEED_INTMAX_T
947 #ifdef _HAVE_UINT64_T
948 typedef  int64_t       intmax_t;
949 typedef uint64_t      uintmax_t;
950 #else
951 typedef          long  intmax_t;
952 typedef unsigned long uintmax_t;
953 #endif
954 #endif
955
956 #ifdef _STDINT_NEED_INTPTR_T
957 #ifndef __intptr_t_defined
958 #define __intptr_t_defined
959 /* we encourage using "long" to store pointer values, never use "int" ! */
960 #if   _STDINT_LONG_MODEL+0 == 242 || _STDINT_LONG_MODEL+0 == 484
961 typedef  unsinged int   uintptr_t;
962 typedef           int    intptr_t;
963 #elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL+0 == 444
964 typedef  unsigned long  uintptr_t;
965 typedef           long   intptr_t;
966 #elif _STDINT_LONG_MODEL+0 == 448 && defined _HAVE_UINT64_T
967 typedef        uint64_t uintptr_t;
968 typedef         int64_t  intptr_t;
969 #else /* matches typical system types ILP32 and LP64 - but not IP16 or LLP64 */
970 typedef  unsigned long  uintptr_t;
971 typedef           long   intptr_t;
972 #endif
973 #endif
974 #endif
975
976 /* The ISO C99 standard specifies that in C++ implementations these
977    should only be defined if explicitly requested.  */
978 #if !defined __cplusplus || defined __STDC_CONSTANT_MACROS
979 #ifndef UINT32_C
980
981 /* Signed.  */
982 # define INT8_C(c)      c
983 # define INT16_C(c)     c
984 # define INT32_C(c)     c
985 # ifdef _HAVE_LONGLONG_UINT64_T
986 #  define INT64_C(c)    c ## L
987 # else
988 #  define INT64_C(c)    c ## LL
989 # endif
990
991 /* Unsigned.  */
992 # define UINT8_C(c)     c ## U
993 # define UINT16_C(c)    c ## U
994 # define UINT32_C(c)    c ## U
995 # ifdef _HAVE_LONGLONG_UINT64_T
996 #  define UINT64_C(c)   c ## UL
997 # else
998 #  define UINT64_C(c)   c ## ULL
999 # endif
1000
1001 /* Maximal type.  */
1002 # ifdef _HAVE_LONGLONG_UINT64_T
1003 #  define INTMAX_C(c)   c ## L
1004 #  define UINTMAX_C(c)  c ## UL
1005 # else
1006 #  define INTMAX_C(c)   c ## LL
1007 #  define UINTMAX_C(c)  c ## ULL
1008 # endif
1009
1010   /* literalnumbers */
1011 #endif
1012 #endif
1013
1014 /* These limits are merily those of a two complement byte-oriented system */
1015
1016 /* Minimum of signed integral types.  */
1017 # define INT8_MIN               (-128)
1018 # define INT16_MIN              (-32767-1)
1019 # define INT32_MIN              (-2147483647-1)
1020 # define INT64_MIN              (-__INT64_C(9223372036854775807)-1)
1021 /* Maximum of signed integral types.  */
1022 # define INT8_MAX               (127)
1023 # define INT16_MAX              (32767)
1024 # define INT32_MAX              (2147483647)
1025 # define INT64_MAX              (__INT64_C(9223372036854775807))
1026
1027 /* Maximum of unsigned integral types.  */
1028 # define UINT8_MAX              (255)
1029 # define UINT16_MAX             (65535)
1030 # define UINT32_MAX             (4294967295U)
1031 # define UINT64_MAX             (__UINT64_C(18446744073709551615))
1032
1033 /* Minimum of signed integral types having a minimum size.  */
1034 # define INT_LEAST8_MIN         INT8_MIN
1035 # define INT_LEAST16_MIN        INT16_MIN
1036 # define INT_LEAST32_MIN        INT32_MIN
1037 # define INT_LEAST64_MIN        INT64_MIN
1038 /* Maximum of signed integral types having a minimum size.  */
1039 # define INT_LEAST8_MAX         INT8_MAX
1040 # define INT_LEAST16_MAX        INT16_MAX
1041 # define INT_LEAST32_MAX        INT32_MAX
1042 # define INT_LEAST64_MAX        INT64_MAX
1043
1044 /* Maximum of unsigned integral types having a minimum size.  */
1045 # define UINT_LEAST8_MAX        UINT8_MAX
1046 # define UINT_LEAST16_MAX       UINT16_MAX
1047 # define UINT_LEAST32_MAX       UINT32_MAX
1048 # define UINT_LEAST64_MAX       UINT64_MAX
1049
1050   /* shortcircuit*/
1051 #endif
1052   /* once */
1053 #endif
1054 #endif
1055 STDINT_EOF
1056 fi
1057     if cmp -s $ac_stdint_h $ac_stdint 2>/dev/null; then
1058       AC_MSG_NOTICE([$ac_stdint_h is unchanged])
1059     else
1060       ac_dir=`AS_DIRNAME(["$ac_stdint_h"])`
1061       AS_MKDIR_P(["$ac_dir"])
1062       rm -f $ac_stdint_h
1063       mv $ac_stdint $ac_stdint_h
1064     fi
1065 ],[# variables for create stdint.h replacement
1066 PACKAGE="$PACKAGE"
1067 VERSION="$VERSION"
1068 ac_stdint_h="$ac_stdint_h"
1069 _ac_stdint_h=AS_TR_CPP(_$PACKAGE-$ac_stdint_h)
1070 ac_cv_stdint_message="$ac_cv_stdint_message"
1071 ac_cv_header_stdint_t="$ac_cv_header_stdint_t"
1072 ac_cv_header_stdint_x="$ac_cv_header_stdint_x"
1073 ac_cv_header_stdint_o="$ac_cv_header_stdint_o"
1074 ac_cv_header_stdint_u="$ac_cv_header_stdint_u"
1075 ac_cv_type_uint64_t="$ac_cv_type_uint64_t"
1076 ac_cv_type_u_int64_t="$ac_cv_type_u_int64_t"
1077 ac_cv_char_data_model="$ac_cv_char_data_model"
1078 ac_cv_long_data_model="$ac_cv_long_data_model"
1079 ac_cv_type_int_least32_t="$ac_cv_type_int_least32_t"
1080 ac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t"
1081 ac_cv_type_intmax_t="$ac_cv_type_intmax_t"
1082 ])
1083 ])
1084
1085 # AC_PROG_XSLTPROC
1086 # -----------------------------------------------------------------
1087 # Find an xsltproc executable.
1088 #
1089 # Input:
1090 #  $1 is the default $XSLTPROC_FLAGS, which will be overridden if the
1091 #  user specifies --with-xsltproc-flags.
1092 # Output:
1093 #  $XSLTPROC contains the path to xsltproc, or is empty if none was
1094 #  found or the user specified --without-xsltproc. $XSLTPROC_FLAGS 
1095 #  contains the flags to use with xsltproc.
1096
1097 AC_DEFUN([AC_PROG_XSLTPROC],
1098 [
1099 XSLTPROC_FLAGS="$1"
1100 AC_SUBST(XSLTPROC_FLAGS)
1101
1102 # The (lack of) whitespace and overquoting here are all necessary for
1103 # proper formatting.
1104 AC_ARG_WITH(xsltproc,
1105 AS_HELP_STRING([--with-xsltproc[[[[[=PATH]]]]]],
1106                [Use the xsltproc binary in in PATH.]),
1107     [ ac_with_xsltproc=$withval; ],
1108     [ ac_with_xsltproc=maybe; ])
1109
1110 AC_ARG_WITH(xsltproc-flags,
1111 AS_HELP_STRING([  --with-xsltproc-flags=FLAGS],
1112                [Flags to pass to xsltproc (default $1)]),
1113     [ if test "x$withval" == "xno"; then
1114         XSLTPROC_FLAGS=''
1115     else
1116         if test "x$withval" != "xyes"; then
1117             XSLTPROC_FLAGS="$withval"
1118         fi
1119     fi
1120         ])
1121
1122 # search for xsltproc if it wasn't specified
1123 if test "$ac_with_xsltproc" = "yes" -o "$ac_with_xsltproc" = "maybe"; then
1124     AC_PATH_PROGS(XSLTPROC,xsltproc,,$LOCSYSPATH)
1125 else
1126     if test "$ac_with_xsltproc" != "no"; then
1127         if test -x "$ac_with_xsltproc"; then
1128             XSLTPROC="$ac_with_xsltproc";
1129         else
1130             AC_MSG_WARN([Specified xsltproc of $ac_with_xsltproc isn't])
1131             AC_MSG_WARN([executable; searching for an alternative.])
1132             AC_PATH_PROGS(XSLTPROC,xsltproc,,$LOCSYSPATH)
1133         fi
1134     fi
1135 fi
1136 ])
1137
1138 # AC_CHECK_DOCBOOK_XSLT
1139 # -----------------------------------------------------------------
1140 # Check for access to docbook stylesheets of a particular revision.
1141 # This macro can be used for multiple versions within the same script.
1142 #
1143 # Input:
1144 #  $1 is the version of docbook to search for; default 'current'
1145 # Output:
1146 #  $HAVE_DOCBOOK_XSLT_VERS will be set to 'yes' or 'no' depending
1147 #  on the results of the test, where VERS is $1, with '_' substituted
1148 #  for '.'  $HAVE_DOCBOOK_XSLT will also be set to the same value.
1149 AC_DEFUN([AC_CHECK_DOCBOOK_XSLT],
1150 [
1151     AC_REQUIRE([AC_PROG_XSLTPROC])
1152
1153     dnl define a temporary variable for the version, so this macro can be
1154     dnl used with multiple versions
1155     define([_VERS], $1)
1156     ifelse(_VERS, [], [define([_VERS], [current])])
1157     define([ac_cv_docbook_xslt_VERS], patsubst([ac_cv_docbook_xslt_]_VERS, [\.], [_]))
1158     define([HAVE_DOCBOOK_XSLT_VERS], patsubst([HAVE_DOCBOOK_XSLT_]_VERS, [\.], [_]))
1159
1160     AC_CACHE_CHECK([for Docbook XSLT version ]_VERS, [ac_cv_docbook_xslt_VERS],
1161     [
1162         ac_cv_docbook_xslt_VERS=no
1163         if test -n "$XSLTPROC"; then
1164             echo "Trying '$XSLTPROC $XSLTPROC_FLAGS http://docbook.sourceforge.net/release/xsl/_VERS/xhtml/docbook.xsl'" >&AS_MESSAGE_LOG_FD
1165             $XSLTPROC $XSLTPROC_FLAGS http://docbook.sourceforge.net/release/xsl/_VERS/xhtml/docbook.xsl >&AS_MESSAGE_LOG_FD 2>&1
1166
1167             if test "$?" = 0; then
1168                 ac_cv_docbook_xslt_VERS=yes
1169             fi
1170         fi
1171     ])
1172
1173     HAVE_DOCBOOK_XSLT_VERS="$ac_cv_docbook_xslt_VERS"
1174     HAVE_DOCBOOK_XSLT=HAVE_DOCBOOK_XSLT_VERS
1175     undefine([_VERS])
1176 ])
1177
1178 # AC_CHECK_DOCBOOK_DTD
1179 # -----------------------------------------------------------------
1180 # Check for access to docbook DTD of a particular revision.
1181 # This macro can be used for multiple versions within the same script.
1182 #
1183 # Input:
1184 #  $1 is the version of docbook to search for; default 'current'
1185 # Output:
1186 #  $HAVE_DOCBOOK_DTD_VERS will be set to 'yes' or 'no' depending
1187 #  on the results of the test, where VERS is $1, with '_' substituted
1188 #  for '.'  $HAVE_DOCBOOK_DTD will also be set to the same value.
1189 AC_DEFUN([AC_CHECK_DOCBOOK_DTD],
1190 [
1191     AC_REQUIRE([AC_PROG_XSLTPROC])
1192
1193     dnl define a temporary variable for the version, so this macro can be
1194     dnl used with multiple versions
1195     define([_VERS], $1)
1196     ifelse(_VERS, [], [define([_VERS], [current])])
1197     define([ac_cv_docbook_dtd_VERS], patsubst([ac_cv_docbook_dtd_]_VERS, [\.], [_]))
1198     define([HAVE_DOCBOOK_DTD_VERS], patsubst([HAVE_DOCBOOK_DTD_]_VERS, [\.], [_]))
1199
1200     AC_CACHE_CHECK([for Docbook DTD version ]_VERS, [ac_cv_docbook_dtd_VERS],
1201     [
1202         ac_cv_docbook_dtd_VERS=no
1203         if test -n "$XSLTPROC"; then
1204             MY_XSLTPROC_FLAGS=`echo "" $XSLTPROC_FLAGS|sed -e s/--novalid//g`
1205             cat <<EOF >conftest.xml
1206 <?xml version="1.0" encoding='ISO-8859-1'?>
1207 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V[]_VERS//EN" "http://www.oasis-open.org/docbook/xml/_VERS/docbookx.dtd">
1208 <book id="empty">
1209 </book>
1210 EOF
1211             echo "Trying '$XSLTPROC $MY_XSLTPROC_FLAGS conftest.xml'" >&AS_MESSAGE_LOG_FD
1212             $XSLTPROC $MY_XSLTPROC_FLAGS conftest.xml >conftest.out 2>&1
1213             if test "$?" = 0; then
1214                 # failing to load the DTD is just a warning, so check for it in the output.
1215                 if grep 'warning: failed to load external entity' conftest_out >/dev/null 2>&1; then
1216                     : # no good..
1217                 else
1218                     ac_cv_docbook_dtd_VERS=yes
1219                 fi
1220             fi
1221             cat conftest.out >&AS_MESSAGE_LOG_FD
1222
1223             rm -f conftest.xml conftest.out
1224         fi
1225     ])
1226
1227     HAVE_DOCBOOK_DTD_VERS="$ac_cv_docbook_dtd_VERS"
1228     HAVE_DOCBOOK_DTD=HAVE_DOCBOOK_DTD_VERS
1229     undefine([_VERS])
1230 ])
1231 dnl
1232 dnl Checks to see if there's a sockaddr_storage structure
1233 dnl
1234 dnl usage:
1235 dnl
1236 dnl     AC_SOCKADDR_STORAGE
1237 dnl
1238 dnl results:
1239 dnl
1240 dnl     HAVE_SOCKADDR_STORAGE (defined)
1241 dnl
1242 AC_DEFUN([AC_SOCKADDR_STORAGE],
1243     [AC_MSG_CHECKING(if sockaddr_storage struct exists)
1244     AC_CACHE_VAL(ac_cv_has_sockaddr_storage,
1245         AC_TRY_COMPILE([
1246 #       include <sys/types.h>
1247 #       include <sys/socket.h>],
1248         [u_int i = sizeof (struct sockaddr_storage)],
1249         ac_cv_has_sockaddr_storage=yes,
1250         ac_cv_has_sockaddr_storage=no))
1251     AC_MSG_RESULT($ac_cv_has_sockaddr_storage)
1252     if test $ac_cv_has_sockaddr_storage = yes ; then
1253             AC_DEFINE(HAVE_SOCKADDR_STORAGE,1,[if struct sockaddr_storage exists])
1254     fi])
1255
1256