1 dnl Try to detect the type of the third arg to getsockname() et al
2 AC_DEFUN([LSH_TYPE_SOCKLEN_T],
3 [AH_TEMPLATE([socklen_t], [Length type used by getsockopt])
4 AC_CACHE_CHECK([for socklen_t in sys/socket.h], ac_cv_type_socklen_t,
5 [AC_EGREP_HEADER(socklen_t, sys/socket.h,
6 [ac_cv_type_socklen_t=yes], [ac_cv_type_socklen_t=no])])
7 if test $ac_cv_type_socklen_t = no; then
8 AC_MSG_CHECKING(for AIX)
15 AC_DEFINE(socklen_t, size_t)
18 AC_DEFINE(socklen_t, int)
23 dnl Choose cc flags for compiling position independent code
24 dnl FIXME: Doesn't do the right thing when crosscompiling.
26 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
27 AC_MSG_CHECKING(CCPIC)
28 AC_CACHE_VAL(lsh_cv_sys_ccpic,[
29 if test -z "$CCPIC" ; then
30 if test "$GCC" = yes ; then
32 bsdi4.*) CCPIC="-fPIC" ;;
34 darwin*) CCPIC="-fPIC" ;;
35 # Could also use -fpic, depending on the number of symbol references
36 solaris*) CCPIC="-fPIC" ;;
43 darwin*) CCPIC="-fPIC" ;;
44 irix*) CCPIC="-share" ;;
46 *freebsd*) CCPIC="-fpic" ;;
47 sco*|sysv4.*) CCPIC="-KPIC -dy -Bdynamic" ;;
48 solaris*) CCPIC="-KPIC -Bdynamic" ;;
49 winnt*) CCPIC="-shared" ;;
55 CFLAGS="$CFLAGS $CCPIC"
56 AC_TRY_COMPILE([], [exit(0);],
57 lsh_cv_sys_ccpic="$CCPIC", lsh_cv_sys_ccpic='')
60 CCPIC="$lsh_cv_sys_ccpic"
64 dnl LSH_PATH_ADD(path-id, directory)
65 AC_DEFUN([LSH_PATH_ADD],
68 if test -d "$2/." ; then
69 ac_real_dir=`cd $2 && pwd`
70 if test -n "$ac_real_dir" ; then
72 for old in $1_REAL_DIRS ; do
74 if test x$ac_real_dir = x$old ; then
79 if test $ac_found = yes ; then
80 AC_MSG_RESULT(already added)
83 # LDFLAGS="$LDFLAGS -L $2"
84 $1_REAL_DIRS="$ac_real_dir [$]$1_REAL_DIRS"
85 $1_DIRS="$2 [$]$1_DIRS"
89 if test $ac_exists = no ; then
90 AC_MSG_RESULT(not found)
94 dnl LSH_RPATH_ADD(dir)
95 AC_DEFUN([LSH_RPATH_ADD], [LSH_PATH_ADD(RPATH_CANDIDATE, $1)])
97 dnl LSH_RPATH_INIT(candidates)
98 AC_DEFUN([LSH_RPATH_INIT],
99 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
100 AC_MSG_CHECKING([for -R flag])
103 osf1*) RPATHFLAG="-rpath " ;;
104 irix6.*|irix5.*) RPATHFLAG="-rpath " ;;
106 if test "$TCC" = "yes"; then
107 # tcc doesn't know about -R
113 linux*) RPATHFLAG="-Wl,-rpath," ;;
117 if test x$RPATHFLAG = x ; then
120 AC_MSG_RESULT([using $RPATHFLAG])
123 RPATH_CANDIDATE_REAL_DIRS=''
124 RPATH_CANDIDATE_DIRS=''
126 AC_MSG_RESULT([Searching for libraries])
133 dnl Try to execute a main program, and if it fails, try adding some
136 AC_DEFUN([LSH_RPATH_FIX],
137 [if test $cross_compiling = no -a "x$RPATHFLAG" != x ; then
139 AC_TRY_RUN([int main(int argc, char **argv) { return 0; }],
140 ac_success=yes, ac_success=no, :)
142 if test $ac_success = no ; then
143 AC_MSG_CHECKING([Running simple test program failed. Trying -R flags])
144 dnl echo RPATH_CANDIDATE_DIRS = $RPATH_CANDIDATE_DIRS
146 ac_rpath_save_LDFLAGS="$LDFLAGS"
147 for d in $RPATH_CANDIDATE_DIRS ; do
148 if test $ac_success = yes ; then
149 ac_remaining_dirs="$ac_remaining_dirs $d"
151 LDFLAGS="$RPATHFLAG$d $LDFLAGS"
152 dnl echo LDFLAGS = $LDFLAGS
153 AC_TRY_RUN([int main(int argc, char **argv) { return 0; }],
155 ac_rpath_save_LDFLAGS="$LDFLAGS"
156 AC_MSG_RESULT([adding $RPATHFLAG$d])
158 [ac_remaining_dirs="$ac_remaining_dirs $d"], :)
159 LDFLAGS="$ac_rpath_save_LDFLAGS"
162 RPATH_CANDIDATE_DIRS=$ac_remaining_dirs
164 if test $ac_success = no ; then
165 AC_MSG_RESULT(failed)
170 dnl Like AC_CHECK_LIB, but uses $KRB_LIBS rather than $LIBS.
171 dnl LSH_CHECK_KRB_LIB(LIBRARY, FUNCTION, [, ACTION-IF-FOUND [,
172 dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
174 AC_DEFUN([LSH_CHECK_KRB_LIB],
175 [AC_CHECK_LIB([$1], [$2],
177 [[ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
178 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
179 AC_DEFINE_UNQUOTED($ac_tr_lib)
180 KRB_LIBS="-l$1 $KRB_LIBS"
187 dnl LSH_LIB_ARGP(ACTION-IF-OK, ACTION-IF-BAD)
188 AC_DEFUN([LSH_LIB_ARGP],
189 [ ac_argp_save_LIBS="$LIBS"
190 ac_argp_save_LDFLAGS="$LDFLAGS"
192 # First check if we can link with argp.
193 AC_SEARCH_LIBS(argp_parse, argp,
195 AC_CACHE_CHECK([for working argp],
196 lsh_cv_lib_argp_works,
201 static const struct argp_option
204 { NULL, 0, NULL, 0, NULL, 0 }
213 child_parser(int key, char *arg, struct argp_state *state)
215 struct child_state *input = (struct child_state *) state->input;
220 return ARGP_ERR_UNKNOWN;
229 const struct argp child_argp =
233 NULL, NULL, NULL, NULL, NULL
238 struct child_state child;
243 main_parser(int key, char *arg, struct argp_state *state)
245 struct main_state *input = (struct main_state *) state->input;
250 return ARGP_ERR_UNKNOWN;
252 state->child_inputs[0] = &input->child;
256 input->m = input->child.n;
263 static const struct argp_child
266 { &child_argp, 0, "", 0 },
270 static const struct argp
272 { options, main_parser,
279 int main(int argc, char **argv)
281 struct main_state input = { { 0 }, 0 };
282 char *v[2] = { "foo", NULL };
284 argp_parse(&main_argp, 1, v, 0, NULL, &input);
286 if ( (input.m == 1) && (input.child.n == 1) )
291 ], lsh_cv_lib_argp_works=yes,
292 lsh_cv_lib_argp_works=no,
293 lsh_cv_lib_argp_works=no)])
295 if test x$lsh_cv_lib_argp_works = xyes ; then
299 LIBS="$ac_argp_save_LIBS"
300 LDFLAGS="$ac_argp_save_LDFLAGS"
303 if test x$ac_argp_ok = xyes ; then
304 ifelse([$1],, true, [$1])
306 ifelse([$2],, true, [$2])
310 dnl LSH_GCC_ATTRIBUTES
311 dnl Check for gcc's __attribute__ construction
313 AC_DEFUN([LSH_GCC_ATTRIBUTES],
314 [AC_CACHE_CHECK(for __attribute__,
319 static void foo(void) __attribute__ ((noreturn));
321 static void __attribute__ ((noreturn))
327 lsh_cv_c_attribute=yes,
328 lsh_cv_c_attribute=no)])
330 AH_TEMPLATE([HAVE_GCC_ATTRIBUTE], [Define if the compiler understands __attribute__])
331 if test "x$lsh_cv_c_attribute" = "xyes"; then
332 AC_DEFINE(HAVE_GCC_ATTRIBUTE)
336 [#if __GNUC__ && HAVE_GCC_ATTRIBUTE
337 # define NORETURN __attribute__ ((__noreturn__))
338 # define PRINTF_STYLE(f, a) __attribute__ ((__format__ (__printf__, f, a)))
339 # define UNUSED __attribute__ ((__unused__))
342 # define PRINTF_STYLE(f, a)
347 # Check for alloca, and include the standard blurb in config.h
348 AC_DEFUN([LSH_FUNC_ALLOCA],
350 AC_CHECK_HEADERS([malloc.h])
352 [/* AIX requires this to be the first thing in the file. */
360 # ifndef alloca /* predefined by HP cc +Olibcalls */
364 /* Needed for alloca on windows */
369 #else /* defined __GNUC__ */
376 AC_DEFUN([LSH_FUNC_STRERROR],
377 [AC_CHECK_FUNCS(strerror)
380 #define STRERROR strerror
382 #define STRERROR(x) (sys_errlist[x])
386 AC_DEFUN([LSH_FUNC_STRSIGNAL],
387 [AC_CHECK_FUNCS(strsignal)
388 AC_CHECK_DECLS([sys_siglist, _sys_siglist])
391 # define STRSIGNAL strsignal
392 #else /* !HAVE_STRSIGNAL */
393 # if HAVE_DECL_SYS_SIGLIST
394 # define STRSIGNAL(x) (sys_siglist[x])
396 # if HAVE_DECL__SYS_SIGLIST
397 # define STRSIGNAL(x) (_sys_siglist[x])
399 # define STRSIGNAL(x) "Unknown signal"
401 # warning Using dummy STRSIGNAL
405 #endif /* !HAVE_STRSIGNAL */
408 dnl LSH_MAKE_CONDITIONAL(symbol, test)
409 AC_DEFUN([LSH_MAKE_CONDITIONAL],
418 AC_SUBST(UNLESS_$1)])
420 dnl LSH_DEPENDENCY_TRACKING
422 dnl Defines compiler flags DEP_FLAGS to generate dependency
423 dnl information, and DEP_PROCESS that is any shell commands needed for
424 dnl massaging the dependency information further. Dependencies are
425 dnl generated as a side effect of compilation. Dependency files
426 dnl themselves are not treated as targets.
428 AC_DEFUN([LSH_DEPENDENCY_TRACKING],
429 [AC_ARG_ENABLE(dependency_tracking,
430 AC_HELP_STRING([--disable-dependency-tracking],
431 [Disable dependency tracking. Dependency tracking doesn't work with BSD make]),,
432 [enable_dependency_tracking=yes])
436 if test x$enable_dependency_tracking = xyes ; then
437 if test x$GCC = xyes ; then
438 gcc_version=`gcc --version | head -1`
439 case "$gcc_version" in
441 enable_dependency_tracking=no
442 AC_MSG_WARN([Dependency tracking disabled, gcc-3.x is needed])
445 DEP_FLAGS='-MT $[]@ -MD -MP -MF $[]@.d'
450 enable_dependency_tracking=no
451 AC_MSG_WARN([Dependency tracking disabled])
455 if test x$enable_dependency_tracking = xyes ; then
456 DEP_INCLUDE='include '
461 AC_SUBST([DEP_INCLUDE])
462 AC_SUBST([DEP_FLAGS])
463 AC_SUBST([DEP_PROCESS])])
465 dnl GMP_TRY_ASSEMBLE(asm-code,[action-success][,action-fail])
466 dnl ----------------------------------------------------------
467 dnl Attempt to assemble the given code.
468 dnl Do "action-success" if this succeeds, "action-fail" if not.
470 dnl conftest.o and conftest.out are available for inspection in
471 dnl "action-success". If either action does a "break" out of a loop then
472 dnl an explicit "rm -f conftest*" will be necessary.
474 dnl This is not unlike AC_TRY_COMPILE, but there's no default includes or
475 dnl anything in "asm-code", everything wanted must be given explicitly.
477 AC_DEFUN([GMP_TRY_ASSEMBLE],
478 [cat >conftest.s <<EOF
481 gmp_assemble="$CC $CFLAGS $CPPFLAGS -c conftest.s >conftest.out 2>&1"
482 if AC_TRY_EVAL(gmp_assemble); then
483 cat conftest.out >&AC_FD_CC
486 cat conftest.out >&AC_FD_CC
487 echo "configure: failed program was:" >&AC_FD_CC
488 cat conftest.s >&AC_FD_CC
494 dnl @synopsis AX_CREATE_STDINT_H [( HEADER-TO-GENERATE [, HEADERS-TO-CHECK])]
496 dnl the "ISO C9X: 7.18 Integer types <stdint.h>" section requires the
497 dnl existence of an include file <stdint.h> that defines a set of
498 dnl typedefs, especially uint8_t,int32_t,uintptr_t.
499 dnl Many older installations will not provide this file, but some will
500 dnl have the very same definitions in <inttypes.h>. In other enviroments
501 dnl we can use the inet-types in <sys/types.h> which would define the
502 dnl typedefs int8_t and u_int8_t respectivly.
504 dnl This macros will create a local "_stdint.h" or the headerfile given as
505 dnl an argument. In many cases that file will just "#include <stdint.h>"
506 dnl or "#include <inttypes.h>", while in other environments it will provide
507 dnl the set of basic 'stdint's definitions/typedefs:
508 dnl int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t
509 dnl int_least32_t.. int_fast32_t.. intmax_t
510 dnl which may or may not rely on the definitions of other files,
511 dnl or using the AC_CHECK_SIZEOF macro to determine the actual
512 dnl sizeof each type.
514 dnl if your header files require the stdint-types you will want to create an
515 dnl installable file mylib-int.h that all your other installable header
516 dnl may include. So if you have a library package named "mylib", just use
517 dnl AX_CREATE_STDINT_H(mylib-int.h)
518 dnl in configure.ac and go to install that very header file in Makefile.am
519 dnl along with the other headers (mylib.h) - and the mylib-specific headers
520 dnl can simply use "#include <mylib-int.h>" to obtain the stdint-types.
522 dnl Remember, if the system already had a valid <stdint.h>, the generated
523 dnl file will include it directly. No need for fuzzy HAVE_STDINT_H things...
525 dnl @, (status: used on new platforms) (see http://ac-archive.sf.net/gstdint/)
526 dnl @version $Id: aclocal.m4,v 1.1 2007/05/03 20:49:15 nisse Exp $
527 dnl @author Guido Draheim <guidod@gmx.de>
529 AC_DEFUN([AX_CREATE_STDINT_H],
530 [# ------ AX CREATE STDINT H -------------------------------------
531 AC_MSG_CHECKING([for stdint types])
532 ac_stdint_h=`echo ifelse($1, , _stdint.h, $1)`
533 # try to shortcircuit - if the default include path of the compiler
534 # can find a "stdint.h" header then we assume that all compilers can.
535 AC_CACHE_VAL([ac_cv_header_stdint_t],[
536 old_CXXFLAGS="$CXXFLAGS" ; CXXFLAGS=""
537 old_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS=""
538 old_CFLAGS="$CFLAGS" ; CFLAGS=""
539 AC_TRY_COMPILE([#include <stdint.h>],[int_least32_t v = 0;],
540 [ac_cv_stdint_result="(assuming C99 compatible system)"
541 ac_cv_header_stdint_t="stdint.h"; ],
542 [ac_cv_header_stdint_t=""])
543 CXXFLAGS="$old_CXXFLAGS"
544 CPPFLAGS="$old_CPPFLAGS"
545 CFLAGS="$old_CFLAGS" ])
547 v="... $ac_cv_header_stdint_h"
548 if test "$ac_stdint_h" = "stdint.h" ; then
549 AC_MSG_RESULT([(are you sure you want them in ./stdint.h?)])
550 elif test "$ac_stdint_h" = "inttypes.h" ; then
551 AC_MSG_RESULT([(are you sure you want them in ./inttypes.h?)])
552 elif test "_$ac_cv_header_stdint_t" = "_" ; then
553 AC_MSG_RESULT([(putting them into $ac_stdint_h)$v])
555 ac_cv_header_stdint="$ac_cv_header_stdint_t"
556 AC_MSG_RESULT([$ac_cv_header_stdint (shortcircuit)])
559 if test "_$ac_cv_header_stdint_t" = "_" ; then # can not shortcircuit..
561 dnl .....intro message done, now do a few system checks.....
562 dnl btw, all CHECK_TYPE macros do automatically "DEFINE" a type, therefore
563 dnl we use the autoconf implementation detail _AC CHECK_TYPE_NEW instead
565 inttype_headers=`echo $2 | sed -e 's/,/ /g'`
567 ac_cv_stdint_result="(no helpful system typedefs seen)"
568 AC_CACHE_CHECK([for stdint uintptr_t], [ac_cv_header_stdint_x],[
569 ac_cv_header_stdint_x="" # the 1997 typedefs (inttypes.h)
570 AC_MSG_RESULT([(..)])
571 for i in stdint.h inttypes.h sys/inttypes.h $inttype_headers ; do
572 unset ac_cv_type_uintptr_t
573 unset ac_cv_type_uint64_t
574 _AC_CHECK_TYPE_NEW(uintptr_t,[ac_cv_header_stdint_x=$i],dnl
575 continue,[#include <$i>])
576 AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
577 ac_cv_stdint_result="(seen uintptr_t$and64 in $i)"
580 AC_MSG_CHECKING([for stdint uintptr_t])
583 if test "_$ac_cv_header_stdint_x" = "_" ; then
584 AC_CACHE_CHECK([for stdint uint32_t], [ac_cv_header_stdint_o],[
585 ac_cv_header_stdint_o="" # the 1995 typedefs (sys/inttypes.h)
586 AC_MSG_RESULT([(..)])
587 for i in inttypes.h sys/inttypes.h stdint.h $inttype_headers ; do
588 unset ac_cv_type_uint32_t
589 unset ac_cv_type_uint64_t
590 AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],dnl
591 continue,[#include <$i>])
592 AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
593 ac_cv_stdint_result="(seen uint32_t$and64 in $i)"
596 AC_MSG_CHECKING([for stdint uint32_t])
600 if test "_$ac_cv_header_stdint_x" = "_" ; then
601 if test "_$ac_cv_header_stdint_o" = "_" ; then
602 AC_CACHE_CHECK([for stdint u_int32_t], [ac_cv_header_stdint_u],[
603 ac_cv_header_stdint_u="" # the BSD typedefs (sys/types.h)
604 AC_MSG_RESULT([(..)])
605 for i in sys/types.h inttypes.h sys/inttypes.h $inttype_headers ; do
606 unset ac_cv_type_u_int32_t
607 unset ac_cv_type_u_int64_t
608 AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],dnl
609 continue,[#include <$i>])
610 AC_CHECK_TYPE(u_int64_t,[and64="/u_int64_t"],[and64=""],[#include<$i>])
611 ac_cv_stdint_result="(seen u_int32_t$and64 in $i)"
614 AC_MSG_CHECKING([for stdint u_int32_t])
618 dnl if there was no good C99 header file, do some typedef checks...
619 if test "_$ac_cv_header_stdint_x" = "_" ; then
620 AC_MSG_CHECKING([for stdint datatype model])
621 AC_MSG_RESULT([(..)])
622 AC_CHECK_SIZEOF(char)
623 AC_CHECK_SIZEOF(short)
625 AC_CHECK_SIZEOF(long)
626 AC_CHECK_SIZEOF(void*)
627 ac_cv_stdint_char_model=""
628 ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_char"
629 ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_short"
630 ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_int"
631 ac_cv_stdint_long_model=""
632 ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_int"
633 ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_long"
634 ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_voidp"
635 name="$ac_cv_stdint_long_model"
636 case "$ac_cv_stdint_char_model/$ac_cv_stdint_long_model" in
637 122/242) name="$name, IP16 (standard 16bit machine)" ;;
638 122/244) name="$name, LP32 (standard 32bit mac/win)" ;;
639 122/*) name="$name (unusual int16 model)" ;;
640 124/444) name="$name, ILP32 (standard 32bit unixish)" ;;
641 124/488) name="$name, LP64 (standard 64bit unixish)" ;;
642 124/448) name="$name, LLP64 (unusual 64bit unixish)" ;;
643 124/*) name="$name (unusual int32 model)" ;;
644 128/888) name="$name, ILP64 (unusual 64bit numeric)" ;;
645 128/*) name="$name (unusual int64 model)" ;;
646 222/*|444/*) name="$name (unusual dsptype)" ;;
647 *) name="$name (very unusal model)" ;;
649 AC_MSG_RESULT([combined for stdint datatype model... $name])
652 if test "_$ac_cv_header_stdint_x" != "_" ; then
653 ac_cv_header_stdint="$ac_cv_header_stdint_x"
654 elif test "_$ac_cv_header_stdint_o" != "_" ; then
655 ac_cv_header_stdint="$ac_cv_header_stdint_o"
656 elif test "_$ac_cv_header_stdint_u" != "_" ; then
657 ac_cv_header_stdint="$ac_cv_header_stdint_u"
659 ac_cv_header_stdint="stddef.h"
662 AC_MSG_CHECKING([for extra inttypes in chosen header])
663 AC_MSG_RESULT([($ac_cv_header_stdint)])
664 dnl see if int_least and int_fast types are present in _this_ header.
665 unset ac_cv_type_int_least32_t
666 unset ac_cv_type_int_fast32_t
667 AC_CHECK_TYPE(int_least32_t,,,[#include <$ac_cv_header_stdint>])
668 AC_CHECK_TYPE(int_fast32_t,,,[#include<$ac_cv_header_stdint>])
669 AC_CHECK_TYPE(intmax_t,,,[#include <$ac_cv_header_stdint>])
671 fi # shortcircut to system "stdint.h"
672 # ------------------ PREPARE VARIABLES ------------------------------
673 if test "$GCC" = "yes" ; then
674 ac_cv_stdint_message="using gnu compiler "`$CC --version | head -1`
676 ac_cv_stdint_message="using $CC"
679 AC_MSG_RESULT([make use of $ac_cv_header_stdint in $ac_stdint_h dnl
680 $ac_cv_stdint_result])
682 # ----------------- DONE inttypes.h checks START header -------------
683 AC_CONFIG_COMMANDS([$ac_stdint_h],[
684 AC_MSG_NOTICE(creating $ac_stdint_h : $_ac_stdint_h)
685 ac_stdint=$tmp/_stdint.h
687 echo "#ifndef" $_ac_stdint_h >$ac_stdint
688 echo "#define" $_ac_stdint_h "1" >>$ac_stdint
689 echo "#ifndef" _GENERATED_STDINT_H >>$ac_stdint
690 echo "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdint
691 echo "/* generated $ac_cv_stdint_message */" >>$ac_stdint
692 if test "_$ac_cv_header_stdint_t" != "_" ; then
693 echo "#define _STDINT_HAVE_STDINT_H" "1" >>$ac_stdint
696 cat >>$ac_stdint <<STDINT_EOF
698 /* ................... shortcircuit part ........................... */
700 #if defined HAVE_STDINT_H || defined _STDINT_HAVE_STDINT_H
705 /* .................... configured part ............................ */
709 echo "/* whether we have a C99 compatible stdint header file */" >>$ac_stdint
710 if test "_$ac_cv_header_stdint_x" != "_" ; then
711 ac_header="$ac_cv_header_stdint_x"
712 echo "#define _STDINT_HEADER_INTPTR" '"'"$ac_header"'"' >>$ac_stdint
714 echo "/* #undef _STDINT_HEADER_INTPTR */" >>$ac_stdint
717 echo "/* whether we have a C96 compatible inttypes header file */" >>$ac_stdint
718 if test "_$ac_cv_header_stdint_o" != "_" ; then
719 ac_header="$ac_cv_header_stdint_o"
720 echo "#define _STDINT_HEADER_UINT32" '"'"$ac_header"'"' >>$ac_stdint
722 echo "/* #undef _STDINT_HEADER_UINT32 */" >>$ac_stdint
725 echo "/* whether we have a BSD compatible inet types header */" >>$ac_stdint
726 if test "_$ac_cv_header_stdint_u" != "_" ; then
727 ac_header="$ac_cv_header_stdint_u"
728 echo "#define _STDINT_HEADER_U_INT32" '"'"$ac_header"'"' >>$ac_stdint
730 echo "/* #undef _STDINT_HEADER_U_INT32 */" >>$ac_stdint
735 if test "_$ac_header" != "_" ; then if test "$ac_header" != "stddef.h" ; then
736 echo "#include <$ac_header>" >>$ac_stdint
740 echo "/* which 64bit typedef has been found */" >>$ac_stdint
741 if test "$ac_cv_type_uint64_t" = "yes" ; then
742 echo "#define _STDINT_HAVE_UINT64_T" "1" >>$ac_stdint
744 echo "/* #undef _STDINT_HAVE_UINT64_T */" >>$ac_stdint
746 if test "$ac_cv_type_u_int64_t" = "yes" ; then
747 echo "#define _STDINT_HAVE_U_INT64_T" "1" >>$ac_stdint
749 echo "/* #undef _STDINT_HAVE_U_INT64_T */" >>$ac_stdint
753 echo "/* which type model has been detected */" >>$ac_stdint
754 if test "_$ac_cv_stdint_char_model" != "_" ; then
755 echo "#define _STDINT_CHAR_MODEL" "$ac_cv_stdint_char_model" >>$ac_stdint
756 echo "#define _STDINT_LONG_MODEL" "$ac_cv_stdint_long_model" >>$ac_stdint
758 echo "/* #undef _STDINT_CHAR_MODEL // skipped */" >>$ac_stdint
759 echo "/* #undef _STDINT_LONG_MODEL // skipped */" >>$ac_stdint
763 echo "/* whether int_least types were detected */" >>$ac_stdint
764 if test "$ac_cv_type_int_least32_t" = "yes"; then
765 echo "#define _STDINT_HAVE_INT_LEAST32_T" "1" >>$ac_stdint
767 echo "/* #undef _STDINT_HAVE_INT_LEAST32_T */" >>$ac_stdint
769 echo "/* whether int_fast types were detected */" >>$ac_stdint
770 if test "$ac_cv_type_int_fast32_t" = "yes"; then
771 echo "#define _STDINT_HAVE_INT_FAST32_T" "1" >>$ac_stdint
773 echo "/* #undef _STDINT_HAVE_INT_FAST32_T */" >>$ac_stdint
775 echo "/* whether intmax_t type was detected */" >>$ac_stdint
776 if test "$ac_cv_type_intmax_t" = "yes"; then
777 echo "#define _STDINT_HAVE_INTMAX_T" "1" >>$ac_stdint
779 echo "/* #undef _STDINT_HAVE_INTMAX_T */" >>$ac_stdint
783 cat >>$ac_stdint <<STDINT_EOF
784 /* .................... detections part ............................ */
786 /* whether we need to define bitspecific types from compiler base types */
787 #ifndef _STDINT_HEADER_INTPTR
788 #ifndef _STDINT_HEADER_UINT32
789 #ifndef _STDINT_HEADER_U_INT32
790 #define _STDINT_NEED_INT_MODEL_T
792 #define _STDINT_HAVE_U_INT_TYPES
797 #ifdef _STDINT_HAVE_U_INT_TYPES
798 #undef _STDINT_NEED_INT_MODEL_T
801 #ifdef _STDINT_CHAR_MODEL
802 #if _STDINT_CHAR_MODEL+0 == 122 || _STDINT_CHAR_MODEL+0 == 124
803 #ifndef _STDINT_BYTE_MODEL
804 #define _STDINT_BYTE_MODEL 12
809 #ifndef _STDINT_HAVE_INT_LEAST32_T
810 #define _STDINT_NEED_INT_LEAST_T
813 #ifndef _STDINT_HAVE_INT_FAST32_T
814 #define _STDINT_NEED_INT_FAST_T
817 #ifndef _STDINT_HEADER_INTPTR
818 #define _STDINT_NEED_INTPTR_T
819 #ifndef _STDINT_HAVE_INTMAX_T
820 #define _STDINT_NEED_INTMAX_T
825 /* .................... definition part ............................ */
827 /* some system headers have good uint64_t */
828 #ifndef _HAVE_UINT64_T
829 #if defined _STDINT_HAVE_UINT64_T || defined HAVE_UINT64_T
830 #define _HAVE_UINT64_T
831 #elif defined _STDINT_HAVE_U_INT64_T || defined HAVE_U_INT64_T
832 #define _HAVE_UINT64_T
833 typedef u_int64_t uint64_t;
837 #ifndef _HAVE_UINT64_T
838 /* .. here are some common heuristics using compiler runtime specifics */
839 #if defined __STDC_VERSION__ && defined __STDC_VERSION__ >= 199901L
840 #define _HAVE_UINT64_T
841 typedef long long int64_t;
842 typedef unsigned long long uint64_t;
844 #elif !defined __STRICT_ANSI__
845 #if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__
846 #define _HAVE_UINT64_T
847 typedef __int64 int64_t;
848 typedef unsigned __int64 uint64_t;
850 #elif defined __GNUC__ || defined __MWERKS__ || defined __ELF__
851 /* note: all ELF-systems seem to have loff-support which needs 64-bit */
852 #if !defined _NO_LONGLONG
853 #define _HAVE_UINT64_T
854 typedef long long int64_t;
855 typedef unsigned long long uint64_t;
858 #elif defined __alpha || (defined __mips && defined _ABIN32)
859 #if !defined _NO_LONGLONG
860 typedef long int64_t;
861 typedef unsigned long uint64_t;
863 /* compiler/cpu type to define int64_t */
868 #if defined _STDINT_HAVE_U_INT_TYPES
869 /* int8_t int16_t int32_t defined by inet code, redeclare the u_intXX types */
870 typedef u_int8_t uint8_t;
871 typedef u_int16_t uint16_t;
872 typedef u_int32_t uint32_t;
874 /* glibc compatibility */
875 #ifndef __int8_t_defined
876 #define __int8_t_defined
880 #ifdef _STDINT_NEED_INT_MODEL_T
881 /* we must guess all the basic types. Apart from byte-adressable system, */
882 /* there a few 32-bit-only dsp-systems that we guard with BYTE_MODEL 8-} */
883 /* (btw, those nibble-addressable systems are way off, or so we assume) */
885 dnl /* have a look at "64bit and data size neutrality" at */
886 dnl /* http://unix.org/version2/whatsnew/login_64bit.html */
887 dnl /* (the shorthand "ILP" types always have a "P" part) */
889 #if defined _STDINT_BYTE_MODEL
890 #if _STDINT_LONG_MODEL+0 == 242
891 /* 2:4:2 = IP16 = a normal 16-bit system */
892 typedef unsigned char uint8_t;
893 typedef unsigned short uint16_t;
894 typedef unsigned long uint32_t;
895 #ifndef __int8_t_defined
896 #define __int8_t_defined
898 typedef short int16_t;
899 typedef long int32_t;
901 #elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL == 444
902 /* 2:4:4 = LP32 = a 32-bit system derived from a 16-bit */
903 /* 4:4:4 = ILP32 = a normal 32-bit system */
904 typedef unsigned char uint8_t;
905 typedef unsigned short uint16_t;
906 typedef unsigned int uint32_t;
907 #ifndef __int8_t_defined
908 #define __int8_t_defined
910 typedef short int16_t;
913 #elif _STDINT_LONG_MODEL+0 == 484 || _STDINT_LONG_MODEL+0 == 488
914 /* 4:8:4 = IP32 = a 32-bit system prepared for 64-bit */
915 /* 4:8:8 = LP64 = a normal 64-bit system */
916 typedef unsigned char uint8_t;
917 typedef unsigned short uint16_t;
918 typedef unsigned int uint32_t;
919 #ifndef __int8_t_defined
920 #define __int8_t_defined
922 typedef short int16_t;
925 /* this system has a "long" of 64bit */
926 #ifndef _HAVE_UINT64_T
927 #define _HAVE_UINT64_T
928 typedef unsigned long uint64_t;
929 typedef long int64_t;
931 #elif _STDINT_LONG_MODEL+0 == 448
932 /* LLP64 a 64-bit system derived from a 32-bit system */
933 typedef unsigned char uint8_t;
934 typedef unsigned short uint16_t;
935 typedef unsigned int uint32_t;
936 #ifndef __int8_t_defined
937 #define __int8_t_defined
939 typedef short int16_t;
942 /* assuming the system has a "long long" */
943 #ifndef _HAVE_UINT64_T
944 #define _HAVE_UINT64_T
945 typedef unsigned long long uint64_t;
946 typedef long long int64_t;
949 #define _STDINT_NO_INT32_T
952 #define _STDINT_NO_INT8_T
953 #define _STDINT_NO_INT32_T
958 * quote from SunOS-5.8 sys/inttypes.h:
959 * Use at your own risk. As of February 1996, the committee is squarely
960 * behind the fixed sized types; the "least" and "fast" types are still being
961 * discussed. The probability that the "fast" types may be removed before
962 * the standard is finalized is high enough that they are not currently
966 #if defined _STDINT_NEED_INT_LEAST_T
967 typedef int8_t int_least8_t;
968 typedef int16_t int_least16_t;
969 typedef int32_t int_least32_t;
970 #ifdef _HAVE_UINT64_T
971 typedef int64_t int_least64_t;
974 typedef uint8_t uint_least8_t;
975 typedef uint16_t uint_least16_t;
976 typedef uint32_t uint_least32_t;
977 #ifdef _HAVE_UINT64_T
978 typedef uint64_t uint_least64_t;
983 #if defined _STDINT_NEED_INT_FAST_T
984 typedef int8_t int_fast8_t;
985 typedef int int_fast16_t;
986 typedef int32_t int_fast32_t;
987 #ifdef _HAVE_UINT64_T
988 typedef int64_t int_fast64_t;
991 typedef uint8_t uint_fast8_t;
992 typedef unsigned uint_fast16_t;
993 typedef uint32_t uint_fast32_t;
994 #ifdef _HAVE_UINT64_T
995 typedef uint64_t uint_fast64_t;
1000 #ifdef _STDINT_NEED_INTMAX_T
1001 #ifdef _HAVE_UINT64_T
1002 typedef int64_t intmax_t;
1003 typedef uint64_t uintmax_t;
1005 typedef long intmax_t;
1006 typedef unsigned long uintmax_t;
1010 #ifdef _STDINT_NEED_INTPTR_T
1011 #ifndef __intptr_t_defined
1012 #define __intptr_t_defined
1013 /* we encourage using "long" to store pointer values, never use "int" ! */
1014 #if _STDINT_LONG_MODEL+0 == 242 || _STDINT_LONG_MODEL+0 == 484
1015 typedef unsinged int uintptr_t;
1016 typedef int intptr_t;
1017 #elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL+0 == 444
1018 typedef unsigned long uintptr_t;
1019 typedef long intptr_t;
1020 #elif _STDINT_LONG_MODEL+0 == 448 && defined _HAVE_UINT64_T
1021 typedef uint64_t uintptr_t;
1022 typedef int64_t intptr_t;
1023 #else /* matches typical system types ILP32 and LP64 - but not IP16 or LLP64 */
1024 typedef unsigned long uintptr_t;
1025 typedef long intptr_t;
1036 if cmp -s $ac_stdint_h $ac_stdint 2>/dev/null; then
1037 AC_MSG_NOTICE([$ac_stdint_h is unchanged])
1039 ac_dir=`AS_DIRNAME(["$ac_stdint_h"])`
1040 AS_MKDIR_P(["$ac_dir"])
1042 mv $ac_stdint $ac_stdint_h
1044 ],[# variables for create stdint.h replacement
1047 ac_stdint_h="$ac_stdint_h"
1048 _ac_stdint_h=AS_TR_CPP(_$PACKAGE-$ac_stdint_h)
1049 ac_cv_stdint_message="$ac_cv_stdint_message"
1050 ac_cv_header_stdint_t="$ac_cv_header_stdint_t"
1051 ac_cv_header_stdint_x="$ac_cv_header_stdint_x"
1052 ac_cv_header_stdint_o="$ac_cv_header_stdint_o"
1053 ac_cv_header_stdint_u="$ac_cv_header_stdint_u"
1054 ac_cv_type_uint64_t="$ac_cv_type_uint64_t"
1055 ac_cv_type_u_int64_t="$ac_cv_type_u_int64_t"
1056 ac_cv_stdint_char_model="$ac_cv_stdint_char_model"
1057 ac_cv_stdint_long_model="$ac_cv_stdint_long_model"
1058 ac_cv_type_int_least32_t="$ac_cv_type_int_least32_t"
1059 ac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t"
1060 ac_cv_type_intmax_t="$ac_cv_type_intmax_t"