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__ */
373 /* Needed for alloca on windows, also with gcc */
381 AC_DEFUN([LSH_FUNC_STRERROR],
382 [AC_CHECK_FUNCS(strerror)
385 #define STRERROR strerror
387 #define STRERROR(x) (sys_errlist[x])
391 AC_DEFUN([LSH_FUNC_STRSIGNAL],
392 [AC_CHECK_FUNCS(strsignal)
393 AC_CHECK_DECLS([sys_siglist, _sys_siglist])
396 # define STRSIGNAL strsignal
397 #else /* !HAVE_STRSIGNAL */
398 # if HAVE_DECL_SYS_SIGLIST
399 # define STRSIGNAL(x) (sys_siglist[x])
401 # if HAVE_DECL__SYS_SIGLIST
402 # define STRSIGNAL(x) (_sys_siglist[x])
404 # define STRSIGNAL(x) "Unknown signal"
406 # warning Using dummy STRSIGNAL
410 #endif /* !HAVE_STRSIGNAL */
413 dnl LSH_MAKE_CONDITIONAL(symbol, test)
414 AC_DEFUN([LSH_MAKE_CONDITIONAL],
423 AC_SUBST(UNLESS_$1)])
425 dnl LSH_DEPENDENCY_TRACKING
427 dnl Defines compiler flags DEP_FLAGS to generate dependency
428 dnl information, and DEP_PROCESS that is any shell commands needed for
429 dnl massaging the dependency information further. Dependencies are
430 dnl generated as a side effect of compilation. Dependency files
431 dnl themselves are not treated as targets.
433 AC_DEFUN([LSH_DEPENDENCY_TRACKING],
434 [AC_ARG_ENABLE(dependency_tracking,
435 AC_HELP_STRING([--disable-dependency-tracking],
436 [Disable dependency tracking. Dependency tracking doesn't work with BSD make]),,
437 [enable_dependency_tracking=yes])
441 if test x$enable_dependency_tracking = xyes ; then
442 if test x$GCC = xyes ; then
443 gcc_version=`gcc --version | head -1`
444 case "$gcc_version" in
446 enable_dependency_tracking=no
447 AC_MSG_WARN([Dependency tracking disabled, gcc-3.x is needed])
450 DEP_FLAGS='-MT $[]@ -MD -MP -MF $[]@.d'
455 enable_dependency_tracking=no
456 AC_MSG_WARN([Dependency tracking disabled])
460 if test x$enable_dependency_tracking = xyes ; then
461 DEP_INCLUDE='include '
466 AC_SUBST([DEP_INCLUDE])
467 AC_SUBST([DEP_FLAGS])
468 AC_SUBST([DEP_PROCESS])])
470 dnl GMP_TRY_ASSEMBLE(asm-code,[action-success][,action-fail])
471 dnl ----------------------------------------------------------
472 dnl Attempt to assemble the given code.
473 dnl Do "action-success" if this succeeds, "action-fail" if not.
475 dnl conftest.o and conftest.out are available for inspection in
476 dnl "action-success". If either action does a "break" out of a loop then
477 dnl an explicit "rm -f conftest*" will be necessary.
479 dnl This is not unlike AC_TRY_COMPILE, but there's no default includes or
480 dnl anything in "asm-code", everything wanted must be given explicitly.
482 AC_DEFUN([GMP_TRY_ASSEMBLE],
483 [cat >conftest.s <<EOF
486 gmp_assemble="$CC $CFLAGS $CPPFLAGS -c conftest.s >conftest.out 2>&1"
487 if AC_TRY_EVAL(gmp_assemble); then
488 cat conftest.out >&AC_FD_CC
491 cat conftest.out >&AC_FD_CC
492 echo "configure: failed program was:" >&AC_FD_CC
493 cat conftest.s >&AC_FD_CC
499 dnl GMP_PROG_CC_FOR_BUILD
500 dnl ---------------------
501 dnl Establish CC_FOR_BUILD, a C compiler for the build system.
503 dnl If CC_FOR_BUILD is set then it's expected to work, likewise the old
504 dnl style HOST_CC, otherwise some likely candidates are tried, the same as
507 AC_DEFUN([GMP_PROG_CC_FOR_BUILD],
508 [AC_REQUIRE([AC_PROG_CC])
509 if test -n "$CC_FOR_BUILD"; then
510 GMP_PROG_CC_FOR_BUILD_WORKS($CC_FOR_BUILD,,
511 [AC_MSG_ERROR([Specified CC_FOR_BUILD doesn't seem to work])])
512 elif test -n "$HOST_CC"; then
513 GMP_PROG_CC_FOR_BUILD_WORKS($HOST_CC,
514 [CC_FOR_BUILD=$HOST_CC],
515 [AC_MSG_ERROR([Specified HOST_CC doesn't seem to work])])
516 elif test $cross_compiling = no ; then
519 for i in cc gcc c89 c99; do
520 GMP_PROG_CC_FOR_BUILD_WORKS($i,
524 if test -z "$CC_FOR_BUILD"; then
525 AC_MSG_ERROR([Cannot find a build system compiler])
529 AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
530 AC_SUBST(CC_FOR_BUILD)
534 dnl GMP_PROG_CC_FOR_BUILD_WORKS(cc/cflags[,[action-if-good][,action-if-bad]])
535 dnl -------------------------------------------------------------------------
536 dnl See if the given cc/cflags works on the build system.
538 dnl It seems easiest to just use the default compiler output, rather than
539 dnl figuring out the .exe or whatever at this stage.
541 AC_DEFUN([GMP_PROG_CC_FOR_BUILD_WORKS],
542 [AC_MSG_CHECKING([build system compiler $1])
543 # remove anything that might look like compiler output to our "||" expression
544 rm -f conftest* a.out b.out a.exe a_out.exe
545 cat >conftest.c <<EOF
552 gmp_compile="$1 conftest.c"
553 cc_for_build_works=no
554 if AC_TRY_EVAL(gmp_compile); then
555 if (./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest) >&AC_FD_CC 2>&1; then
556 cc_for_build_works=yes
559 rm -f conftest* a.out b.out a.exe a_out.exe
560 AC_MSG_RESULT($cc_for_build_works)
561 if test "$cc_for_build_works" = yes; then
568 dnl GMP_PROG_EXEEXT_FOR_BUILD
569 dnl -------------------------
570 dnl Determine EXEEXT_FOR_BUILD, the build system executable suffix.
572 dnl The idea is to find what "-o conftest$foo" will make it possible to run
573 dnl the program with ./conftest. On Unix-like systems this is of course
574 dnl nothing, for DOS it's ".exe", or for a strange RISC OS foreign file
575 dnl system cross compile it can be ",ff8" apparently. Not sure if the
576 dnl latter actually applies to a build-system executable, maybe it doesn't,
577 dnl but it won't hurt to try.
579 AC_DEFUN([GMP_PROG_EXEEXT_FOR_BUILD],
580 [AC_REQUIRE([GMP_PROG_CC_FOR_BUILD])
581 AC_CACHE_CHECK([for build system executable suffix],
582 gmp_cv_prog_exeext_for_build,
583 [if test $cross_compiling = no ; then
584 gmp_cv_prog_exeext_for_build="$EXEEXT"
586 cat >conftest.c <<EOF
593 for i in .exe ,ff8 ""; do
594 gmp_compile="$CC_FOR_BUILD conftest.c -o conftest$i"
595 if AC_TRY_EVAL(gmp_compile); then
596 if (./conftest) 2>&AC_FD_CC; then
597 gmp_cv_prog_exeext_for_build=$i
603 if test "${gmp_cv_prog_exeext_for_build+set}" != set; then
604 AC_MSG_ERROR([Cannot determine executable suffix])
608 AC_SUBST(EXEEXT_FOR_BUILD,$gmp_cv_prog_exeext_for_build)
611 dnl NETTLE_CHECK_ARM_NEON
612 dnl ---------------------
613 dnl Check if ARM Neon instructions should be used.
614 dnl Obeys enable_arm_neon, which should be set earlier.
615 AC_DEFUN([NETTLE_CHECK_ARM_NEON],
616 [if test "$enable_arm_neon" = auto ; then
617 if test "$cross_compiling" = yes ; then
618 dnl Check if compiler/assembler accepts it,
619 dnl without an explicit .fpu neon directive.
620 AC_CACHE_CHECK([if assembler accepts Neon instructions],
621 nettle_cv_asm_arm_neon,
627 [nettle_cv_asm_arm_neon=yes],
628 [nettle_cv_asm_arm_neon=no])])
629 enable_arm_neon="$nettle_cv_asm_arm_neon"
631 AC_MSG_CHECKING([if /proc/cpuinfo claims neon support])
632 if grep '^Features.*:.* neon' /proc/cpuinfo >/dev/null ; then
637 AC_MSG_RESULT($enable_arm_neon)
642 dnl @synopsis AX_CREATE_STDINT_H [( HEADER-TO-GENERATE [, HEADERS-TO-CHECK])]
644 dnl the "ISO C9X: 7.18 Integer types <stdint.h>" section requires the
645 dnl existence of an include file <stdint.h> that defines a set of
646 dnl typedefs, especially uint8_t,int32_t,uintptr_t.
647 dnl Many older installations will not provide this file, but some will
648 dnl have the very same definitions in <inttypes.h>. In other enviroments
649 dnl we can use the inet-types in <sys/types.h> which would define the
650 dnl typedefs int8_t and u_int8_t respectivly.
652 dnl This macros will create a local "_stdint.h" or the headerfile given as
653 dnl an argument. In many cases that file will just "#include <stdint.h>"
654 dnl or "#include <inttypes.h>", while in other environments it will provide
655 dnl the set of basic 'stdint's definitions/typedefs:
656 dnl int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t
657 dnl int_least32_t.. int_fast32_t.. intmax_t
658 dnl which may or may not rely on the definitions of other files,
659 dnl or using the AC_CHECK_SIZEOF macro to determine the actual
660 dnl sizeof each type.
662 dnl if your header files require the stdint-types you will want to create an
663 dnl installable file mylib-int.h that all your other installable header
664 dnl may include. So if you have a library package named "mylib", just use
665 dnl AX_CREATE_STDINT_H(mylib-int.h)
666 dnl in configure.ac and go to install that very header file in Makefile.am
667 dnl along with the other headers (mylib.h) - and the mylib-specific headers
668 dnl can simply use "#include <mylib-int.h>" to obtain the stdint-types.
670 dnl Remember, if the system already had a valid <stdint.h>, the generated
671 dnl file will include it directly. No need for fuzzy HAVE_STDINT_H things...
673 dnl @, (status: used on new platforms) (see http://ac-archive.sf.net/gstdint/)
674 dnl @author Guido Draheim <guidod@gmx.de>
676 AC_DEFUN([AX_CREATE_STDINT_H],
677 [# ------ AX CREATE STDINT H -------------------------------------
678 AC_MSG_CHECKING([for stdint types])
679 ac_stdint_h=`echo ifelse($1, , _stdint.h, $1)`
680 # try to shortcircuit - if the default include path of the compiler
681 # can find a "stdint.h" header then we assume that all compilers can.
682 AC_CACHE_VAL([ac_cv_header_stdint_t],[
683 old_CXXFLAGS="$CXXFLAGS" ; CXXFLAGS=""
684 old_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS=""
685 old_CFLAGS="$CFLAGS" ; CFLAGS=""
686 AC_TRY_COMPILE([#include <stdint.h>],[int_least32_t v = 0;],
687 [ac_cv_stdint_result="(assuming C99 compatible system)"
688 ac_cv_header_stdint_t="stdint.h"; ],
689 [ac_cv_header_stdint_t=""])
690 CXXFLAGS="$old_CXXFLAGS"
691 CPPFLAGS="$old_CPPFLAGS"
692 CFLAGS="$old_CFLAGS" ])
694 v="... $ac_cv_header_stdint_h"
695 if test "$ac_stdint_h" = "stdint.h" ; then
696 AC_MSG_RESULT([(are you sure you want them in ./stdint.h?)])
697 elif test "$ac_stdint_h" = "inttypes.h" ; then
698 AC_MSG_RESULT([(are you sure you want them in ./inttypes.h?)])
699 elif test "_$ac_cv_header_stdint_t" = "_" ; then
700 AC_MSG_RESULT([(putting them into $ac_stdint_h)$v])
702 ac_cv_header_stdint="$ac_cv_header_stdint_t"
703 AC_MSG_RESULT([$ac_cv_header_stdint (shortcircuit)])
706 if test "_$ac_cv_header_stdint_t" = "_" ; then # can not shortcircuit..
708 dnl .....intro message done, now do a few system checks.....
709 dnl btw, all CHECK_TYPE macros do automatically "DEFINE" a type, therefore
710 dnl we use the autoconf implementation detail _AC CHECK_TYPE_NEW instead
712 inttype_headers=`echo $2 | sed -e 's/,/ /g'`
714 ac_cv_stdint_result="(no helpful system typedefs seen)"
715 AC_CACHE_CHECK([for stdint uintptr_t], [ac_cv_header_stdint_x],[
716 ac_cv_header_stdint_x="" # the 1997 typedefs (inttypes.h)
717 AC_MSG_RESULT([(..)])
718 for i in stdint.h inttypes.h sys/inttypes.h $inttype_headers ; do
719 unset ac_cv_type_uintptr_t
720 unset ac_cv_type_uint64_t
721 _AC_CHECK_TYPE_NEW(uintptr_t,[ac_cv_header_stdint_x=$i],dnl
722 continue,[#include <$i>])
723 AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
724 ac_cv_stdint_result="(seen uintptr_t$and64 in $i)"
727 AC_MSG_CHECKING([for stdint uintptr_t])
730 if test "_$ac_cv_header_stdint_x" = "_" ; then
731 AC_CACHE_CHECK([for stdint uint32_t], [ac_cv_header_stdint_o],[
732 ac_cv_header_stdint_o="" # the 1995 typedefs (sys/inttypes.h)
733 AC_MSG_RESULT([(..)])
734 for i in inttypes.h sys/inttypes.h stdint.h $inttype_headers ; do
735 unset ac_cv_type_uint32_t
736 unset ac_cv_type_uint64_t
737 AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],dnl
738 continue,[#include <$i>])
739 AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
740 ac_cv_stdint_result="(seen uint32_t$and64 in $i)"
743 AC_MSG_CHECKING([for stdint uint32_t])
747 if test "_$ac_cv_header_stdint_x" = "_" ; then
748 if test "_$ac_cv_header_stdint_o" = "_" ; then
749 AC_CACHE_CHECK([for stdint u_int32_t], [ac_cv_header_stdint_u],[
750 ac_cv_header_stdint_u="" # the BSD typedefs (sys/types.h)
751 AC_MSG_RESULT([(..)])
752 for i in sys/types.h inttypes.h sys/inttypes.h $inttype_headers ; do
753 unset ac_cv_type_u_int32_t
754 unset ac_cv_type_u_int64_t
755 AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],dnl
756 continue,[#include <$i>])
757 AC_CHECK_TYPE(u_int64_t,[and64="/u_int64_t"],[and64=""],[#include<$i>])
758 ac_cv_stdint_result="(seen u_int32_t$and64 in $i)"
761 AC_MSG_CHECKING([for stdint u_int32_t])
765 dnl if there was no good C99 header file, do some typedef checks...
766 if test "_$ac_cv_header_stdint_x" = "_" ; then
767 AC_MSG_CHECKING([for stdint datatype model])
768 AC_MSG_RESULT([(..)])
769 AC_CHECK_SIZEOF(char)
770 AC_CHECK_SIZEOF(short)
772 AC_CHECK_SIZEOF(long)
773 AC_CHECK_SIZEOF(void*)
774 ac_cv_stdint_char_model=""
775 ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_char"
776 ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_short"
777 ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_int"
778 ac_cv_stdint_long_model=""
779 ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_int"
780 ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_long"
781 ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_voidp"
782 name="$ac_cv_stdint_long_model"
783 case "$ac_cv_stdint_char_model/$ac_cv_stdint_long_model" in
784 122/242) name="$name, IP16 (standard 16bit machine)" ;;
785 122/244) name="$name, LP32 (standard 32bit mac/win)" ;;
786 122/*) name="$name (unusual int16 model)" ;;
787 124/444) name="$name, ILP32 (standard 32bit unixish)" ;;
788 124/488) name="$name, LP64 (standard 64bit unixish)" ;;
789 124/448) name="$name, LLP64 (unusual 64bit unixish)" ;;
790 124/*) name="$name (unusual int32 model)" ;;
791 128/888) name="$name, ILP64 (unusual 64bit numeric)" ;;
792 128/*) name="$name (unusual int64 model)" ;;
793 222/*|444/*) name="$name (unusual dsptype)" ;;
794 *) name="$name (very unusal model)" ;;
796 AC_MSG_RESULT([combined for stdint datatype model... $name])
799 if test "_$ac_cv_header_stdint_x" != "_" ; then
800 ac_cv_header_stdint="$ac_cv_header_stdint_x"
801 elif test "_$ac_cv_header_stdint_o" != "_" ; then
802 ac_cv_header_stdint="$ac_cv_header_stdint_o"
803 elif test "_$ac_cv_header_stdint_u" != "_" ; then
804 ac_cv_header_stdint="$ac_cv_header_stdint_u"
806 ac_cv_header_stdint="stddef.h"
809 AC_MSG_CHECKING([for extra inttypes in chosen header])
810 AC_MSG_RESULT([($ac_cv_header_stdint)])
811 dnl see if int_least and int_fast types are present in _this_ header.
812 unset ac_cv_type_int_least32_t
813 unset ac_cv_type_int_fast32_t
814 AC_CHECK_TYPE(int_least32_t,,,[#include <$ac_cv_header_stdint>])
815 AC_CHECK_TYPE(int_fast32_t,,,[#include<$ac_cv_header_stdint>])
816 AC_CHECK_TYPE(intmax_t,,,[#include <$ac_cv_header_stdint>])
818 fi # shortcircut to system "stdint.h"
819 # ------------------ PREPARE VARIABLES ------------------------------
820 if test "$GCC" = "yes" ; then
821 ac_cv_stdint_message="using gnu compiler "`$CC --version | head -1`
823 ac_cv_stdint_message="using $CC"
826 AC_MSG_RESULT([make use of $ac_cv_header_stdint in $ac_stdint_h dnl
827 $ac_cv_stdint_result])
829 # ----------------- DONE inttypes.h checks START header -------------
830 AC_CONFIG_COMMANDS([$ac_stdint_h],[
831 AC_MSG_NOTICE(creating $ac_stdint_h : $_ac_stdint_h)
832 ac_stdint=$tmp/_stdint.h
834 echo "#ifndef" $_ac_stdint_h >$ac_stdint
835 echo "#define" $_ac_stdint_h "1" >>$ac_stdint
836 echo "#ifndef" _GENERATED_STDINT_H >>$ac_stdint
837 echo "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdint
838 echo "/* generated $ac_cv_stdint_message */" >>$ac_stdint
839 if test "_$ac_cv_header_stdint_t" != "_" ; then
840 echo "#define _STDINT_HAVE_STDINT_H" "1" >>$ac_stdint
843 cat >>$ac_stdint <<STDINT_EOF
845 /* ................... shortcircuit part ........................... */
847 #if defined HAVE_STDINT_H || defined _STDINT_HAVE_STDINT_H
852 /* .................... configured part ............................ */
856 echo "/* whether we have a C99 compatible stdint header file */" >>$ac_stdint
857 if test "_$ac_cv_header_stdint_x" != "_" ; then
858 ac_header="$ac_cv_header_stdint_x"
859 echo "#define _STDINT_HEADER_INTPTR" '"'"$ac_header"'"' >>$ac_stdint
861 echo "/* #undef _STDINT_HEADER_INTPTR */" >>$ac_stdint
864 echo "/* whether we have a C96 compatible inttypes header file */" >>$ac_stdint
865 if test "_$ac_cv_header_stdint_o" != "_" ; then
866 ac_header="$ac_cv_header_stdint_o"
867 echo "#define _STDINT_HEADER_UINT32" '"'"$ac_header"'"' >>$ac_stdint
869 echo "/* #undef _STDINT_HEADER_UINT32 */" >>$ac_stdint
872 echo "/* whether we have a BSD compatible inet types header */" >>$ac_stdint
873 if test "_$ac_cv_header_stdint_u" != "_" ; then
874 ac_header="$ac_cv_header_stdint_u"
875 echo "#define _STDINT_HEADER_U_INT32" '"'"$ac_header"'"' >>$ac_stdint
877 echo "/* #undef _STDINT_HEADER_U_INT32 */" >>$ac_stdint
882 if test "_$ac_header" != "_" ; then if test "$ac_header" != "stddef.h" ; then
883 echo "#include <$ac_header>" >>$ac_stdint
887 echo "/* which 64bit typedef has been found */" >>$ac_stdint
888 if test "$ac_cv_type_uint64_t" = "yes" ; then
889 echo "#define _STDINT_HAVE_UINT64_T" "1" >>$ac_stdint
891 echo "/* #undef _STDINT_HAVE_UINT64_T */" >>$ac_stdint
893 if test "$ac_cv_type_u_int64_t" = "yes" ; then
894 echo "#define _STDINT_HAVE_U_INT64_T" "1" >>$ac_stdint
896 echo "/* #undef _STDINT_HAVE_U_INT64_T */" >>$ac_stdint
900 echo "/* which type model has been detected */" >>$ac_stdint
901 if test "_$ac_cv_stdint_char_model" != "_" ; then
902 echo "#define _STDINT_CHAR_MODEL" "$ac_cv_stdint_char_model" >>$ac_stdint
903 echo "#define _STDINT_LONG_MODEL" "$ac_cv_stdint_long_model" >>$ac_stdint
905 echo "/* #undef _STDINT_CHAR_MODEL // skipped */" >>$ac_stdint
906 echo "/* #undef _STDINT_LONG_MODEL // skipped */" >>$ac_stdint
910 echo "/* whether int_least types were detected */" >>$ac_stdint
911 if test "$ac_cv_type_int_least32_t" = "yes"; then
912 echo "#define _STDINT_HAVE_INT_LEAST32_T" "1" >>$ac_stdint
914 echo "/* #undef _STDINT_HAVE_INT_LEAST32_T */" >>$ac_stdint
916 echo "/* whether int_fast types were detected */" >>$ac_stdint
917 if test "$ac_cv_type_int_fast32_t" = "yes"; then
918 echo "#define _STDINT_HAVE_INT_FAST32_T" "1" >>$ac_stdint
920 echo "/* #undef _STDINT_HAVE_INT_FAST32_T */" >>$ac_stdint
922 echo "/* whether intmax_t type was detected */" >>$ac_stdint
923 if test "$ac_cv_type_intmax_t" = "yes"; then
924 echo "#define _STDINT_HAVE_INTMAX_T" "1" >>$ac_stdint
926 echo "/* #undef _STDINT_HAVE_INTMAX_T */" >>$ac_stdint
930 cat >>$ac_stdint <<STDINT_EOF
931 /* .................... detections part ............................ */
933 /* whether we need to define bitspecific types from compiler base types */
934 #ifndef _STDINT_HEADER_INTPTR
935 #ifndef _STDINT_HEADER_UINT32
936 #ifndef _STDINT_HEADER_U_INT32
937 #define _STDINT_NEED_INT_MODEL_T
939 #define _STDINT_HAVE_U_INT_TYPES
944 #ifdef _STDINT_HAVE_U_INT_TYPES
945 #undef _STDINT_NEED_INT_MODEL_T
948 #ifdef _STDINT_CHAR_MODEL
949 #if _STDINT_CHAR_MODEL+0 == 122 || _STDINT_CHAR_MODEL+0 == 124
950 #ifndef _STDINT_BYTE_MODEL
951 #define _STDINT_BYTE_MODEL 12
956 #ifndef _STDINT_HAVE_INT_LEAST32_T
957 #define _STDINT_NEED_INT_LEAST_T
960 #ifndef _STDINT_HAVE_INT_FAST32_T
961 #define _STDINT_NEED_INT_FAST_T
964 #ifndef _STDINT_HEADER_INTPTR
965 #define _STDINT_NEED_INTPTR_T
966 #ifndef _STDINT_HAVE_INTMAX_T
967 #define _STDINT_NEED_INTMAX_T
972 /* .................... definition part ............................ */
974 /* some system headers have good uint64_t */
975 #ifndef _HAVE_UINT64_T
976 #if defined _STDINT_HAVE_UINT64_T || defined HAVE_UINT64_T
977 #define _HAVE_UINT64_T
978 #elif defined _STDINT_HAVE_U_INT64_T || defined HAVE_U_INT64_T
979 #define _HAVE_UINT64_T
980 typedef u_int64_t uint64_t;
984 #ifndef _HAVE_UINT64_T
985 /* .. here are some common heuristics using compiler runtime specifics */
986 #if defined __STDC_VERSION__ && defined __STDC_VERSION__ >= 199901L
987 #define _HAVE_UINT64_T
988 typedef long long int64_t;
989 typedef unsigned long long uint64_t;
991 #elif !defined __STRICT_ANSI__
992 #if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__
993 #define _HAVE_UINT64_T
994 typedef __int64 int64_t;
995 typedef unsigned __int64 uint64_t;
997 #elif defined __GNUC__ || defined __MWERKS__ || defined __ELF__
998 /* note: all ELF-systems seem to have loff-support which needs 64-bit */
999 #if !defined _NO_LONGLONG
1000 #define _HAVE_UINT64_T
1001 typedef long long int64_t;
1002 typedef unsigned long long uint64_t;
1005 #elif defined __alpha || (defined __mips && defined _ABIN32)
1006 #if !defined _NO_LONGLONG
1007 typedef long int64_t;
1008 typedef unsigned long uint64_t;
1010 /* compiler/cpu type to define int64_t */
1015 #if defined _STDINT_HAVE_U_INT_TYPES
1016 /* int8_t int16_t int32_t defined by inet code, redeclare the u_intXX types */
1017 typedef u_int8_t uint8_t;
1018 typedef u_int16_t uint16_t;
1019 typedef u_int32_t uint32_t;
1021 /* glibc compatibility */
1022 #ifndef __int8_t_defined
1023 #define __int8_t_defined
1027 #ifdef _STDINT_NEED_INT_MODEL_T
1028 /* we must guess all the basic types. Apart from byte-adressable system, */
1029 /* there a few 32-bit-only dsp-systems that we guard with BYTE_MODEL 8-} */
1030 /* (btw, those nibble-addressable systems are way off, or so we assume) */
1032 dnl /* have a look at "64bit and data size neutrality" at */
1033 dnl /* http://unix.org/version2/whatsnew/login_64bit.html */
1034 dnl /* (the shorthand "ILP" types always have a "P" part) */
1036 #if defined _STDINT_BYTE_MODEL
1037 #if _STDINT_LONG_MODEL+0 == 242
1038 /* 2:4:2 = IP16 = a normal 16-bit system */
1039 typedef unsigned char uint8_t;
1040 typedef unsigned short uint16_t;
1041 typedef unsigned long uint32_t;
1042 #ifndef __int8_t_defined
1043 #define __int8_t_defined
1044 typedef char int8_t;
1045 typedef short int16_t;
1046 typedef long int32_t;
1048 #elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL == 444
1049 /* 2:4:4 = LP32 = a 32-bit system derived from a 16-bit */
1050 /* 4:4:4 = ILP32 = a normal 32-bit system */
1051 typedef unsigned char uint8_t;
1052 typedef unsigned short uint16_t;
1053 typedef unsigned int uint32_t;
1054 #ifndef __int8_t_defined
1055 #define __int8_t_defined
1056 typedef char int8_t;
1057 typedef short int16_t;
1058 typedef int int32_t;
1060 #elif _STDINT_LONG_MODEL+0 == 484 || _STDINT_LONG_MODEL+0 == 488
1061 /* 4:8:4 = IP32 = a 32-bit system prepared for 64-bit */
1062 /* 4:8:8 = LP64 = a normal 64-bit system */
1063 typedef unsigned char uint8_t;
1064 typedef unsigned short uint16_t;
1065 typedef unsigned int uint32_t;
1066 #ifndef __int8_t_defined
1067 #define __int8_t_defined
1068 typedef char int8_t;
1069 typedef short int16_t;
1070 typedef int int32_t;
1072 /* this system has a "long" of 64bit */
1073 #ifndef _HAVE_UINT64_T
1074 #define _HAVE_UINT64_T
1075 typedef unsigned long uint64_t;
1076 typedef long int64_t;
1078 #elif _STDINT_LONG_MODEL+0 == 448
1079 /* LLP64 a 64-bit system derived from a 32-bit system */
1080 typedef unsigned char uint8_t;
1081 typedef unsigned short uint16_t;
1082 typedef unsigned int uint32_t;
1083 #ifndef __int8_t_defined
1084 #define __int8_t_defined
1085 typedef char int8_t;
1086 typedef short int16_t;
1087 typedef int int32_t;
1089 /* assuming the system has a "long long" */
1090 #ifndef _HAVE_UINT64_T
1091 #define _HAVE_UINT64_T
1092 typedef unsigned long long uint64_t;
1093 typedef long long int64_t;
1096 #define _STDINT_NO_INT32_T
1099 #define _STDINT_NO_INT8_T
1100 #define _STDINT_NO_INT32_T
1105 * quote from SunOS-5.8 sys/inttypes.h:
1106 * Use at your own risk. As of February 1996, the committee is squarely
1107 * behind the fixed sized types; the "least" and "fast" types are still being
1108 * discussed. The probability that the "fast" types may be removed before
1109 * the standard is finalized is high enough that they are not currently
1113 #if defined _STDINT_NEED_INT_LEAST_T
1114 typedef int8_t int_least8_t;
1115 typedef int16_t int_least16_t;
1116 typedef int32_t int_least32_t;
1117 #ifdef _HAVE_UINT64_T
1118 typedef int64_t int_least64_t;
1121 typedef uint8_t uint_least8_t;
1122 typedef uint16_t uint_least16_t;
1123 typedef uint32_t uint_least32_t;
1124 #ifdef _HAVE_UINT64_T
1125 typedef uint64_t uint_least64_t;
1130 #if defined _STDINT_NEED_INT_FAST_T
1131 typedef int8_t int_fast8_t;
1132 typedef int int_fast16_t;
1133 typedef int32_t int_fast32_t;
1134 #ifdef _HAVE_UINT64_T
1135 typedef int64_t int_fast64_t;
1138 typedef uint8_t uint_fast8_t;
1139 typedef unsigned uint_fast16_t;
1140 typedef uint32_t uint_fast32_t;
1141 #ifdef _HAVE_UINT64_T
1142 typedef uint64_t uint_fast64_t;
1147 #ifdef _STDINT_NEED_INTMAX_T
1148 #ifdef _HAVE_UINT64_T
1149 typedef int64_t intmax_t;
1150 typedef uint64_t uintmax_t;
1152 typedef long intmax_t;
1153 typedef unsigned long uintmax_t;
1157 #ifdef _STDINT_NEED_INTPTR_T
1158 #ifndef __intptr_t_defined
1159 #define __intptr_t_defined
1160 /* we encourage using "long" to store pointer values, never use "int" ! */
1161 #if _STDINT_LONG_MODEL+0 == 242 || _STDINT_LONG_MODEL+0 == 484
1162 typedef unsinged int uintptr_t;
1163 typedef int intptr_t;
1164 #elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL+0 == 444
1165 typedef unsigned long uintptr_t;
1166 typedef long intptr_t;
1167 #elif _STDINT_LONG_MODEL+0 == 448 && defined _HAVE_UINT64_T
1168 typedef uint64_t uintptr_t;
1169 typedef int64_t intptr_t;
1170 #else /* matches typical system types ILP32 and LP64 - but not IP16 or LLP64 */
1171 typedef unsigned long uintptr_t;
1172 typedef long intptr_t;
1183 if cmp -s $ac_stdint_h $ac_stdint 2>/dev/null; then
1184 AC_MSG_NOTICE([$ac_stdint_h is unchanged])
1186 ac_dir=`AS_DIRNAME(["$ac_stdint_h"])`
1187 AS_MKDIR_P(["$ac_dir"])
1189 mv $ac_stdint $ac_stdint_h
1191 ],[# variables for create stdint.h replacement
1194 ac_stdint_h="$ac_stdint_h"
1195 _ac_stdint_h=AS_TR_CPP(_$PACKAGE-$ac_stdint_h)
1196 ac_cv_stdint_message="$ac_cv_stdint_message"
1197 ac_cv_header_stdint_t="$ac_cv_header_stdint_t"
1198 ac_cv_header_stdint_x="$ac_cv_header_stdint_x"
1199 ac_cv_header_stdint_o="$ac_cv_header_stdint_o"
1200 ac_cv_header_stdint_u="$ac_cv_header_stdint_u"
1201 ac_cv_type_uint64_t="$ac_cv_type_uint64_t"
1202 ac_cv_type_u_int64_t="$ac_cv_type_u_int64_t"
1203 ac_cv_stdint_char_model="$ac_cv_stdint_char_model"
1204 ac_cv_stdint_long_model="$ac_cv_stdint_long_model"
1205 ac_cv_type_int_least32_t="$ac_cv_type_int_least32_t"
1206 ac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t"
1207 ac_cv_type_intmax_t="$ac_cv_type_intmax_t"