testutils.c: Fix high bits of the mpz_urandomb used with mini-gmp.
[gd/nettle] / aclocal.m4
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)
9         AC_EGREP_CPP(yes, [
10 #ifdef _AIX
11  yes
12 #endif
13 ],[
14 AC_MSG_RESULT(yes)
15 AC_DEFINE(socklen_t, size_t)
16 ],[
17 AC_MSG_RESULT(no)
18 AC_DEFINE(socklen_t, int)
19 ])
20 fi
21 ])
22
23 dnl Choose cc flags for compiling position independent code
24 dnl FIXME: Doesn't do the right thing when crosscompiling.
25 AC_DEFUN([LSH_CCPIC],
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
31       case "$host_os" in
32         bsdi4.*)        CCPIC="-fPIC" ;;
33         bsdi*)          CCPIC="" ;;
34         darwin*)        CCPIC="-fPIC" ;;
35         # Could also use -fpic, depending on the number of symbol references
36         solaris*)       CCPIC="-fPIC" ;;
37         cygwin*)        CCPIC="" ;;
38         mingw32*)       CCPIC="" ;;
39         *)              CCPIC="-fpic" ;;
40       esac
41     else
42       case "$host_os" in
43         darwin*)        CCPIC="-fPIC" ;;
44         irix*)          CCPIC="-share" ;;
45         hpux*)          CCPIC="+z"; ;;
46         *freebsd*)      CCPIC="-fpic" ;;
47         sco*|sysv4.*)   CCPIC="-KPIC -dy -Bdynamic" ;;
48         solaris*)       CCPIC="-KPIC -Bdynamic" ;;
49         winnt*)         CCPIC="-shared" ;;
50         *)              CCPIC="" ;;
51       esac
52     fi
53   fi
54   OLD_CFLAGS="$CFLAGS"
55   CFLAGS="$CFLAGS $CCPIC"
56   AC_TRY_COMPILE([], [exit(0);],
57     lsh_cv_sys_ccpic="$CCPIC", lsh_cv_sys_ccpic='')
58   CFLAGS="$OLD_CFLAGS"
59 ])
60 CCPIC="$lsh_cv_sys_ccpic"
61 AC_MSG_RESULT($CCPIC)])
62
63 dnl LSH_PATH_ADD(path-id, directory)
64 AC_DEFUN([LSH_PATH_ADD],
65 [AC_MSG_CHECKING($2)
66 ac_exists=no
67 if test -d "$2/." ; then
68   ac_real_dir=`cd $2 && pwd`
69   if test -n "$ac_real_dir" ; then
70     ac_exists=yes
71     for old in $1_REAL_DIRS ; do
72       ac_found=no
73       if test x$ac_real_dir = x$old ; then
74         ac_found=yes;
75         break;
76       fi
77     done
78     if test $ac_found = yes ; then
79       AC_MSG_RESULT(already added)
80     else
81       AC_MSG_RESULT(added)
82       # LDFLAGS="$LDFLAGS -L $2"
83       $1_REAL_DIRS="$ac_real_dir [$]$1_REAL_DIRS"
84       $1_DIRS="$2 [$]$1_DIRS"
85     fi
86   fi
87 fi
88 if test $ac_exists = no ; then
89   AC_MSG_RESULT(not found)
90 fi
91 ])
92
93 dnl LSH_RPATH_ADD(dir)
94 AC_DEFUN([LSH_RPATH_ADD], [LSH_PATH_ADD(RPATH_CANDIDATE, $1)])
95
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])
100 RPATHFLAG=''
101 case "$host_os" in
102   osf1*)                RPATHFLAG="-rpath " ;;
103   irix6.*|irix5.*)      RPATHFLAG="-rpath " ;;
104   solaris*)
105     if test "$TCC" = "yes"; then
106       # tcc doesn't know about -R
107       RPATHFLAG="-Wl,-R,"
108     else
109       RPATHFLAG=-R
110     fi
111     ;;
112   linux*|freebsd*)      RPATHFLAG="-Wl,-rpath," ;;
113   *)                    RPATHFLAG="" ;;
114 esac
115
116 if test x$RPATHFLAG = x ; then
117   AC_MSG_RESULT(none)
118 else
119   AC_MSG_RESULT([using $RPATHFLAG])
120 fi
121
122 RPATH_CANDIDATE_REAL_DIRS=''
123 RPATH_CANDIDATE_DIRS=''
124
125 AC_MSG_RESULT([Searching for libraries])
126
127 for d in $1 ; do
128   LSH_RPATH_ADD($d)
129 done
130 ])    
131
132 dnl Try to execute a main program, and if it fails, try adding some
133 dnl -R flag.
134 dnl LSH_RPATH_FIX
135 AC_DEFUN([LSH_RPATH_FIX],
136 [if test $cross_compiling = no -a "x$RPATHFLAG" != x ; then
137   ac_success=no
138   AC_TRY_RUN([int main(int argc, char **argv) { return 0; }],
139     ac_success=yes, ac_success=no, :)
140   
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
144     ac_remaining_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"
149       else
150         LDFLAGS="$RPATHFLAG$d $LDFLAGS"
151 dnl echo LDFLAGS = $LDFLAGS
152         AC_TRY_RUN([int main(int argc, char **argv) { return 0; }],
153           [ac_success=yes
154           ac_rpath_save_LDFLAGS="$LDFLAGS"
155           AC_MSG_RESULT([adding $RPATHFLAG$d])
156           ],
157           [ac_remaining_dirs="$ac_remaining_dirs $d"], :)
158         LDFLAGS="$ac_rpath_save_LDFLAGS"
159       fi
160     done
161     RPATH_CANDIDATE_DIRS=$ac_remaining_dirs
162   fi
163   if test $ac_success = no ; then
164     AC_MSG_RESULT(failed)
165   fi
166 fi
167 ])
168
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]]])
172
173 AC_DEFUN([LSH_CHECK_KRB_LIB],
174 [AC_CHECK_LIB([$1], [$2],
175   ifelse([$3], ,
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"
180       ]], [$3]),
181   ifelse([$4], , , [$4
182 ])dnl
183 , [$5 $KRB_LIBS])
184 ])
185
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"
190   ac_argp_ok=no
191   # First check if we can link with argp.
192   AC_SEARCH_LIBS(argp_parse, argp,
193   [ LSH_RPATH_FIX
194     AC_CACHE_CHECK([for working argp],
195       lsh_cv_lib_argp_works,
196       [ AC_TRY_RUN(
197 [#include <argp.h>
198 #include <stdlib.h>
199
200 static const struct argp_option
201 options[] =
202 {
203   { NULL, 0, NULL, 0, NULL, 0 }
204 };
205
206 struct child_state
207 {
208   int n;
209 };
210
211 static error_t
212 child_parser(int key, char *arg, struct argp_state *state)
213 {
214   struct child_state *input = (struct child_state *) state->input;
215   
216   switch(key)
217     {
218     default:
219       return ARGP_ERR_UNKNOWN;
220     case ARGP_KEY_END:
221       if (!input->n)
222         input->n = 1;
223       break;
224     }
225   return 0;
226 }
227
228 const struct argp child_argp =
229 {
230   options,
231   child_parser,
232   NULL, NULL, NULL, NULL, NULL
233 };
234
235 struct main_state
236 {
237   struct child_state child;
238   int m;
239 };
240
241 static error_t
242 main_parser(int key, char *arg, struct argp_state *state)
243 {
244   struct main_state *input = (struct main_state *) state->input;
245
246   switch(key)
247     {
248     default:
249       return ARGP_ERR_UNKNOWN;
250     case ARGP_KEY_INIT:
251       state->child_inputs[0] = &input->child;
252       break;
253     case ARGP_KEY_END:
254       if (!input->m)
255         input->m = input->child.n;
256       
257       break;
258     }
259   return 0;
260 }
261
262 static const struct argp_child
263 main_children[] =
264 {
265   { &child_argp, 0, "", 0 },
266   { NULL, 0, NULL, 0}
267 };
268
269 static const struct argp
270 main_argp =
271 { options, main_parser, 
272   NULL,
273   NULL,
274   main_children,
275   NULL, NULL
276 };
277
278 int main(int argc, char **argv)
279 {
280   struct main_state input = { { 0 }, 0 };
281   char *v[2] = { "foo", NULL };
282
283   argp_parse(&main_argp, 1, v, 0, NULL, &input);
284
285   if ( (input.m == 1) && (input.child.n == 1) )
286     return 0;
287   else
288     return 1;
289 }
290 ], lsh_cv_lib_argp_works=yes,
291    lsh_cv_lib_argp_works=no,
292    lsh_cv_lib_argp_works=no)])
293
294   if test x$lsh_cv_lib_argp_works = xyes ; then
295     ac_argp_ok=yes
296   else
297     # Reset link flags
298     LIBS="$ac_argp_save_LIBS"
299     LDFLAGS="$ac_argp_save_LDFLAGS"
300   fi])
301
302   if test x$ac_argp_ok = xyes ; then
303     ifelse([$1],, true, [$1])
304   else
305     ifelse([$2],, true, [$2])
306   fi   
307 ])
308
309 dnl LSH_GCC_ATTRIBUTES
310 dnl Check for gcc's __attribute__ construction
311
312 AC_DEFUN([LSH_GCC_ATTRIBUTES],
313 [AC_CACHE_CHECK(for __attribute__,
314                lsh_cv_c_attribute,
315 [ AC_TRY_COMPILE([
316 #include <stdlib.h>
317
318 static void foo(void) __attribute__ ((noreturn));
319
320 static void __attribute__ ((noreturn))
321 foo(void)
322 {
323   exit(1);
324 }
325 ],[],
326 lsh_cv_c_attribute=yes,
327 lsh_cv_c_attribute=no)])
328
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)
332 fi
333
334 AH_BOTTOM(
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__))
339 #else
340 # define NORETURN
341 # define PRINTF_STYLE(f, a)
342 # define UNUSED
343 #endif
344 ])])
345
346 # Check for alloca, and include the standard blurb in config.h
347 AC_DEFUN([LSH_FUNC_ALLOCA],
348 [AC_FUNC_ALLOCA
349 AC_CHECK_HEADERS([malloc.h])
350 AH_BOTTOM(
351 [/* AIX requires this to be the first thing in the file.  */
352 #ifndef __GNUC__
353 # if HAVE_ALLOCA_H
354 #  include <alloca.h>
355 # else
356 #  ifdef _AIX
357  #pragma alloca
358 #  else
359 #   ifndef alloca /* predefined by HP cc +Olibcalls */
360 char *alloca ();
361 #   endif
362 #  endif
363 /* Needed for alloca on windows */
364 #  if HAVE_MALLOC_H
365 #   include <malloc.h>
366 #  endif
367 # endif
368 #else /* defined __GNUC__ */
369 # if HAVE_ALLOCA_H
370 #  include <alloca.h>
371 # else
372 /* Needed for alloca on windows, also with gcc */
373 #  if HAVE_MALLOC_H
374 #   include <malloc.h>
375 #  endif
376 # endif
377 #endif
378 ])])
379
380 AC_DEFUN([LSH_FUNC_STRERROR],
381 [AC_CHECK_FUNCS(strerror)
382 AH_BOTTOM(
383 [#if HAVE_STRERROR
384 #define STRERROR strerror
385 #else
386 #define STRERROR(x) (sys_errlist[x])
387 #endif
388 ])])
389
390 AC_DEFUN([LSH_FUNC_STRSIGNAL],
391 [AC_CHECK_FUNCS(strsignal)
392 AC_CHECK_DECLS([sys_siglist, _sys_siglist])
393 AH_BOTTOM(
394 [#if HAVE_STRSIGNAL
395 # define STRSIGNAL strsignal
396 #else /* !HAVE_STRSIGNAL */
397 # if HAVE_DECL_SYS_SIGLIST
398 #  define STRSIGNAL(x) (sys_siglist[x])
399 # else
400 #  if HAVE_DECL__SYS_SIGLIST
401 #   define STRSIGNAL(x) (_sys_siglist[x])
402 #  else
403 #   define STRSIGNAL(x) "Unknown signal"
404 #   if __GNUC__
405 #    warning Using dummy STRSIGNAL
406 #   endif
407 #  endif
408 # endif
409 #endif /* !HAVE_STRSIGNAL */
410 ])])
411
412 dnl LSH_MAKE_CONDITIONAL(symbol, test)
413 AC_DEFUN([LSH_MAKE_CONDITIONAL],
414 [if $2 ; then
415   IF_$1=''
416   UNLESS_$1='# '
417 else
418   IF_$1='# '
419   UNLESS_$1=''
420 fi 
421 AC_SUBST(IF_$1)
422 AC_SUBST(UNLESS_$1)])
423
424 dnl LSH_DEPENDENCY_TRACKING
425
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.
431
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])
437
438 DEP_FLAGS=''
439 DEP_PROCESS='true'
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
444       2.*|*[[!0-9.]]2.*)
445         enable_dependency_tracking=no
446         AC_MSG_WARN([Dependency tracking disabled, gcc-3.x is needed])
447       ;;
448       *)
449         DEP_FLAGS='-MT $[]@ -MD -MP -MF $[]@.d'
450         DEP_PROCESS='true'
451       ;;
452     esac
453   else
454     enable_dependency_tracking=no
455     AC_MSG_WARN([Dependency tracking disabled])
456   fi
457 fi
458
459 if test x$enable_dependency_tracking = xyes ; then
460   DEP_INCLUDE='include '
461 else
462   DEP_INCLUDE='# '
463 fi
464
465 AC_SUBST([DEP_INCLUDE])
466 AC_SUBST([DEP_FLAGS])
467 AC_SUBST([DEP_PROCESS])])
468
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.
473 dnl
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.
477 dnl
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.
480
481 AC_DEFUN([GMP_TRY_ASSEMBLE],
482 [cat >conftest.s <<EOF
483 [$1]
484 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
488   ifelse([$2],,:,[$2])
489 else
490   cat conftest.out >&AC_FD_CC
491   echo "configure: failed program was:" >&AC_FD_CC
492   cat conftest.s >&AC_FD_CC
493   ifelse([$3],,:,[$3])
494 fi
495 rm -f conftest*
496 ])
497
498 dnl  GMP_PROG_CC_FOR_BUILD
499 dnl  ---------------------
500 dnl  Establish CC_FOR_BUILD, a C compiler for the build system.
501 dnl
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
504 dnl  configfsf.guess.
505
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])])
515 else
516   if test $cross_compiling = no ; then
517     CC_FOR_BUILD="$CC"  
518   else
519     for i in gcc cc c89 c99; do
520       GMP_PROG_CC_FOR_BUILD_WORKS($i,
521         [CC_FOR_BUILD=$i
522          break])
523     done
524     if test -z "$CC_FOR_BUILD"; then
525       AC_MSG_ERROR([Cannot find a build system compiler])
526     fi
527   fi
528   if test "$CC_FOR_BUILD" = gcc ; then
529     CC_FOR_BUILD="$CC_FOR_BUILD -O -g"
530   fi
531 fi
532
533 AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
534 AC_SUBST(CC_FOR_BUILD)
535 ])
536
537
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.
541 dnl
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.
544
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
550 int
551 main ()
552 {
553   exit(0);
554 }
555 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
561   fi
562 fi
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
566   ifelse([$2],,:,[$2])
567 else
568   ifelse([$3],,:,[$3])
569 fi
570 ])
571
572 dnl  GMP_PROG_EXEEXT_FOR_BUILD
573 dnl  -------------------------
574 dnl  Determine EXEEXT_FOR_BUILD, the build system executable suffix.
575 dnl
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.
582
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"
589 else
590   cat >conftest.c <<EOF
591 int
592 main ()
593 {
594   exit (0);
595 }
596 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
602         break
603       fi
604     fi
605   done
606   rm -f conftest*
607   if test "${gmp_cv_prog_exeext_for_build+set}" != set; then
608     AC_MSG_ERROR([Cannot determine executable suffix])
609   fi
610 fi
611 ])
612 AC_SUBST(EXEEXT_FOR_BUILD,$gmp_cv_prog_exeext_for_build)
613 ])
614
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,
626       [GMP_TRY_ASSEMBLE([
627 .text
628 foo:
629         vmlal.u32       q1, d0, d1
630 ],
631       [nettle_cv_asm_arm_neon=yes],
632       [nettle_cv_asm_arm_neon=no])])
633     enable_arm_neon="$nettle_cv_asm_arm_neon"
634   else
635     AC_MSG_CHECKING([if /proc/cpuinfo claims neon support])
636     if grep '^Features.*:.* neon' /proc/cpuinfo >/dev/null ; then
637       enable_arm_neon=yes
638     else
639       enable_arm_neon=no
640     fi
641     AC_MSG_RESULT($enable_arm_neon)
642   fi
643 fi
644 ])
645
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([
654 static int
655 foo_imp(int x)
656 {
657   return 1;
658 }
659
660 typedef void void_func (void);
661
662 static void_func *
663 foo_resolv(void)
664 {
665   return (void_func *) foo_imp;
666 }
667
668 int foo (int x) __attribute__ ((ifunc("foo_resolv")));
669 ],[
670   return foo(0);
671
672 ])],
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)
678 fi 
679 ])
680
681 dnl @synopsis AX_CREATE_STDINT_H [( HEADER-TO-GENERATE [, HEADERS-TO-CHECK])]
682 dnl
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.
690 dnl
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.
700 dnl
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.
708 dnl
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...
711 dnl
712 dnl @, (status: used on new platforms) (see http://ac-archive.sf.net/gstdint/)
713 dnl @author  Guido Draheim <guidod@gmx.de> 
714
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" ])
732
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])
740 else
741  ac_cv_header_stdint="$ac_cv_header_stdint_t"
742  AC_MSG_RESULT([$ac_cv_header_stdint (shortcircuit)])
743 fi
744
745 if test "_$ac_cv_header_stdint_t" = "_" ; then # can not shortcircuit..
746
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
750
751 inttype_headers=`echo $2 | sed -e 's/,/ /g'`
752
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)"
764    break;
765   done
766   AC_MSG_CHECKING([for stdint uintptr_t])
767  ])
768
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)"
780    break;
781   done
782   AC_MSG_CHECKING([for stdint uint32_t])
783  ])
784 fi
785
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)"
798    break;
799   done
800   AC_MSG_CHECKING([for stdint u_int32_t])
801  ])
802 fi fi
803
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)
810    AC_CHECK_SIZEOF(int)
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)" ;;
834    esac
835    AC_MSG_RESULT([combined for stdint datatype model...  $name])
836 fi
837
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"
844 else
845    ac_cv_header_stdint="stddef.h"
846 fi
847
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>])
856
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` 
861 else
862 ac_cv_stdint_message="using $CC"
863 fi
864
865 AC_MSG_RESULT([make use of $ac_cv_header_stdint in $ac_stdint_h dnl
866 $ac_cv_stdint_result])
867
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
872
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
880 fi
881
882 cat >>$ac_stdint <<STDINT_EOF
883
884 /* ................... shortcircuit part ........................... */
885
886 #if defined HAVE_STDINT_H || defined _STDINT_HAVE_STDINT_H
887 #include <stdint.h>
888 #else
889 #include <stddef.h>
890
891 /* .................... configured part ............................ */
892
893 STDINT_EOF
894
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
899 else
900   echo "/* #undef _STDINT_HEADER_INTPTR */" >>$ac_stdint
901 fi
902
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
907 else
908   echo "/* #undef _STDINT_HEADER_UINT32 */" >>$ac_stdint
909 fi
910
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
915 else
916   echo "/* #undef _STDINT_HEADER_U_INT32 */" >>$ac_stdint
917 fi
918
919 echo "" >>$ac_stdint
920
921 if test "_$ac_header" != "_" ; then if test "$ac_header" != "stddef.h" ; then
922   echo "#include <$ac_header>" >>$ac_stdint
923   echo "" >>$ac_stdint
924 fi fi
925
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
929 else
930 echo "/* #undef _STDINT_HAVE_UINT64_T */" >>$ac_stdint
931 fi
932 if test "$ac_cv_type_u_int64_t" = "yes" ; then
933 echo "#define   _STDINT_HAVE_U_INT64_T" "1"  >>$ac_stdint
934 else
935 echo "/* #undef _STDINT_HAVE_U_INT64_T */" >>$ac_stdint
936 fi
937 echo "" >>$ac_stdint
938
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
943 else
944 echo "/* #undef _STDINT_CHAR_MODEL // skipped */" >>$ac_stdint
945 echo "/* #undef _STDINT_LONG_MODEL // skipped */" >>$ac_stdint
946 fi
947 echo "" >>$ac_stdint
948
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
952 else
953 echo "/* #undef _STDINT_HAVE_INT_LEAST32_T */" >>$ac_stdint
954 fi
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
958 else
959 echo "/* #undef _STDINT_HAVE_INT_FAST32_T */" >>$ac_stdint
960 fi
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
964 else
965 echo "/* #undef _STDINT_HAVE_INTMAX_T */" >>$ac_stdint
966 fi
967 echo "" >>$ac_stdint
968
969   cat >>$ac_stdint <<STDINT_EOF
970 /* .................... detections part ............................ */
971
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
977 #else
978 #define _STDINT_HAVE_U_INT_TYPES
979 #endif
980 #endif
981 #endif
982
983 #ifdef _STDINT_HAVE_U_INT_TYPES
984 #undef _STDINT_NEED_INT_MODEL_T
985 #endif
986
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
991 #endif
992 #endif
993 #endif
994
995 #ifndef _STDINT_HAVE_INT_LEAST32_T
996 #define _STDINT_NEED_INT_LEAST_T
997 #endif
998
999 #ifndef _STDINT_HAVE_INT_FAST32_T
1000 #define _STDINT_NEED_INT_FAST_T
1001 #endif
1002
1003 #ifndef _STDINT_HEADER_INTPTR
1004 #define _STDINT_NEED_INTPTR_T
1005 #ifndef _STDINT_HAVE_INTMAX_T
1006 #define _STDINT_NEED_INTMAX_T
1007 #endif
1008 #endif
1009
1010
1011 /* .................... definition part ............................ */
1012
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;
1020 #endif
1021 #endif
1022
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;
1029
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;
1035
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;
1042 #endif
1043
1044 #elif defined __alpha || (defined __mips && defined _ABIN32)
1045 #if !defined _NO_LONGLONG
1046 typedef long int64_t;
1047 typedef unsigned long uint64_t;
1048 #endif
1049   /* compiler/cpu type to define int64_t */
1050 #endif
1051 #endif
1052 #endif
1053
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;
1059
1060 /* glibc compatibility */
1061 #ifndef __int8_t_defined
1062 #define __int8_t_defined
1063 #endif
1064 #endif
1065
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) */
1070
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) */
1074
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;
1086 #endif
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;
1098 #endif
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;
1110 #endif
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;
1116 #endif
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;
1127 #endif
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;
1133 #endif
1134 #else
1135 #define _STDINT_NO_INT32_T
1136 #endif
1137 #else
1138 #define _STDINT_NO_INT8_T
1139 #define _STDINT_NO_INT32_T
1140 #endif
1141 #endif
1142
1143 /*
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
1149  * implemented.
1150  */
1151
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;
1158 #endif
1159
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;
1165 #endif
1166   /* least types */
1167 #endif
1168
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;
1175 #endif
1176
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;
1182 #endif
1183   /* fast types */
1184 #endif
1185
1186 #ifdef _STDINT_NEED_INTMAX_T
1187 #ifdef _HAVE_UINT64_T
1188 typedef  int64_t       intmax_t;
1189 typedef uint64_t      uintmax_t;
1190 #else
1191 typedef          long  intmax_t;
1192 typedef unsigned long uintmax_t;
1193 #endif
1194 #endif
1195
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;
1212 #endif
1213 #endif
1214 #endif
1215
1216   /* shortcircuit*/
1217 #endif
1218   /* once */
1219 #endif
1220 #endif
1221 STDINT_EOF
1222     if cmp -s $ac_stdint_h $ac_stdint 2>/dev/null; then
1223       AC_MSG_NOTICE([$ac_stdint_h is unchanged])
1224     else
1225       ac_dir=`AS_DIRNAME(["$ac_stdint_h"])`
1226       AS_MKDIR_P(["$ac_dir"])
1227       rm -f $ac_stdint_h
1228       mv $ac_stdint $ac_stdint_h
1229     fi
1230 ],[# variables for create stdint.h replacement
1231 PACKAGE="$PACKAGE"
1232 VERSION="$VERSION"
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"
1247 ])
1248 ])
1249
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.
1255
1256 dnl From Simon Josefsson
1257
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.
1262
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],
1268 [
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
1278 foo
1279 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
1284 VERS_1 {
1285         global: sym;
1286 };
1287
1288 VERS_2 {
1289         global: sym;
1290 } VERS_1;
1291 EOF
1292       AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
1293                      [have_ld_version_script=yes], [have_ld_version_script=no])
1294     else
1295       have_ld_version_script=no
1296     fi
1297     rm -f conftest.map
1298     LDFLAGS="$save_LDFLAGS"
1299     AC_MSG_RESULT($have_ld_version_script)
1300   fi
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)
1306   fi
1307 ])