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"
61 AC_MSG_RESULT($CCPIC)])
63 dnl LSH_PATH_ADD(path-id, directory)
64 AC_DEFUN([LSH_PATH_ADD],
67 if test -d "$2/." ; then
68 ac_real_dir=`cd $2 && pwd`
69 if test -n "$ac_real_dir" ; then
71 for old in $1_REAL_DIRS ; do
73 if test x$ac_real_dir = x$old ; then
78 if test $ac_found = yes ; then
79 AC_MSG_RESULT(already added)
82 # LDFLAGS="$LDFLAGS -L $2"
83 $1_REAL_DIRS="$ac_real_dir [$]$1_REAL_DIRS"
84 $1_DIRS="$2 [$]$1_DIRS"
88 if test $ac_exists = no ; then
89 AC_MSG_RESULT(not found)
93 dnl LSH_RPATH_ADD(dir)
94 AC_DEFUN([LSH_RPATH_ADD], [LSH_PATH_ADD(RPATH_CANDIDATE, $1)])
96 dnl LSH_RPATH_INIT(candidates)
97 AC_DEFUN([LSH_RPATH_INIT],
98 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
99 AC_MSG_CHECKING([for -R flag])
102 osf1*) RPATHFLAG="-rpath " ;;
103 irix6.*|irix5.*) RPATHFLAG="-rpath " ;;
105 if test "$TCC" = "yes"; then
106 # tcc doesn't know about -R
112 linux*|freebsd*) RPATHFLAG="-Wl,-rpath," ;;
116 if test x$RPATHFLAG = x ; then
119 AC_MSG_RESULT([using $RPATHFLAG])
122 RPATH_CANDIDATE_REAL_DIRS=''
123 RPATH_CANDIDATE_DIRS=''
125 AC_MSG_RESULT([Searching for libraries])
132 dnl Try to execute a main program, and if it fails, try adding some
135 AC_DEFUN([LSH_RPATH_FIX],
136 [if test $cross_compiling = no -a "x$RPATHFLAG" != x ; then
138 AC_TRY_RUN([int main(int argc, char **argv) { return 0; }],
139 ac_success=yes, ac_success=no, :)
141 if test $ac_success = no ; then
142 AC_MSG_CHECKING([Running simple test program failed. Trying -R flags])
143 dnl echo RPATH_CANDIDATE_DIRS = $RPATH_CANDIDATE_DIRS
145 ac_rpath_save_LDFLAGS="$LDFLAGS"
146 for d in $RPATH_CANDIDATE_DIRS ; do
147 if test $ac_success = yes ; then
148 ac_remaining_dirs="$ac_remaining_dirs $d"
150 LDFLAGS="$RPATHFLAG$d $LDFLAGS"
151 dnl echo LDFLAGS = $LDFLAGS
152 AC_TRY_RUN([int main(int argc, char **argv) { return 0; }],
154 ac_rpath_save_LDFLAGS="$LDFLAGS"
155 AC_MSG_RESULT([adding $RPATHFLAG$d])
157 [ac_remaining_dirs="$ac_remaining_dirs $d"], :)
158 LDFLAGS="$ac_rpath_save_LDFLAGS"
161 RPATH_CANDIDATE_DIRS=$ac_remaining_dirs
163 if test $ac_success = no ; then
164 AC_MSG_RESULT(failed)
169 dnl Like AC_CHECK_LIB, but uses $KRB_LIBS rather than $LIBS.
170 dnl LSH_CHECK_KRB_LIB(LIBRARY, FUNCTION, [, ACTION-IF-FOUND [,
171 dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
173 AC_DEFUN([LSH_CHECK_KRB_LIB],
174 [AC_CHECK_LIB([$1], [$2],
176 [[ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
177 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
178 AC_DEFINE_UNQUOTED($ac_tr_lib)
179 KRB_LIBS="-l$1 $KRB_LIBS"
186 dnl LSH_LIB_ARGP(ACTION-IF-OK, ACTION-IF-BAD)
187 AC_DEFUN([LSH_LIB_ARGP],
188 [ ac_argp_save_LIBS="$LIBS"
189 ac_argp_save_LDFLAGS="$LDFLAGS"
191 # First check if we can link with argp.
192 AC_SEARCH_LIBS(argp_parse, argp,
194 AC_CACHE_CHECK([for working argp],
195 lsh_cv_lib_argp_works,
200 static const struct argp_option
203 { NULL, 0, NULL, 0, NULL, 0 }
212 child_parser(int key, char *arg, struct argp_state *state)
214 struct child_state *input = (struct child_state *) state->input;
219 return ARGP_ERR_UNKNOWN;
228 const struct argp child_argp =
232 NULL, NULL, NULL, NULL, NULL
237 struct child_state child;
242 main_parser(int key, char *arg, struct argp_state *state)
244 struct main_state *input = (struct main_state *) state->input;
249 return ARGP_ERR_UNKNOWN;
251 state->child_inputs[0] = &input->child;
255 input->m = input->child.n;
262 static const struct argp_child
265 { &child_argp, 0, "", 0 },
269 static const struct argp
271 { options, main_parser,
278 int main(int argc, char **argv)
280 struct main_state input = { { 0 }, 0 };
281 char *v[2] = { "foo", NULL };
283 argp_parse(&main_argp, 1, v, 0, NULL, &input);
285 if ( (input.m == 1) && (input.child.n == 1) )
290 ], lsh_cv_lib_argp_works=yes,
291 lsh_cv_lib_argp_works=no,
292 lsh_cv_lib_argp_works=no)])
294 if test x$lsh_cv_lib_argp_works = xyes ; then
298 LIBS="$ac_argp_save_LIBS"
299 LDFLAGS="$ac_argp_save_LDFLAGS"
302 if test x$ac_argp_ok = xyes ; then
303 ifelse([$1],, true, [$1])
305 ifelse([$2],, true, [$2])
309 dnl LSH_GCC_ATTRIBUTES
310 dnl Check for gcc's __attribute__ construction
312 AC_DEFUN([LSH_GCC_ATTRIBUTES],
313 [AC_CACHE_CHECK(for __attribute__,
318 static void foo(void) __attribute__ ((noreturn));
320 static void __attribute__ ((noreturn))
326 lsh_cv_c_attribute=yes,
327 lsh_cv_c_attribute=no)])
329 AH_TEMPLATE([HAVE_GCC_ATTRIBUTE], [Define if the compiler understands __attribute__])
330 if test "x$lsh_cv_c_attribute" = "xyes"; then
331 AC_DEFINE(HAVE_GCC_ATTRIBUTE)
335 [#if __GNUC__ && HAVE_GCC_ATTRIBUTE
336 # define NORETURN __attribute__ ((__noreturn__))
337 # define PRINTF_STYLE(f, a) __attribute__ ((__format__ (__printf__, f, a)))
338 # define UNUSED __attribute__ ((__unused__))
341 # define PRINTF_STYLE(f, a)
346 # Check for alloca, and include the standard blurb in config.h
347 AC_DEFUN([LSH_FUNC_ALLOCA],
349 AC_CHECK_HEADERS([malloc.h])
351 [/* AIX requires this to be the first thing in the file. */
359 # ifndef alloca /* predefined by HP cc +Olibcalls */
363 /* Needed for alloca on windows */
368 #else /* defined __GNUC__ */
372 /* Needed for alloca on windows, also with gcc */
380 AC_DEFUN([LSH_FUNC_STRERROR],
381 [AC_CHECK_FUNCS(strerror)
384 #define STRERROR strerror
386 #define STRERROR(x) (sys_errlist[x])
390 AC_DEFUN([LSH_FUNC_STRSIGNAL],
391 [AC_CHECK_FUNCS(strsignal)
392 AC_CHECK_DECLS([sys_siglist, _sys_siglist])
395 # define STRSIGNAL strsignal
396 #else /* !HAVE_STRSIGNAL */
397 # if HAVE_DECL_SYS_SIGLIST
398 # define STRSIGNAL(x) (sys_siglist[x])
400 # if HAVE_DECL__SYS_SIGLIST
401 # define STRSIGNAL(x) (_sys_siglist[x])
403 # define STRSIGNAL(x) "Unknown signal"
405 # warning Using dummy STRSIGNAL
409 #endif /* !HAVE_STRSIGNAL */
412 dnl LSH_MAKE_CONDITIONAL(symbol, test)
413 AC_DEFUN([LSH_MAKE_CONDITIONAL],
422 AC_SUBST(UNLESS_$1)])
424 dnl LSH_DEPENDENCY_TRACKING
426 dnl Defines compiler flags DEP_FLAGS to generate dependency
427 dnl information, and DEP_PROCESS that is any shell commands needed for
428 dnl massaging the dependency information further. Dependencies are
429 dnl generated as a side effect of compilation. Dependency files
430 dnl themselves are not treated as targets.
432 AC_DEFUN([LSH_DEPENDENCY_TRACKING],
433 [AC_ARG_ENABLE(dependency_tracking,
434 AC_HELP_STRING([--disable-dependency-tracking],
435 [Disable dependency tracking. Dependency tracking doesn't work with BSD make]),,
436 [enable_dependency_tracking=yes])
440 if test x$enable_dependency_tracking = xyes ; then
441 if test x$GCC = xyes ; then
442 gcc_version=`gcc --version | head -1`
443 case "$gcc_version" in
445 enable_dependency_tracking=no
446 AC_MSG_WARN([Dependency tracking disabled, gcc-3.x is needed])
449 DEP_FLAGS='-MT $[]@ -MD -MP -MF $[]@.d'
454 enable_dependency_tracking=no
455 AC_MSG_WARN([Dependency tracking disabled])
459 if test x$enable_dependency_tracking = xyes ; then
460 DEP_INCLUDE='include '
465 AC_SUBST([DEP_INCLUDE])
466 AC_SUBST([DEP_FLAGS])
467 AC_SUBST([DEP_PROCESS])])
469 dnl GMP_TRY_ASSEMBLE(asm-code,[action-success][,action-fail])
470 dnl ----------------------------------------------------------
471 dnl Attempt to assemble the given code.
472 dnl Do "action-success" if this succeeds, "action-fail" if not.
474 dnl conftest.o and conftest.out are available for inspection in
475 dnl "action-success". If either action does a "break" out of a loop then
476 dnl an explicit "rm -f conftest*" will be necessary.
478 dnl This is not unlike AC_TRY_COMPILE, but there's no default includes or
479 dnl anything in "asm-code", everything wanted must be given explicitly.
481 AC_DEFUN([GMP_TRY_ASSEMBLE],
482 [cat >conftest.s <<EOF
485 gmp_assemble="$CC $CFLAGS $CPPFLAGS -c conftest.s >conftest.out 2>&1"
486 if AC_TRY_EVAL(gmp_assemble); then
487 cat conftest.out >&AC_FD_CC
490 cat conftest.out >&AC_FD_CC
491 echo "configure: failed program was:" >&AC_FD_CC
492 cat conftest.s >&AC_FD_CC
498 dnl GMP_PROG_CC_FOR_BUILD
499 dnl ---------------------
500 dnl Establish CC_FOR_BUILD, a C compiler for the build system.
502 dnl If CC_FOR_BUILD is set then it's expected to work, likewise the old
503 dnl style HOST_CC, otherwise some likely candidates are tried, the same as
506 AC_DEFUN([GMP_PROG_CC_FOR_BUILD],
507 [AC_REQUIRE([AC_PROG_CC])
508 if test -n "$CC_FOR_BUILD"; then
509 GMP_PROG_CC_FOR_BUILD_WORKS($CC_FOR_BUILD,,
510 [AC_MSG_ERROR([Specified CC_FOR_BUILD doesn't seem to work])])
511 elif test -n "$HOST_CC"; then
512 GMP_PROG_CC_FOR_BUILD_WORKS($HOST_CC,
513 [CC_FOR_BUILD=$HOST_CC],
514 [AC_MSG_ERROR([Specified HOST_CC doesn't seem to work])])
516 if test $cross_compiling = no ; then
519 for i in gcc cc 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])
528 if test "$CC_FOR_BUILD" = gcc ; then
529 CC_FOR_BUILD="$CC_FOR_BUILD -O -g"
533 AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
534 AC_SUBST(CC_FOR_BUILD)
538 dnl GMP_PROG_CC_FOR_BUILD_WORKS(cc/cflags[,[action-if-good][,action-if-bad]])
539 dnl -------------------------------------------------------------------------
540 dnl See if the given cc/cflags works on the build system.
542 dnl It seems easiest to just use the default compiler output, rather than
543 dnl figuring out the .exe or whatever at this stage.
545 AC_DEFUN([GMP_PROG_CC_FOR_BUILD_WORKS],
546 [AC_MSG_CHECKING([build system compiler $1])
547 # remove anything that might look like compiler output to our "||" expression
548 rm -f conftest* a.out b.out a.exe a_out.exe
549 cat >conftest.c <<EOF
556 gmp_compile="$1 conftest.c"
557 cc_for_build_works=no
558 if AC_TRY_EVAL(gmp_compile); then
559 if (./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest) >&AC_FD_CC 2>&1; then
560 cc_for_build_works=yes
563 rm -f conftest* a.out b.out a.exe a_out.exe
564 AC_MSG_RESULT($cc_for_build_works)
565 if test "$cc_for_build_works" = yes; then
572 dnl GMP_PROG_EXEEXT_FOR_BUILD
573 dnl -------------------------
574 dnl Determine EXEEXT_FOR_BUILD, the build system executable suffix.
576 dnl The idea is to find what "-o conftest$foo" will make it possible to run
577 dnl the program with ./conftest. On Unix-like systems this is of course
578 dnl nothing, for DOS it's ".exe", or for a strange RISC OS foreign file
579 dnl system cross compile it can be ",ff8" apparently. Not sure if the
580 dnl latter actually applies to a build-system executable, maybe it doesn't,
581 dnl but it won't hurt to try.
583 AC_DEFUN([GMP_PROG_EXEEXT_FOR_BUILD],
584 [AC_REQUIRE([GMP_PROG_CC_FOR_BUILD])
585 AC_CACHE_CHECK([for build system executable suffix],
586 gmp_cv_prog_exeext_for_build,
587 [if test $cross_compiling = no ; then
588 gmp_cv_prog_exeext_for_build="$EXEEXT"
590 cat >conftest.c <<EOF
597 for i in .exe ,ff8 ""; do
598 gmp_compile="$CC_FOR_BUILD conftest.c -o conftest$i"
599 if AC_TRY_EVAL(gmp_compile); then
600 if (./conftest) 2>&AC_FD_CC; then
601 gmp_cv_prog_exeext_for_build=$i
607 if test "${gmp_cv_prog_exeext_for_build+set}" != set; then
608 AC_MSG_ERROR([Cannot determine executable suffix])
612 AC_SUBST(EXEEXT_FOR_BUILD,$gmp_cv_prog_exeext_for_build)
615 dnl NETTLE_CHECK_ARM_NEON
616 dnl ---------------------
617 dnl Check if ARM Neon instructions should be used.
618 dnl Obeys enable_arm_neon, which should be set earlier.
619 AC_DEFUN([NETTLE_CHECK_ARM_NEON],
620 [if test "$enable_arm_neon" = auto ; then
621 if test "$cross_compiling" = yes ; then
622 dnl Check if compiler/assembler accepts it,
623 dnl without an explicit .fpu neon directive.
624 AC_CACHE_CHECK([if assembler accepts Neon instructions],
625 nettle_cv_asm_arm_neon,
631 [nettle_cv_asm_arm_neon=yes],
632 [nettle_cv_asm_arm_neon=no])])
633 enable_arm_neon="$nettle_cv_asm_arm_neon"
635 AC_MSG_CHECKING([if /proc/cpuinfo claims neon support])
636 if grep '^Features.*:.* neon' /proc/cpuinfo >/dev/null ; then
641 AC_MSG_RESULT($enable_arm_neon)
646 dnl NETTLE_CHECK_IFUNC
647 dnl ------------------
648 dnl Check if __attribute__ ((ifunc(...))) works
649 AC_DEFUN([NETTLE_CHECK_IFUNC],
650 [AC_REQUIRE([AC_PROG_CC])
651 AC_CACHE_CHECK([for ifunc support],
652 nettle_cv_link_ifunc,
653 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
660 typedef void void_func (void);
665 return (void_func *) foo_imp;
668 int foo (int x) __attribute__ ((ifunc("foo_resolv")));
673 [nettle_cv_link_ifunc=yes],
674 [nettle_cv_link_ifunc=no])])
675 AH_TEMPLATE([HAVE_LINK_IFUNC], [Define if compiler and linker supports __attribute__ ifunc])
676 if test "x$nettle_cv_link_ifunc" = xyes ; then
677 AC_DEFINE(HAVE_LINK_IFUNC)
681 dnl @synopsis AX_CREATE_STDINT_H [( HEADER-TO-GENERATE [, HEADERS-TO-CHECK])]
683 dnl the "ISO C9X: 7.18 Integer types <stdint.h>" section requires the
684 dnl existence of an include file <stdint.h> that defines a set of
685 dnl typedefs, especially uint8_t,int32_t,uintptr_t.
686 dnl Many older installations will not provide this file, but some will
687 dnl have the very same definitions in <inttypes.h>. In other enviroments
688 dnl we can use the inet-types in <sys/types.h> which would define the
689 dnl typedefs int8_t and u_int8_t respectivly.
691 dnl This macros will create a local "_stdint.h" or the headerfile given as
692 dnl an argument. In many cases that file will just "#include <stdint.h>"
693 dnl or "#include <inttypes.h>", while in other environments it will provide
694 dnl the set of basic 'stdint's definitions/typedefs:
695 dnl int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t
696 dnl int_least32_t.. int_fast32_t.. intmax_t
697 dnl which may or may not rely on the definitions of other files,
698 dnl or using the AC_CHECK_SIZEOF macro to determine the actual
699 dnl sizeof each type.
701 dnl if your header files require the stdint-types you will want to create an
702 dnl installable file mylib-int.h that all your other installable header
703 dnl may include. So if you have a library package named "mylib", just use
704 dnl AX_CREATE_STDINT_H(mylib-int.h)
705 dnl in configure.ac and go to install that very header file in Makefile.am
706 dnl along with the other headers (mylib.h) - and the mylib-specific headers
707 dnl can simply use "#include <mylib-int.h>" to obtain the stdint-types.
709 dnl Remember, if the system already had a valid <stdint.h>, the generated
710 dnl file will include it directly. No need for fuzzy HAVE_STDINT_H things...
712 dnl @, (status: used on new platforms) (see http://ac-archive.sf.net/gstdint/)
713 dnl @author Guido Draheim <guidod@gmx.de>
715 AC_DEFUN([AX_CREATE_STDINT_H],
716 [# ------ AX CREATE STDINT H -------------------------------------
717 AC_MSG_CHECKING([for stdint types])
718 ac_stdint_h=`echo ifelse($1, , _stdint.h, $1)`
719 # try to shortcircuit - if the default include path of the compiler
720 # can find a "stdint.h" header then we assume that all compilers can.
721 AC_CACHE_VAL([ac_cv_header_stdint_t],[
722 old_CXXFLAGS="$CXXFLAGS" ; CXXFLAGS=""
723 old_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS=""
724 old_CFLAGS="$CFLAGS" ; CFLAGS=""
725 AC_TRY_COMPILE([#include <stdint.h>],[int_least32_t v = 0;],
726 [ac_cv_stdint_result="(assuming C99 compatible system)"
727 ac_cv_header_stdint_t="stdint.h"; ],
728 [ac_cv_header_stdint_t=""])
729 CXXFLAGS="$old_CXXFLAGS"
730 CPPFLAGS="$old_CPPFLAGS"
731 CFLAGS="$old_CFLAGS" ])
733 v="... $ac_cv_header_stdint_h"
734 if test "$ac_stdint_h" = "stdint.h" ; then
735 AC_MSG_RESULT([(are you sure you want them in ./stdint.h?)])
736 elif test "$ac_stdint_h" = "inttypes.h" ; then
737 AC_MSG_RESULT([(are you sure you want them in ./inttypes.h?)])
738 elif test "_$ac_cv_header_stdint_t" = "_" ; then
739 AC_MSG_RESULT([(putting them into $ac_stdint_h)$v])
741 ac_cv_header_stdint="$ac_cv_header_stdint_t"
742 AC_MSG_RESULT([$ac_cv_header_stdint (shortcircuit)])
745 if test "_$ac_cv_header_stdint_t" = "_" ; then # can not shortcircuit..
747 dnl .....intro message done, now do a few system checks.....
748 dnl btw, all CHECK_TYPE macros do automatically "DEFINE" a type, therefore
749 dnl we use the autoconf implementation detail _AC CHECK_TYPE_NEW instead
751 inttype_headers=`echo $2 | sed -e 's/,/ /g'`
753 ac_cv_stdint_result="(no helpful system typedefs seen)"
754 AC_CACHE_CHECK([for stdint uintptr_t], [ac_cv_header_stdint_x],[
755 ac_cv_header_stdint_x="" # the 1997 typedefs (inttypes.h)
756 AC_MSG_RESULT([(..)])
757 for i in stdint.h inttypes.h sys/inttypes.h $inttype_headers ; do
758 unset ac_cv_type_uintptr_t
759 unset ac_cv_type_uint64_t
760 _AC_CHECK_TYPE_NEW(uintptr_t,[ac_cv_header_stdint_x=$i],dnl
761 continue,[#include <$i>])
762 AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
763 ac_cv_stdint_result="(seen uintptr_t$and64 in $i)"
766 AC_MSG_CHECKING([for stdint uintptr_t])
769 if test "_$ac_cv_header_stdint_x" = "_" ; then
770 AC_CACHE_CHECK([for stdint uint32_t], [ac_cv_header_stdint_o],[
771 ac_cv_header_stdint_o="" # the 1995 typedefs (sys/inttypes.h)
772 AC_MSG_RESULT([(..)])
773 for i in inttypes.h sys/inttypes.h stdint.h $inttype_headers ; do
774 unset ac_cv_type_uint32_t
775 unset ac_cv_type_uint64_t
776 AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],dnl
777 continue,[#include <$i>])
778 AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
779 ac_cv_stdint_result="(seen uint32_t$and64 in $i)"
782 AC_MSG_CHECKING([for stdint uint32_t])
786 if test "_$ac_cv_header_stdint_x" = "_" ; then
787 if test "_$ac_cv_header_stdint_o" = "_" ; then
788 AC_CACHE_CHECK([for stdint u_int32_t], [ac_cv_header_stdint_u],[
789 ac_cv_header_stdint_u="" # the BSD typedefs (sys/types.h)
790 AC_MSG_RESULT([(..)])
791 for i in sys/types.h inttypes.h sys/inttypes.h $inttype_headers ; do
792 unset ac_cv_type_u_int32_t
793 unset ac_cv_type_u_int64_t
794 AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],dnl
795 continue,[#include <$i>])
796 AC_CHECK_TYPE(u_int64_t,[and64="/u_int64_t"],[and64=""],[#include<$i>])
797 ac_cv_stdint_result="(seen u_int32_t$and64 in $i)"
800 AC_MSG_CHECKING([for stdint u_int32_t])
804 dnl if there was no good C99 header file, do some typedef checks...
805 if test "_$ac_cv_header_stdint_x" = "_" ; then
806 AC_MSG_CHECKING([for stdint datatype model])
807 AC_MSG_RESULT([(..)])
808 AC_CHECK_SIZEOF(char)
809 AC_CHECK_SIZEOF(short)
811 AC_CHECK_SIZEOF(long)
812 AC_CHECK_SIZEOF(void*)
813 ac_cv_stdint_char_model=""
814 ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_char"
815 ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_short"
816 ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_int"
817 ac_cv_stdint_long_model=""
818 ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_int"
819 ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_long"
820 ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_voidp"
821 name="$ac_cv_stdint_long_model"
822 case "$ac_cv_stdint_char_model/$ac_cv_stdint_long_model" in
823 122/242) name="$name, IP16 (standard 16bit machine)" ;;
824 122/244) name="$name, LP32 (standard 32bit mac/win)" ;;
825 122/*) name="$name (unusual int16 model)" ;;
826 124/444) name="$name, ILP32 (standard 32bit unixish)" ;;
827 124/488) name="$name, LP64 (standard 64bit unixish)" ;;
828 124/448) name="$name, LLP64 (unusual 64bit unixish)" ;;
829 124/*) name="$name (unusual int32 model)" ;;
830 128/888) name="$name, ILP64 (unusual 64bit numeric)" ;;
831 128/*) name="$name (unusual int64 model)" ;;
832 222/*|444/*) name="$name (unusual dsptype)" ;;
833 *) name="$name (very unusal model)" ;;
835 AC_MSG_RESULT([combined for stdint datatype model... $name])
838 if test "_$ac_cv_header_stdint_x" != "_" ; then
839 ac_cv_header_stdint="$ac_cv_header_stdint_x"
840 elif test "_$ac_cv_header_stdint_o" != "_" ; then
841 ac_cv_header_stdint="$ac_cv_header_stdint_o"
842 elif test "_$ac_cv_header_stdint_u" != "_" ; then
843 ac_cv_header_stdint="$ac_cv_header_stdint_u"
845 ac_cv_header_stdint="stddef.h"
848 AC_MSG_CHECKING([for extra inttypes in chosen header])
849 AC_MSG_RESULT([($ac_cv_header_stdint)])
850 dnl see if int_least and int_fast types are present in _this_ header.
851 unset ac_cv_type_int_least32_t
852 unset ac_cv_type_int_fast32_t
853 AC_CHECK_TYPE(int_least32_t,,,[#include <$ac_cv_header_stdint>])
854 AC_CHECK_TYPE(int_fast32_t,,,[#include<$ac_cv_header_stdint>])
855 AC_CHECK_TYPE(intmax_t,,,[#include <$ac_cv_header_stdint>])
857 fi # shortcircut to system "stdint.h"
858 # ------------------ PREPARE VARIABLES ------------------------------
859 if test "$GCC" = "yes" ; then
860 ac_cv_stdint_message="using gnu compiler "`$CC --version | head -1`
862 ac_cv_stdint_message="using $CC"
865 AC_MSG_RESULT([make use of $ac_cv_header_stdint in $ac_stdint_h dnl
866 $ac_cv_stdint_result])
868 # ----------------- DONE inttypes.h checks START header -------------
869 AC_CONFIG_COMMANDS([$ac_stdint_h],[
870 AC_MSG_NOTICE(creating $ac_stdint_h : $_ac_stdint_h)
871 ac_stdint=$tmp/_stdint.h
873 echo "#ifndef" $_ac_stdint_h >$ac_stdint
874 echo "#define" $_ac_stdint_h "1" >>$ac_stdint
875 echo "#ifndef" _GENERATED_STDINT_H >>$ac_stdint
876 echo "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdint
877 echo "/* generated $ac_cv_stdint_message */" >>$ac_stdint
878 if test "_$ac_cv_header_stdint_t" != "_" ; then
879 echo "#define _STDINT_HAVE_STDINT_H" "1" >>$ac_stdint
882 cat >>$ac_stdint <<STDINT_EOF
884 /* ................... shortcircuit part ........................... */
886 #if defined HAVE_STDINT_H || defined _STDINT_HAVE_STDINT_H
891 /* .................... configured part ............................ */
895 echo "/* whether we have a C99 compatible stdint header file */" >>$ac_stdint
896 if test "_$ac_cv_header_stdint_x" != "_" ; then
897 ac_header="$ac_cv_header_stdint_x"
898 echo "#define _STDINT_HEADER_INTPTR" '"'"$ac_header"'"' >>$ac_stdint
900 echo "/* #undef _STDINT_HEADER_INTPTR */" >>$ac_stdint
903 echo "/* whether we have a C96 compatible inttypes header file */" >>$ac_stdint
904 if test "_$ac_cv_header_stdint_o" != "_" ; then
905 ac_header="$ac_cv_header_stdint_o"
906 echo "#define _STDINT_HEADER_UINT32" '"'"$ac_header"'"' >>$ac_stdint
908 echo "/* #undef _STDINT_HEADER_UINT32 */" >>$ac_stdint
911 echo "/* whether we have a BSD compatible inet types header */" >>$ac_stdint
912 if test "_$ac_cv_header_stdint_u" != "_" ; then
913 ac_header="$ac_cv_header_stdint_u"
914 echo "#define _STDINT_HEADER_U_INT32" '"'"$ac_header"'"' >>$ac_stdint
916 echo "/* #undef _STDINT_HEADER_U_INT32 */" >>$ac_stdint
921 if test "_$ac_header" != "_" ; then if test "$ac_header" != "stddef.h" ; then
922 echo "#include <$ac_header>" >>$ac_stdint
926 echo "/* which 64bit typedef has been found */" >>$ac_stdint
927 if test "$ac_cv_type_uint64_t" = "yes" ; then
928 echo "#define _STDINT_HAVE_UINT64_T" "1" >>$ac_stdint
930 echo "/* #undef _STDINT_HAVE_UINT64_T */" >>$ac_stdint
932 if test "$ac_cv_type_u_int64_t" = "yes" ; then
933 echo "#define _STDINT_HAVE_U_INT64_T" "1" >>$ac_stdint
935 echo "/* #undef _STDINT_HAVE_U_INT64_T */" >>$ac_stdint
939 echo "/* which type model has been detected */" >>$ac_stdint
940 if test "_$ac_cv_stdint_char_model" != "_" ; then
941 echo "#define _STDINT_CHAR_MODEL" "$ac_cv_stdint_char_model" >>$ac_stdint
942 echo "#define _STDINT_LONG_MODEL" "$ac_cv_stdint_long_model" >>$ac_stdint
944 echo "/* #undef _STDINT_CHAR_MODEL // skipped */" >>$ac_stdint
945 echo "/* #undef _STDINT_LONG_MODEL // skipped */" >>$ac_stdint
949 echo "/* whether int_least types were detected */" >>$ac_stdint
950 if test "$ac_cv_type_int_least32_t" = "yes"; then
951 echo "#define _STDINT_HAVE_INT_LEAST32_T" "1" >>$ac_stdint
953 echo "/* #undef _STDINT_HAVE_INT_LEAST32_T */" >>$ac_stdint
955 echo "/* whether int_fast types were detected */" >>$ac_stdint
956 if test "$ac_cv_type_int_fast32_t" = "yes"; then
957 echo "#define _STDINT_HAVE_INT_FAST32_T" "1" >>$ac_stdint
959 echo "/* #undef _STDINT_HAVE_INT_FAST32_T */" >>$ac_stdint
961 echo "/* whether intmax_t type was detected */" >>$ac_stdint
962 if test "$ac_cv_type_intmax_t" = "yes"; then
963 echo "#define _STDINT_HAVE_INTMAX_T" "1" >>$ac_stdint
965 echo "/* #undef _STDINT_HAVE_INTMAX_T */" >>$ac_stdint
969 cat >>$ac_stdint <<STDINT_EOF
970 /* .................... detections part ............................ */
972 /* whether we need to define bitspecific types from compiler base types */
973 #ifndef _STDINT_HEADER_INTPTR
974 #ifndef _STDINT_HEADER_UINT32
975 #ifndef _STDINT_HEADER_U_INT32
976 #define _STDINT_NEED_INT_MODEL_T
978 #define _STDINT_HAVE_U_INT_TYPES
983 #ifdef _STDINT_HAVE_U_INT_TYPES
984 #undef _STDINT_NEED_INT_MODEL_T
987 #ifdef _STDINT_CHAR_MODEL
988 #if _STDINT_CHAR_MODEL+0 == 122 || _STDINT_CHAR_MODEL+0 == 124
989 #ifndef _STDINT_BYTE_MODEL
990 #define _STDINT_BYTE_MODEL 12
995 #ifndef _STDINT_HAVE_INT_LEAST32_T
996 #define _STDINT_NEED_INT_LEAST_T
999 #ifndef _STDINT_HAVE_INT_FAST32_T
1000 #define _STDINT_NEED_INT_FAST_T
1003 #ifndef _STDINT_HEADER_INTPTR
1004 #define _STDINT_NEED_INTPTR_T
1005 #ifndef _STDINT_HAVE_INTMAX_T
1006 #define _STDINT_NEED_INTMAX_T
1011 /* .................... definition part ............................ */
1013 /* some system headers have good uint64_t */
1014 #ifndef _HAVE_UINT64_T
1015 #if defined _STDINT_HAVE_UINT64_T || defined HAVE_UINT64_T
1016 #define _HAVE_UINT64_T
1017 #elif defined _STDINT_HAVE_U_INT64_T || defined HAVE_U_INT64_T
1018 #define _HAVE_UINT64_T
1019 typedef u_int64_t uint64_t;
1023 #ifndef _HAVE_UINT64_T
1024 /* .. here are some common heuristics using compiler runtime specifics */
1025 #if defined __STDC_VERSION__ && defined __STDC_VERSION__ >= 199901L
1026 #define _HAVE_UINT64_T
1027 typedef long long int64_t;
1028 typedef unsigned long long uint64_t;
1030 #elif !defined __STRICT_ANSI__
1031 #if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__
1032 #define _HAVE_UINT64_T
1033 typedef __int64 int64_t;
1034 typedef unsigned __int64 uint64_t;
1036 #elif defined __GNUC__ || defined __MWERKS__ || defined __ELF__
1037 /* note: all ELF-systems seem to have loff-support which needs 64-bit */
1038 #if !defined _NO_LONGLONG
1039 #define _HAVE_UINT64_T
1040 typedef long long int64_t;
1041 typedef unsigned long long uint64_t;
1044 #elif defined __alpha || (defined __mips && defined _ABIN32)
1045 #if !defined _NO_LONGLONG
1046 typedef long int64_t;
1047 typedef unsigned long uint64_t;
1049 /* compiler/cpu type to define int64_t */
1054 #if defined _STDINT_HAVE_U_INT_TYPES
1055 /* int8_t int16_t int32_t defined by inet code, redeclare the u_intXX types */
1056 typedef u_int8_t uint8_t;
1057 typedef u_int16_t uint16_t;
1058 typedef u_int32_t uint32_t;
1060 /* glibc compatibility */
1061 #ifndef __int8_t_defined
1062 #define __int8_t_defined
1066 #ifdef _STDINT_NEED_INT_MODEL_T
1067 /* we must guess all the basic types. Apart from byte-adressable system, */
1068 /* there a few 32-bit-only dsp-systems that we guard with BYTE_MODEL 8-} */
1069 /* (btw, those nibble-addressable systems are way off, or so we assume) */
1071 dnl /* have a look at "64bit and data size neutrality" at */
1072 dnl /* http://unix.org/version2/whatsnew/login_64bit.html */
1073 dnl /* (the shorthand "ILP" types always have a "P" part) */
1075 #if defined _STDINT_BYTE_MODEL
1076 #if _STDINT_LONG_MODEL+0 == 242
1077 /* 2:4:2 = IP16 = a normal 16-bit system */
1078 typedef unsigned char uint8_t;
1079 typedef unsigned short uint16_t;
1080 typedef unsigned long uint32_t;
1081 #ifndef __int8_t_defined
1082 #define __int8_t_defined
1083 typedef char int8_t;
1084 typedef short int16_t;
1085 typedef long int32_t;
1087 #elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL == 444
1088 /* 2:4:4 = LP32 = a 32-bit system derived from a 16-bit */
1089 /* 4:4:4 = ILP32 = a normal 32-bit system */
1090 typedef unsigned char uint8_t;
1091 typedef unsigned short uint16_t;
1092 typedef unsigned int uint32_t;
1093 #ifndef __int8_t_defined
1094 #define __int8_t_defined
1095 typedef char int8_t;
1096 typedef short int16_t;
1097 typedef int int32_t;
1099 #elif _STDINT_LONG_MODEL+0 == 484 || _STDINT_LONG_MODEL+0 == 488
1100 /* 4:8:4 = IP32 = a 32-bit system prepared for 64-bit */
1101 /* 4:8:8 = LP64 = a normal 64-bit system */
1102 typedef unsigned char uint8_t;
1103 typedef unsigned short uint16_t;
1104 typedef unsigned int uint32_t;
1105 #ifndef __int8_t_defined
1106 #define __int8_t_defined
1107 typedef char int8_t;
1108 typedef short int16_t;
1109 typedef int int32_t;
1111 /* this system has a "long" of 64bit */
1112 #ifndef _HAVE_UINT64_T
1113 #define _HAVE_UINT64_T
1114 typedef unsigned long uint64_t;
1115 typedef long int64_t;
1117 #elif _STDINT_LONG_MODEL+0 == 448
1118 /* LLP64 a 64-bit system derived from a 32-bit system */
1119 typedef unsigned char uint8_t;
1120 typedef unsigned short uint16_t;
1121 typedef unsigned int uint32_t;
1122 #ifndef __int8_t_defined
1123 #define __int8_t_defined
1124 typedef char int8_t;
1125 typedef short int16_t;
1126 typedef int int32_t;
1128 /* assuming the system has a "long long" */
1129 #ifndef _HAVE_UINT64_T
1130 #define _HAVE_UINT64_T
1131 typedef unsigned long long uint64_t;
1132 typedef long long int64_t;
1135 #define _STDINT_NO_INT32_T
1138 #define _STDINT_NO_INT8_T
1139 #define _STDINT_NO_INT32_T
1144 * quote from SunOS-5.8 sys/inttypes.h:
1145 * Use at your own risk. As of February 1996, the committee is squarely
1146 * behind the fixed sized types; the "least" and "fast" types are still being
1147 * discussed. The probability that the "fast" types may be removed before
1148 * the standard is finalized is high enough that they are not currently
1152 #if defined _STDINT_NEED_INT_LEAST_T
1153 typedef int8_t int_least8_t;
1154 typedef int16_t int_least16_t;
1155 typedef int32_t int_least32_t;
1156 #ifdef _HAVE_UINT64_T
1157 typedef int64_t int_least64_t;
1160 typedef uint8_t uint_least8_t;
1161 typedef uint16_t uint_least16_t;
1162 typedef uint32_t uint_least32_t;
1163 #ifdef _HAVE_UINT64_T
1164 typedef uint64_t uint_least64_t;
1169 #if defined _STDINT_NEED_INT_FAST_T
1170 typedef int8_t int_fast8_t;
1171 typedef int int_fast16_t;
1172 typedef int32_t int_fast32_t;
1173 #ifdef _HAVE_UINT64_T
1174 typedef int64_t int_fast64_t;
1177 typedef uint8_t uint_fast8_t;
1178 typedef unsigned uint_fast16_t;
1179 typedef uint32_t uint_fast32_t;
1180 #ifdef _HAVE_UINT64_T
1181 typedef uint64_t uint_fast64_t;
1186 #ifdef _STDINT_NEED_INTMAX_T
1187 #ifdef _HAVE_UINT64_T
1188 typedef int64_t intmax_t;
1189 typedef uint64_t uintmax_t;
1191 typedef long intmax_t;
1192 typedef unsigned long uintmax_t;
1196 #ifdef _STDINT_NEED_INTPTR_T
1197 #ifndef __intptr_t_defined
1198 #define __intptr_t_defined
1199 /* we encourage using "long" to store pointer values, never use "int" ! */
1200 #if _STDINT_LONG_MODEL+0 == 242 || _STDINT_LONG_MODEL+0 == 484
1201 typedef unsigned int uintptr_t;
1202 typedef int intptr_t;
1203 #elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL+0 == 444
1204 typedef unsigned long uintptr_t;
1205 typedef long intptr_t;
1206 #elif _STDINT_LONG_MODEL+0 == 448 && defined _HAVE_UINT64_T
1207 typedef uint64_t uintptr_t;
1208 typedef int64_t intptr_t;
1209 #else /* matches typical system types ILP32 and LP64 - but not IP16 or LLP64 */
1210 typedef unsigned long uintptr_t;
1211 typedef long intptr_t;
1222 if cmp -s $ac_stdint_h $ac_stdint 2>/dev/null; then
1223 AC_MSG_NOTICE([$ac_stdint_h is unchanged])
1225 ac_dir=`AS_DIRNAME(["$ac_stdint_h"])`
1226 AS_MKDIR_P(["$ac_dir"])
1228 mv $ac_stdint $ac_stdint_h
1230 ],[# variables for create stdint.h replacement
1233 ac_stdint_h="$ac_stdint_h"
1234 _ac_stdint_h=AS_TR_CPP(_$PACKAGE-$ac_stdint_h)
1235 ac_cv_stdint_message="$ac_cv_stdint_message"
1236 ac_cv_header_stdint_t="$ac_cv_header_stdint_t"
1237 ac_cv_header_stdint_x="$ac_cv_header_stdint_x"
1238 ac_cv_header_stdint_o="$ac_cv_header_stdint_o"
1239 ac_cv_header_stdint_u="$ac_cv_header_stdint_u"
1240 ac_cv_type_uint64_t="$ac_cv_type_uint64_t"
1241 ac_cv_type_u_int64_t="$ac_cv_type_u_int64_t"
1242 ac_cv_stdint_char_model="$ac_cv_stdint_char_model"
1243 ac_cv_stdint_long_model="$ac_cv_stdint_long_model"
1244 ac_cv_type_int_least32_t="$ac_cv_type_int_least32_t"
1245 ac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t"
1246 ac_cv_type_intmax_t="$ac_cv_type_intmax_t"
1250 # ld-version-script.m4 serial 3
1251 dnl Copyright (C) 2008-2014 Free Software Foundation, Inc.
1252 dnl This file is free software; the Free Software Foundation
1253 dnl gives unlimited permission to copy and/or distribute it,
1254 dnl with or without modifications, as long as this notice is preserved.
1256 dnl From Simon Josefsson
1258 # FIXME: The test below returns a false positive for mingw
1259 # cross-compiles, 'local:' statements does not reduce number of
1260 # exported symbols in a DLL. Use --disable-ld-version-script to work
1261 # around the problem.
1263 # gl_LD_VERSION_SCRIPT
1264 # --------------------
1265 # Check if LD supports linker scripts, and define automake conditional
1266 # HAVE_LD_VERSION_SCRIPT if so.
1267 AC_DEFUN([LD_VERSION_SCRIPT],
1269 AC_ARG_ENABLE([ld-version-script],
1270 AS_HELP_STRING([--enable-ld-version-script],
1271 [enable linker version script (default is enabled when possible)]),
1272 [have_ld_version_script=$enableval], [])
1273 if test -z "$have_ld_version_script"; then
1274 AC_MSG_CHECKING([if LD -Wl,--version-script works])
1275 save_LDFLAGS="$LDFLAGS"
1276 LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
1277 cat > conftest.map <<EOF
1280 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
1281 [accepts_syntax_errors=yes], [accepts_syntax_errors=no])
1282 if test "$accepts_syntax_errors" = no; then
1283 cat > conftest.map <<EOF
1292 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
1293 [have_ld_version_script=yes], [have_ld_version_script=no])
1295 have_ld_version_script=no
1298 LDFLAGS="$save_LDFLAGS"
1299 AC_MSG_RESULT($have_ld_version_script)
1301 if test "$have_ld_version_script" = "yes";then
1302 EXTRA_LINKER_FLAGS="-Wl,--version-script=libnettle.map"
1303 AC_SUBST(EXTRA_LINKER_FLAGS)
1304 EXTRA_HOGWEED_LINKER_FLAGS="-Wl,--version-script=libhogweed.map"
1305 AC_SUBST(EXTRA_HOGWEED_LINKER_FLAGS)