nettle: import from packages, update to 3.0
[openwrt.git] / package / libs / nettle / patches / 0003-Include-local-macros-in-nettle.m4-to-allow-regenerat.patch
1 From a6d49f192166d20755a6651d4612d3abcd780822 Mon Sep 17 00:00:00 2001
2 From: Nikos Mavrogiannopoulos <nmav@gnutls.org>
3 Date: Sun, 9 Mar 2014 11:58:05 +0100
4 Subject: [PATCH 3/5] Include local macros in nettle.m4 to allow regeneration.
5
6 ---
7  configure.ac |    1 +
8  nettle.m4    | 1209 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9  2 files changed, 1210 insertions(+)
10  create mode 100644 nettle.m4
11
12 --- a/configure.ac
13 +++ b/configure.ac
14 @@ -7,6 +7,7 @@ AC_PREREQ(2.61)
15  AC_CONFIG_SRCDIR([arcfour.c])
16  # Needed to stop autoconf from looking for files in parent directories.
17  AC_CONFIG_AUX_DIR([.])
18 +AC_CONFIG_MACRO_DIR([.])
19  
20  AC_CONFIG_HEADER([config.h])
21  
22 --- /dev/null
23 +++ b/nettle.m4
24 @@ -0,0 +1,1209 @@
25 +dnl Try to detect the type of the third arg to getsockname() et al
26 +AC_DEFUN([LSH_TYPE_SOCKLEN_T],
27 +[AH_TEMPLATE([socklen_t], [Length type used by getsockopt])
28 +AC_CACHE_CHECK([for socklen_t in sys/socket.h], ac_cv_type_socklen_t,
29 +[AC_EGREP_HEADER(socklen_t, sys/socket.h,
30 +  [ac_cv_type_socklen_t=yes], [ac_cv_type_socklen_t=no])])
31 +if test $ac_cv_type_socklen_t = no; then
32 +        AC_MSG_CHECKING(for AIX)
33 +        AC_EGREP_CPP(yes, [
34 +#ifdef _AIX
35 + yes
36 +#endif
37 +],[
38 +AC_MSG_RESULT(yes)
39 +AC_DEFINE(socklen_t, size_t)
40 +],[
41 +AC_MSG_RESULT(no)
42 +AC_DEFINE(socklen_t, int)
43 +])
44 +fi
45 +])
46 +
47 +dnl Choose cc flags for compiling position independent code
48 +dnl FIXME: Doesn't do the right thing when crosscompiling.
49 +AC_DEFUN([LSH_CCPIC],
50 +[AC_REQUIRE([AC_CANONICAL_HOST])dnl
51 +AC_MSG_CHECKING(CCPIC)
52 +AC_CACHE_VAL(lsh_cv_sys_ccpic,[
53 +  if test -z "$CCPIC" ; then
54 +    if test "$GCC" = yes ; then
55 +      case "$host_os" in
56 +       bsdi4.*)        CCPIC="-fPIC" ;;
57 +       bsdi*)          CCPIC="" ;;
58 +       darwin*)        CCPIC="-fPIC" ;;
59 +       # Could also use -fpic, depending on the number of symbol references
60 +       solaris*)       CCPIC="-fPIC" ;;
61 +       cygwin*)        CCPIC="" ;;
62 +       mingw32*)       CCPIC="" ;;
63 +       *)              CCPIC="-fpic" ;;
64 +      esac
65 +    else
66 +      case "$host_os" in
67 +       darwin*)        CCPIC="-fPIC" ;;
68 +        irix*)         CCPIC="-share" ;;
69 +       hpux*)          CCPIC="+z"; ;;
70 +       *freebsd*)      CCPIC="-fpic" ;;
71 +       sco*|sysv4.*)   CCPIC="-KPIC -dy -Bdynamic" ;;
72 +       solaris*)       CCPIC="-KPIC -Bdynamic" ;;
73 +       winnt*)         CCPIC="-shared" ;;
74 +       *)              CCPIC="" ;;
75 +      esac
76 +    fi
77 +  fi
78 +  OLD_CFLAGS="$CFLAGS"
79 +  CFLAGS="$CFLAGS $CCPIC"
80 +  AC_TRY_COMPILE([], [exit(0);],
81 +    lsh_cv_sys_ccpic="$CCPIC", lsh_cv_sys_ccpic='')
82 +  CFLAGS="$OLD_CFLAGS"
83 +])
84 +CCPIC="$lsh_cv_sys_ccpic"
85 +AC_MSG_RESULT($CCPIC)
86 +AC_SUBST([CCPIC])])
87 +
88 +dnl LSH_PATH_ADD(path-id, directory)
89 +AC_DEFUN([LSH_PATH_ADD],
90 +[AC_MSG_CHECKING($2)
91 +ac_exists=no
92 +if test -d "$2/." ; then
93 +  ac_real_dir=`cd $2 && pwd`
94 +  if test -n "$ac_real_dir" ; then
95 +    ac_exists=yes
96 +    for old in $1_REAL_DIRS ; do
97 +      ac_found=no
98 +      if test x$ac_real_dir = x$old ; then
99 +        ac_found=yes;
100 +       break;
101 +      fi
102 +    done
103 +    if test $ac_found = yes ; then
104 +      AC_MSG_RESULT(already added)
105 +    else
106 +      AC_MSG_RESULT(added)
107 +      # LDFLAGS="$LDFLAGS -L $2"
108 +      $1_REAL_DIRS="$ac_real_dir [$]$1_REAL_DIRS"
109 +      $1_DIRS="$2 [$]$1_DIRS"
110 +    fi
111 +  fi
112 +fi
113 +if test $ac_exists = no ; then
114 +  AC_MSG_RESULT(not found)
115 +fi
116 +])
117 +
118 +dnl LSH_RPATH_ADD(dir)
119 +AC_DEFUN([LSH_RPATH_ADD], [LSH_PATH_ADD(RPATH_CANDIDATE, $1)])
120 +
121 +dnl LSH_RPATH_INIT(candidates)
122 +AC_DEFUN([LSH_RPATH_INIT],
123 +[AC_REQUIRE([AC_CANONICAL_HOST])dnl
124 +AC_MSG_CHECKING([for -R flag])
125 +RPATHFLAG=''
126 +case "$host_os" in
127 +  osf1*)               RPATHFLAG="-rpath " ;;
128 +  irix6.*|irix5.*)     RPATHFLAG="-rpath " ;;
129 +  solaris*)
130 +    if test "$TCC" = "yes"; then
131 +      # tcc doesn't know about -R
132 +      RPATHFLAG="-Wl,-R,"
133 +    else
134 +      RPATHFLAG=-R
135 +    fi
136 +    ;;
137 +  linux*)              RPATHFLAG="-Wl,-rpath," ;;
138 +  *)                   RPATHFLAG="" ;;
139 +esac
140 +
141 +if test x$RPATHFLAG = x ; then
142 +  AC_MSG_RESULT(none)
143 +else
144 +  AC_MSG_RESULT([using $RPATHFLAG])
145 +fi
146 +
147 +RPATH_CANDIDATE_REAL_DIRS=''
148 +RPATH_CANDIDATE_DIRS=''
149 +
150 +AC_MSG_RESULT([Searching for libraries])
151 +
152 +for d in $1 ; do
153 +  LSH_RPATH_ADD($d)
154 +done
155 +])    
156 +
157 +dnl Try to execute a main program, and if it fails, try adding some
158 +dnl -R flag.
159 +dnl LSH_RPATH_FIX
160 +AC_DEFUN([LSH_RPATH_FIX],
161 +[if test $cross_compiling = no -a "x$RPATHFLAG" != x ; then
162 +  ac_success=no
163 +  AC_TRY_RUN([int main(int argc, char **argv) { return 0; }],
164 +    ac_success=yes, ac_success=no, :)
165 +  
166 +  if test $ac_success = no ; then
167 +    AC_MSG_CHECKING([Running simple test program failed. Trying -R flags])
168 +dnl echo RPATH_CANDIDATE_DIRS = $RPATH_CANDIDATE_DIRS
169 +    ac_remaining_dirs=''
170 +    ac_rpath_save_LDFLAGS="$LDFLAGS"
171 +    for d in $RPATH_CANDIDATE_DIRS ; do
172 +      if test $ac_success = yes ; then
173 +       ac_remaining_dirs="$ac_remaining_dirs $d"
174 +      else
175 +       LDFLAGS="$RPATHFLAG$d $LDFLAGS"
176 +dnl echo LDFLAGS = $LDFLAGS
177 +       AC_TRY_RUN([int main(int argc, char **argv) { return 0; }],
178 +         [ac_success=yes
179 +         ac_rpath_save_LDFLAGS="$LDFLAGS"
180 +         AC_MSG_RESULT([adding $RPATHFLAG$d])
181 +         ],
182 +         [ac_remaining_dirs="$ac_remaining_dirs $d"], :)
183 +       LDFLAGS="$ac_rpath_save_LDFLAGS"
184 +      fi
185 +    done
186 +    RPATH_CANDIDATE_DIRS=$ac_remaining_dirs
187 +  fi
188 +  if test $ac_success = no ; then
189 +    AC_MSG_RESULT(failed)
190 +  fi
191 +fi
192 +])
193 +
194 +dnl Like AC_CHECK_LIB, but uses $KRB_LIBS rather than $LIBS.
195 +dnl LSH_CHECK_KRB_LIB(LIBRARY, FUNCTION, [, ACTION-IF-FOUND [,
196 +dnl                  ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
197 +
198 +AC_DEFUN([LSH_CHECK_KRB_LIB],
199 +[AC_CHECK_LIB([$1], [$2],
200 +  ifelse([$3], ,
201 +      [[ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
202 +           -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
203 +        AC_DEFINE_UNQUOTED($ac_tr_lib)
204 +        KRB_LIBS="-l$1 $KRB_LIBS"
205 +      ]], [$3]),
206 +  ifelse([$4], , , [$4
207 +])dnl
208 +, [$5 $KRB_LIBS])
209 +])
210 +
211 +dnl LSH_LIB_ARGP(ACTION-IF-OK, ACTION-IF-BAD)
212 +AC_DEFUN([LSH_LIB_ARGP],
213 +[ ac_argp_save_LIBS="$LIBS"
214 +  ac_argp_save_LDFLAGS="$LDFLAGS"
215 +  ac_argp_ok=no
216 +  # First check if we can link with argp.
217 +  AC_SEARCH_LIBS(argp_parse, argp,
218 +  [ LSH_RPATH_FIX
219 +    AC_CACHE_CHECK([for working argp],
220 +      lsh_cv_lib_argp_works,
221 +      [ AC_TRY_RUN(
222 +[#include <argp.h>
223 +#include <stdlib.h>
224 +
225 +static const struct argp_option
226 +options[] =
227 +{
228 +  { NULL, 0, NULL, 0, NULL, 0 }
229 +};
230 +
231 +struct child_state
232 +{
233 +  int n;
234 +};
235 +
236 +static error_t
237 +child_parser(int key, char *arg, struct argp_state *state)
238 +{
239 +  struct child_state *input = (struct child_state *) state->input;
240 +  
241 +  switch(key)
242 +    {
243 +    default:
244 +      return ARGP_ERR_UNKNOWN;
245 +    case ARGP_KEY_END:
246 +      if (!input->n)
247 +       input->n = 1;
248 +      break;
249 +    }
250 +  return 0;
251 +}
252 +
253 +const struct argp child_argp =
254 +{
255 +  options,
256 +  child_parser,
257 +  NULL, NULL, NULL, NULL, NULL
258 +};
259 +
260 +struct main_state
261 +{
262 +  struct child_state child;
263 +  int m;
264 +};
265 +
266 +static error_t
267 +main_parser(int key, char *arg, struct argp_state *state)
268 +{
269 +  struct main_state *input = (struct main_state *) state->input;
270 +
271 +  switch(key)
272 +    {
273 +    default:
274 +      return ARGP_ERR_UNKNOWN;
275 +    case ARGP_KEY_INIT:
276 +      state->child_inputs[0] = &input->child;
277 +      break;
278 +    case ARGP_KEY_END:
279 +      if (!input->m)
280 +       input->m = input->child.n;
281 +      
282 +      break;
283 +    }
284 +  return 0;
285 +}
286 +
287 +static const struct argp_child
288 +main_children[] =
289 +{
290 +  { &child_argp, 0, "", 0 },
291 +  { NULL, 0, NULL, 0}
292 +};
293 +
294 +static const struct argp
295 +main_argp =
296 +{ options, main_parser, 
297 +  NULL,
298 +  NULL,
299 +  main_children,
300 +  NULL, NULL
301 +};
302 +
303 +int main(int argc, char **argv)
304 +{
305 +  struct main_state input = { { 0 }, 0 };
306 +  char *v[2] = { "foo", NULL };
307 +
308 +  argp_parse(&main_argp, 1, v, 0, NULL, &input);
309 +
310 +  if ( (input.m == 1) && (input.child.n == 1) )
311 +    return 0;
312 +  else
313 +    return 1;
314 +}
315 +], lsh_cv_lib_argp_works=yes,
316 +   lsh_cv_lib_argp_works=no,
317 +   lsh_cv_lib_argp_works=no)])
318 +
319 +  if test x$lsh_cv_lib_argp_works = xyes ; then
320 +    ac_argp_ok=yes
321 +  else
322 +    # Reset link flags
323 +    LIBS="$ac_argp_save_LIBS"
324 +    LDFLAGS="$ac_argp_save_LDFLAGS"
325 +  fi])
326 +
327 +  if test x$ac_argp_ok = xyes ; then
328 +    ifelse([$1],, true, [$1])
329 +  else
330 +    ifelse([$2],, true, [$2])
331 +  fi   
332 +])
333 +
334 +dnl LSH_GCC_ATTRIBUTES
335 +dnl Check for gcc's __attribute__ construction
336 +
337 +AC_DEFUN([LSH_GCC_ATTRIBUTES],
338 +[AC_CACHE_CHECK(for __attribute__,
339 +              lsh_cv_c_attribute,
340 +[ AC_TRY_COMPILE([
341 +#include <stdlib.h>
342 +
343 +static void foo(void) __attribute__ ((noreturn));
344 +
345 +static void __attribute__ ((noreturn))
346 +foo(void)
347 +{
348 +  exit(1);
349 +}
350 +],[],
351 +lsh_cv_c_attribute=yes,
352 +lsh_cv_c_attribute=no)])
353 +
354 +AH_TEMPLATE([HAVE_GCC_ATTRIBUTE], [Define if the compiler understands __attribute__])
355 +if test "x$lsh_cv_c_attribute" = "xyes"; then
356 +  AC_DEFINE(HAVE_GCC_ATTRIBUTE)
357 +fi
358 +
359 +AH_BOTTOM(
360 +[#if __GNUC__ && HAVE_GCC_ATTRIBUTE
361 +# define NORETURN __attribute__ ((__noreturn__))
362 +# define PRINTF_STYLE(f, a) __attribute__ ((__format__ (__printf__, f, a)))
363 +# define UNUSED __attribute__ ((__unused__))
364 +#else
365 +# define NORETURN
366 +# define PRINTF_STYLE(f, a)
367 +# define UNUSED
368 +#endif
369 +])])
370 +
371 +# Check for alloca, and include the standard blurb in config.h
372 +AC_DEFUN([LSH_FUNC_ALLOCA],
373 +[AC_FUNC_ALLOCA
374 +AC_CHECK_HEADERS([malloc.h])
375 +AH_BOTTOM(
376 +[/* AIX requires this to be the first thing in the file.  */
377 +#ifndef __GNUC__
378 +# if HAVE_ALLOCA_H
379 +#  include <alloca.h>
380 +# else
381 +#  ifdef _AIX
382 + #pragma alloca
383 +#  else
384 +#   ifndef alloca /* predefined by HP cc +Olibcalls */
385 +char *alloca ();
386 +#   endif
387 +#  endif
388 +/* Needed for alloca on windows */
389 +#  if HAVE_MALLOC_H
390 +#   include <malloc.h>
391 +#  endif
392 +# endif
393 +#else /* defined __GNUC__ */
394 +# if HAVE_ALLOCA_H
395 +#  include <alloca.h>
396 +# else
397 +/* Needed for alloca on windows, also with gcc */
398 +#  if HAVE_MALLOC_H
399 +#   include <malloc.h>
400 +#  endif
401 +# endif
402 +#endif
403 +])])
404 +
405 +AC_DEFUN([LSH_FUNC_STRERROR],
406 +[AC_CHECK_FUNCS(strerror)
407 +AH_BOTTOM(
408 +[#if HAVE_STRERROR
409 +#define STRERROR strerror
410 +#else
411 +#define STRERROR(x) (sys_errlist[x])
412 +#endif
413 +])])
414 +
415 +AC_DEFUN([LSH_FUNC_STRSIGNAL],
416 +[AC_CHECK_FUNCS(strsignal)
417 +AC_CHECK_DECLS([sys_siglist, _sys_siglist])
418 +AH_BOTTOM(
419 +[#if HAVE_STRSIGNAL
420 +# define STRSIGNAL strsignal
421 +#else /* !HAVE_STRSIGNAL */
422 +# if HAVE_DECL_SYS_SIGLIST
423 +#  define STRSIGNAL(x) (sys_siglist[x])
424 +# else
425 +#  if HAVE_DECL__SYS_SIGLIST
426 +#   define STRSIGNAL(x) (_sys_siglist[x])
427 +#  else
428 +#   define STRSIGNAL(x) "Unknown signal"
429 +#   if __GNUC__
430 +#    warning Using dummy STRSIGNAL
431 +#   endif
432 +#  endif
433 +# endif
434 +#endif /* !HAVE_STRSIGNAL */
435 +])])
436 +
437 +dnl LSH_MAKE_CONDITIONAL(symbol, test)
438 +AC_DEFUN([LSH_MAKE_CONDITIONAL],
439 +[if $2 ; then
440 +  IF_$1=''
441 +  UNLESS_$1='# '
442 +else
443 +  IF_$1='# '
444 +  UNLESS_$1=''
445 +fi 
446 +AC_SUBST(IF_$1)
447 +AC_SUBST(UNLESS_$1)])
448 +
449 +dnl LSH_DEPENDENCY_TRACKING
450 +
451 +dnl Defines compiler flags DEP_FLAGS to generate dependency
452 +dnl information, and DEP_PROCESS that is any shell commands needed for
453 +dnl massaging the dependency information further. Dependencies are
454 +dnl generated as a side effect of compilation. Dependency files
455 +dnl themselves are not treated as targets.
456 +
457 +AC_DEFUN([LSH_DEPENDENCY_TRACKING],
458 +[AC_ARG_ENABLE(dependency_tracking,
459 +  AC_HELP_STRING([--disable-dependency-tracking],
460 +    [Disable dependency tracking. Dependency tracking doesn't work with BSD make]),,
461 +  [enable_dependency_tracking=yes])
462 +
463 +DEP_FLAGS=''
464 +DEP_PROCESS='true'
465 +if test x$enable_dependency_tracking = xyes ; then
466 +  if test x$GCC = xyes ; then
467 +    gcc_version=`gcc --version | head -1`
468 +    case "$gcc_version" in
469 +      2.*|*[[!0-9.]]2.*)
470 +        enable_dependency_tracking=no
471 +        AC_MSG_WARN([Dependency tracking disabled, gcc-3.x is needed])
472 +      ;;
473 +      *)
474 +        DEP_FLAGS='-MT $[]@ -MD -MP -MF $[]@.d'
475 +        DEP_PROCESS='true'
476 +      ;;
477 +    esac
478 +  else
479 +    enable_dependency_tracking=no
480 +    AC_MSG_WARN([Dependency tracking disabled])
481 +  fi
482 +fi
483 +
484 +if test x$enable_dependency_tracking = xyes ; then
485 +  DEP_INCLUDE='include '
486 +else
487 +  DEP_INCLUDE='# '
488 +fi
489 +
490 +AC_SUBST([DEP_INCLUDE])
491 +AC_SUBST([DEP_FLAGS])
492 +AC_SUBST([DEP_PROCESS])])
493 +
494 +dnl  GMP_TRY_ASSEMBLE(asm-code,[action-success][,action-fail])
495 +dnl  ----------------------------------------------------------
496 +dnl  Attempt to assemble the given code.
497 +dnl  Do "action-success" if this succeeds, "action-fail" if not.
498 +dnl
499 +dnl  conftest.o and conftest.out are available for inspection in
500 +dnl  "action-success".  If either action does a "break" out of a loop then
501 +dnl  an explicit "rm -f conftest*" will be necessary.
502 +dnl
503 +dnl  This is not unlike AC_TRY_COMPILE, but there's no default includes or
504 +dnl  anything in "asm-code", everything wanted must be given explicitly.
505 +
506 +AC_DEFUN([GMP_TRY_ASSEMBLE],
507 +[cat >conftest.s <<EOF
508 +[$1]
509 +EOF
510 +gmp_assemble="$CC $CFLAGS $CPPFLAGS -c conftest.s >conftest.out 2>&1"
511 +if AC_TRY_EVAL(gmp_assemble); then
512 +  cat conftest.out >&AC_FD_CC
513 +  ifelse([$2],,:,[$2])
514 +else
515 +  cat conftest.out >&AC_FD_CC
516 +  echo "configure: failed program was:" >&AC_FD_CC
517 +  cat conftest.s >&AC_FD_CC
518 +  ifelse([$3],,:,[$3])
519 +fi
520 +rm -f conftest*
521 +])
522 +
523 +dnl  GMP_PROG_CC_FOR_BUILD
524 +dnl  ---------------------
525 +dnl  Establish CC_FOR_BUILD, a C compiler for the build system.
526 +dnl
527 +dnl  If CC_FOR_BUILD is set then it's expected to work, likewise the old
528 +dnl  style HOST_CC, otherwise some likely candidates are tried, the same as
529 +dnl  configfsf.guess.
530 +
531 +AC_DEFUN([GMP_PROG_CC_FOR_BUILD],
532 +[AC_REQUIRE([AC_PROG_CC])
533 +if test -n "$CC_FOR_BUILD"; then
534 +  GMP_PROG_CC_FOR_BUILD_WORKS($CC_FOR_BUILD,,
535 +    [AC_MSG_ERROR([Specified CC_FOR_BUILD doesn't seem to work])])
536 +elif test -n "$HOST_CC"; then
537 +  GMP_PROG_CC_FOR_BUILD_WORKS($HOST_CC,
538 +    [CC_FOR_BUILD=$HOST_CC],
539 +    [AC_MSG_ERROR([Specified HOST_CC doesn't seem to work])])
540 +elif test $cross_compiling = no ; then
541 +  CC_FOR_BUILD="$CC"
542 +else
543 +  for i in cc gcc c89 c99; do
544 +    GMP_PROG_CC_FOR_BUILD_WORKS($i,
545 +      [CC_FOR_BUILD=$i
546 +       break])
547 +  done
548 +  if test -z "$CC_FOR_BUILD"; then
549 +    AC_MSG_ERROR([Cannot find a build system compiler])
550 +  fi
551 +fi
552 +
553 +AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
554 +AC_SUBST(CC_FOR_BUILD)
555 +])
556 +
557 +
558 +dnl  GMP_PROG_CC_FOR_BUILD_WORKS(cc/cflags[,[action-if-good][,action-if-bad]])
559 +dnl  -------------------------------------------------------------------------
560 +dnl  See if the given cc/cflags works on the build system.
561 +dnl
562 +dnl  It seems easiest to just use the default compiler output, rather than
563 +dnl  figuring out the .exe or whatever at this stage.
564 +
565 +AC_DEFUN([GMP_PROG_CC_FOR_BUILD_WORKS],
566 +[AC_MSG_CHECKING([build system compiler $1])
567 +# remove anything that might look like compiler output to our "||" expression
568 +rm -f conftest* a.out b.out a.exe a_out.exe
569 +cat >conftest.c <<EOF
570 +int
571 +main ()
572 +{
573 +  exit(0);
574 +}
575 +EOF
576 +gmp_compile="$1 conftest.c"
577 +cc_for_build_works=no
578 +if AC_TRY_EVAL(gmp_compile); then
579 +  if (./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest) >&AC_FD_CC 2>&1; then
580 +    cc_for_build_works=yes
581 +  fi
582 +fi
583 +rm -f conftest* a.out b.out a.exe a_out.exe
584 +AC_MSG_RESULT($cc_for_build_works)
585 +if test "$cc_for_build_works" = yes; then
586 +  ifelse([$2],,:,[$2])
587 +else
588 +  ifelse([$3],,:,[$3])
589 +fi
590 +])
591 +
592 +dnl  GMP_PROG_EXEEXT_FOR_BUILD
593 +dnl  -------------------------
594 +dnl  Determine EXEEXT_FOR_BUILD, the build system executable suffix.
595 +dnl
596 +dnl  The idea is to find what "-o conftest$foo" will make it possible to run
597 +dnl  the program with ./conftest.  On Unix-like systems this is of course
598 +dnl  nothing, for DOS it's ".exe", or for a strange RISC OS foreign file
599 +dnl  system cross compile it can be ",ff8" apparently.  Not sure if the
600 +dnl  latter actually applies to a build-system executable, maybe it doesn't,
601 +dnl  but it won't hurt to try.
602 +
603 +AC_DEFUN([GMP_PROG_EXEEXT_FOR_BUILD],
604 +[AC_REQUIRE([GMP_PROG_CC_FOR_BUILD])
605 +AC_CACHE_CHECK([for build system executable suffix],
606 +               gmp_cv_prog_exeext_for_build,
607 +[if test $cross_compiling = no ; then
608 +  gmp_cv_prog_exeext_for_build="$EXEEXT"
609 +else
610 +  cat >conftest.c <<EOF
611 +int
612 +main ()
613 +{
614 +  exit (0);
615 +}
616 +EOF
617 +  for i in .exe ,ff8 ""; do
618 +    gmp_compile="$CC_FOR_BUILD conftest.c -o conftest$i"
619 +    if AC_TRY_EVAL(gmp_compile); then
620 +      if (./conftest) 2>&AC_FD_CC; then
621 +        gmp_cv_prog_exeext_for_build=$i
622 +        break
623 +      fi
624 +    fi
625 +  done
626 +  rm -f conftest*
627 +  if test "${gmp_cv_prog_exeext_for_build+set}" != set; then
628 +    AC_MSG_ERROR([Cannot determine executable suffix])
629 +  fi
630 +fi
631 +])
632 +AC_SUBST(EXEEXT_FOR_BUILD,$gmp_cv_prog_exeext_for_build)
633 +])
634 +
635 +dnl NETTLE_CHECK_ARM_NEON
636 +dnl ---------------------
637 +dnl Check if ARM Neon instructions should be used.
638 +dnl Obeys enable_arm_neon, which should be set earlier.
639 +AC_DEFUN([NETTLE_CHECK_ARM_NEON],
640 +[if test "$enable_arm_neon" = auto ; then
641 +  if test "$cross_compiling" = yes ; then
642 +    dnl Check if compiler/assembler accepts it,
643 +    dnl without an explicit .fpu neon directive.
644 +    AC_CACHE_CHECK([if assembler accepts Neon instructions],
645 +      nettle_cv_asm_arm_neon,
646 +      [GMP_TRY_ASSEMBLE([
647 +.text
648 +foo:
649 +       vmlal.u32       q1, d0, d1
650 +],
651 +      [nettle_cv_asm_arm_neon=yes],
652 +      [nettle_cv_asm_arm_neon=no])])
653 +    enable_arm_neon="$nettle_cv_asm_arm_neon"
654 +  else
655 +    AC_MSG_CHECKING([if /proc/cpuinfo claims neon support])
656 +    if grep '^Features.*:.* neon' /proc/cpuinfo >/dev/null ; then
657 +      enable_arm_neon=yes
658 +    else
659 +      enable_arm_neon=no
660 +    fi
661 +    AC_MSG_RESULT($enable_arm_neon)
662 +  fi
663 +fi
664 +])
665 +
666 +dnl @synopsis AX_CREATE_STDINT_H [( HEADER-TO-GENERATE [, HEADERS-TO-CHECK])]
667 +dnl
668 +dnl the "ISO C9X: 7.18 Integer types <stdint.h>" section requires the
669 +dnl existence of an include file <stdint.h> that defines a set of 
670 +dnl typedefs, especially uint8_t,int32_t,uintptr_t.
671 +dnl Many older installations will not provide this file, but some will
672 +dnl have the very same definitions in <inttypes.h>. In other enviroments
673 +dnl we can use the inet-types in <sys/types.h> which would define the
674 +dnl typedefs int8_t and u_int8_t respectivly.
675 +dnl
676 +dnl This macros will create a local "_stdint.h" or the headerfile given as 
677 +dnl an argument. In many cases that file will just "#include <stdint.h>" 
678 +dnl or "#include <inttypes.h>", while in other environments it will provide 
679 +dnl the set of basic 'stdint's definitions/typedefs: 
680 +dnl   int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t
681 +dnl   int_least32_t.. int_fast32_t.. intmax_t
682 +dnl which may or may not rely on the definitions of other files,
683 +dnl or using the AC_CHECK_SIZEOF macro to determine the actual
684 +dnl sizeof each type.
685 +dnl
686 +dnl if your header files require the stdint-types you will want to create an
687 +dnl installable file mylib-int.h that all your other installable header
688 +dnl may include. So if you have a library package named "mylib", just use
689 +dnl      AX_CREATE_STDINT_H(mylib-int.h) 
690 +dnl in configure.ac and go to install that very header file in Makefile.am
691 +dnl along with the other headers (mylib.h) - and the mylib-specific headers
692 +dnl can simply use "#include <mylib-int.h>" to obtain the stdint-types.
693 +dnl
694 +dnl Remember, if the system already had a valid <stdint.h>, the generated
695 +dnl file will include it directly. No need for fuzzy HAVE_STDINT_H things...
696 +dnl
697 +dnl @, (status: used on new platforms) (see http://ac-archive.sf.net/gstdint/)
698 +dnl @author  Guido Draheim <guidod@gmx.de> 
699 +
700 +AC_DEFUN([AX_CREATE_STDINT_H],
701 +[# ------ AX CREATE STDINT H -------------------------------------
702 +AC_MSG_CHECKING([for stdint types])
703 +ac_stdint_h=`echo ifelse($1, , _stdint.h, $1)`
704 +# try to shortcircuit - if the default include path of the compiler
705 +# can find a "stdint.h" header then we assume that all compilers can.
706 +AC_CACHE_VAL([ac_cv_header_stdint_t],[
707 +old_CXXFLAGS="$CXXFLAGS" ; CXXFLAGS=""
708 +old_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS=""
709 +old_CFLAGS="$CFLAGS"     ; CFLAGS=""
710 +AC_TRY_COMPILE([#include <stdint.h>],[int_least32_t v = 0;],
711 +[ac_cv_stdint_result="(assuming C99 compatible system)"
712 + ac_cv_header_stdint_t="stdint.h"; ],
713 +[ac_cv_header_stdint_t=""])
714 +CXXFLAGS="$old_CXXFLAGS"
715 +CPPFLAGS="$old_CPPFLAGS"
716 +CFLAGS="$old_CFLAGS" ])
717 +
718 +v="... $ac_cv_header_stdint_h"
719 +if test "$ac_stdint_h" = "stdint.h" ; then
720 + AC_MSG_RESULT([(are you sure you want them in ./stdint.h?)])
721 +elif test "$ac_stdint_h" = "inttypes.h" ; then
722 + AC_MSG_RESULT([(are you sure you want them in ./inttypes.h?)])
723 +elif test "_$ac_cv_header_stdint_t" = "_" ; then
724 + AC_MSG_RESULT([(putting them into $ac_stdint_h)$v])
725 +else
726 + ac_cv_header_stdint="$ac_cv_header_stdint_t"
727 + AC_MSG_RESULT([$ac_cv_header_stdint (shortcircuit)])
728 +fi
729 +
730 +if test "_$ac_cv_header_stdint_t" = "_" ; then # can not shortcircuit..
731 +
732 +dnl .....intro message done, now do a few system checks.....
733 +dnl btw, all CHECK_TYPE macros do automatically "DEFINE" a type, therefore
734 +dnl we use the autoconf implementation detail _AC CHECK_TYPE_NEW instead
735 +
736 +inttype_headers=`echo $2 | sed -e 's/,/ /g'`
737 +
738 +ac_cv_stdint_result="(no helpful system typedefs seen)"
739 +AC_CACHE_CHECK([for stdint uintptr_t], [ac_cv_header_stdint_x],[
740 + ac_cv_header_stdint_x="" # the 1997 typedefs (inttypes.h)
741 +  AC_MSG_RESULT([(..)])
742 +  for i in stdint.h inttypes.h sys/inttypes.h $inttype_headers ; do
743 +   unset ac_cv_type_uintptr_t 
744 +   unset ac_cv_type_uint64_t
745 +   _AC_CHECK_TYPE_NEW(uintptr_t,[ac_cv_header_stdint_x=$i],dnl
746 +     continue,[#include <$i>])
747 +   AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
748 +   ac_cv_stdint_result="(seen uintptr_t$and64 in $i)"
749 +   break;
750 +  done
751 +  AC_MSG_CHECKING([for stdint uintptr_t])
752 + ])
753 +
754 +if test "_$ac_cv_header_stdint_x" = "_" ; then
755 +AC_CACHE_CHECK([for stdint uint32_t], [ac_cv_header_stdint_o],[
756 + ac_cv_header_stdint_o="" # the 1995 typedefs (sys/inttypes.h)
757 +  AC_MSG_RESULT([(..)])
758 +  for i in inttypes.h sys/inttypes.h stdint.h $inttype_headers ; do
759 +   unset ac_cv_type_uint32_t
760 +   unset ac_cv_type_uint64_t
761 +   AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],dnl
762 +     continue,[#include <$i>])
763 +   AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
764 +   ac_cv_stdint_result="(seen uint32_t$and64 in $i)"
765 +   break;
766 +  done
767 +  AC_MSG_CHECKING([for stdint uint32_t])
768 + ])
769 +fi
770 +
771 +if test "_$ac_cv_header_stdint_x" = "_" ; then
772 +if test "_$ac_cv_header_stdint_o" = "_" ; then
773 +AC_CACHE_CHECK([for stdint u_int32_t], [ac_cv_header_stdint_u],[
774 + ac_cv_header_stdint_u="" # the BSD typedefs (sys/types.h)
775 +  AC_MSG_RESULT([(..)])
776 +  for i in sys/types.h inttypes.h sys/inttypes.h $inttype_headers ; do
777 +   unset ac_cv_type_u_int32_t
778 +   unset ac_cv_type_u_int64_t
779 +   AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],dnl
780 +     continue,[#include <$i>])
781 +   AC_CHECK_TYPE(u_int64_t,[and64="/u_int64_t"],[and64=""],[#include<$i>])
782 +   ac_cv_stdint_result="(seen u_int32_t$and64 in $i)"
783 +   break;
784 +  done
785 +  AC_MSG_CHECKING([for stdint u_int32_t])
786 + ])
787 +fi fi
788 +
789 +dnl if there was no good C99 header file, do some typedef checks...
790 +if test "_$ac_cv_header_stdint_x" = "_" ; then
791 +   AC_MSG_CHECKING([for stdint datatype model])
792 +   AC_MSG_RESULT([(..)])
793 +   AC_CHECK_SIZEOF(char)
794 +   AC_CHECK_SIZEOF(short)
795 +   AC_CHECK_SIZEOF(int)
796 +   AC_CHECK_SIZEOF(long)
797 +   AC_CHECK_SIZEOF(void*)
798 +   ac_cv_stdint_char_model=""
799 +   ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_char"
800 +   ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_short"
801 +   ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_int"
802 +   ac_cv_stdint_long_model=""
803 +   ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_int"
804 +   ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_long"
805 +   ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_voidp"
806 +   name="$ac_cv_stdint_long_model"
807 +   case "$ac_cv_stdint_char_model/$ac_cv_stdint_long_model" in
808 +    122/242)     name="$name,  IP16 (standard 16bit machine)" ;;
809 +    122/244)     name="$name,  LP32 (standard 32bit mac/win)" ;;
810 +    122/*)       name="$name        (unusual int16 model)" ;; 
811 +    124/444)     name="$name, ILP32 (standard 32bit unixish)" ;;
812 +    124/488)     name="$name,  LP64 (standard 64bit unixish)" ;;
813 +    124/448)     name="$name, LLP64 (unusual  64bit unixish)" ;;
814 +    124/*)       name="$name        (unusual int32 model)" ;; 
815 +    128/888)     name="$name, ILP64 (unusual  64bit numeric)" ;;
816 +    128/*)       name="$name        (unusual int64 model)" ;; 
817 +    222/*|444/*) name="$name        (unusual dsptype)" ;;
818 +     *)          name="$name        (very unusal model)" ;;
819 +   esac
820 +   AC_MSG_RESULT([combined for stdint datatype model...  $name])
821 +fi
822 +
823 +if test "_$ac_cv_header_stdint_x" != "_" ; then
824 +   ac_cv_header_stdint="$ac_cv_header_stdint_x"
825 +elif  test "_$ac_cv_header_stdint_o" != "_" ; then
826 +   ac_cv_header_stdint="$ac_cv_header_stdint_o"
827 +elif  test "_$ac_cv_header_stdint_u" != "_" ; then
828 +   ac_cv_header_stdint="$ac_cv_header_stdint_u"
829 +else
830 +   ac_cv_header_stdint="stddef.h"
831 +fi
832 +
833 +AC_MSG_CHECKING([for extra inttypes in chosen header])
834 +AC_MSG_RESULT([($ac_cv_header_stdint)])
835 +dnl see if int_least and int_fast types are present in _this_ header.
836 +unset ac_cv_type_int_least32_t
837 +unset ac_cv_type_int_fast32_t
838 +AC_CHECK_TYPE(int_least32_t,,,[#include <$ac_cv_header_stdint>])
839 +AC_CHECK_TYPE(int_fast32_t,,,[#include<$ac_cv_header_stdint>])
840 +AC_CHECK_TYPE(intmax_t,,,[#include <$ac_cv_header_stdint>])
841 +
842 +fi # shortcircut to system "stdint.h"
843 +# ------------------ PREPARE VARIABLES ------------------------------
844 +if test "$GCC" = "yes" ; then
845 +ac_cv_stdint_message="using gnu compiler "`$CC --version | head -1` 
846 +else
847 +ac_cv_stdint_message="using $CC"
848 +fi
849 +
850 +AC_MSG_RESULT([make use of $ac_cv_header_stdint in $ac_stdint_h dnl
851 +$ac_cv_stdint_result])
852 +
853 +# ----------------- DONE inttypes.h checks START header -------------
854 +AC_CONFIG_COMMANDS([$ac_stdint_h],[
855 +AC_MSG_NOTICE(creating $ac_stdint_h : $_ac_stdint_h)
856 +ac_stdint=$tmp/_stdint.h
857 +
858 +echo "#ifndef" $_ac_stdint_h >$ac_stdint
859 +echo "#define" $_ac_stdint_h "1" >>$ac_stdint
860 +echo "#ifndef" _GENERATED_STDINT_H >>$ac_stdint
861 +echo "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdint
862 +echo "/* generated $ac_cv_stdint_message */" >>$ac_stdint
863 +if test "_$ac_cv_header_stdint_t" != "_" ; then 
864 +echo "#define _STDINT_HAVE_STDINT_H" "1" >>$ac_stdint
865 +fi
866 +
867 +cat >>$ac_stdint <<STDINT_EOF
868 +
869 +/* ................... shortcircuit part ........................... */
870 +
871 +#if defined HAVE_STDINT_H || defined _STDINT_HAVE_STDINT_H
872 +#include <stdint.h>
873 +#else
874 +#include <stddef.h>
875 +
876 +/* .................... configured part ............................ */
877 +
878 +STDINT_EOF
879 +
880 +echo "/* whether we have a C99 compatible stdint header file */" >>$ac_stdint
881 +if test "_$ac_cv_header_stdint_x" != "_" ; then
882 +  ac_header="$ac_cv_header_stdint_x"
883 +  echo "#define _STDINT_HEADER_INTPTR" '"'"$ac_header"'"' >>$ac_stdint
884 +else
885 +  echo "/* #undef _STDINT_HEADER_INTPTR */" >>$ac_stdint
886 +fi
887 +
888 +echo "/* whether we have a C96 compatible inttypes header file */" >>$ac_stdint
889 +if  test "_$ac_cv_header_stdint_o" != "_" ; then
890 +  ac_header="$ac_cv_header_stdint_o"
891 +  echo "#define _STDINT_HEADER_UINT32" '"'"$ac_header"'"' >>$ac_stdint
892 +else
893 +  echo "/* #undef _STDINT_HEADER_UINT32 */" >>$ac_stdint
894 +fi
895 +
896 +echo "/* whether we have a BSD compatible inet types header */" >>$ac_stdint
897 +if  test "_$ac_cv_header_stdint_u" != "_" ; then
898 +  ac_header="$ac_cv_header_stdint_u"
899 +  echo "#define _STDINT_HEADER_U_INT32" '"'"$ac_header"'"' >>$ac_stdint
900 +else
901 +  echo "/* #undef _STDINT_HEADER_U_INT32 */" >>$ac_stdint
902 +fi
903 +
904 +echo "" >>$ac_stdint
905 +
906 +if test "_$ac_header" != "_" ; then if test "$ac_header" != "stddef.h" ; then
907 +  echo "#include <$ac_header>" >>$ac_stdint
908 +  echo "" >>$ac_stdint
909 +fi fi
910 +
911 +echo "/* which 64bit typedef has been found */" >>$ac_stdint
912 +if test "$ac_cv_type_uint64_t" = "yes" ; then
913 +echo "#define   _STDINT_HAVE_UINT64_T" "1"  >>$ac_stdint
914 +else
915 +echo "/* #undef _STDINT_HAVE_UINT64_T */" >>$ac_stdint
916 +fi
917 +if test "$ac_cv_type_u_int64_t" = "yes" ; then
918 +echo "#define   _STDINT_HAVE_U_INT64_T" "1"  >>$ac_stdint
919 +else
920 +echo "/* #undef _STDINT_HAVE_U_INT64_T */" >>$ac_stdint
921 +fi
922 +echo "" >>$ac_stdint
923 +
924 +echo "/* which type model has been detected */" >>$ac_stdint
925 +if test "_$ac_cv_stdint_char_model" != "_" ; then
926 +echo "#define   _STDINT_CHAR_MODEL" "$ac_cv_stdint_char_model" >>$ac_stdint
927 +echo "#define   _STDINT_LONG_MODEL" "$ac_cv_stdint_long_model" >>$ac_stdint
928 +else
929 +echo "/* #undef _STDINT_CHAR_MODEL // skipped */" >>$ac_stdint
930 +echo "/* #undef _STDINT_LONG_MODEL // skipped */" >>$ac_stdint
931 +fi
932 +echo "" >>$ac_stdint
933 +
934 +echo "/* whether int_least types were detected */" >>$ac_stdint
935 +if test "$ac_cv_type_int_least32_t" = "yes"; then
936 +echo "#define   _STDINT_HAVE_INT_LEAST32_T" "1"  >>$ac_stdint
937 +else
938 +echo "/* #undef _STDINT_HAVE_INT_LEAST32_T */" >>$ac_stdint
939 +fi
940 +echo "/* whether int_fast types were detected */" >>$ac_stdint
941 +if test "$ac_cv_type_int_fast32_t" = "yes"; then
942 +echo "#define   _STDINT_HAVE_INT_FAST32_T" "1" >>$ac_stdint
943 +else
944 +echo "/* #undef _STDINT_HAVE_INT_FAST32_T */" >>$ac_stdint
945 +fi
946 +echo "/* whether intmax_t type was detected */" >>$ac_stdint
947 +if test "$ac_cv_type_intmax_t" = "yes"; then
948 +echo "#define   _STDINT_HAVE_INTMAX_T" "1" >>$ac_stdint
949 +else
950 +echo "/* #undef _STDINT_HAVE_INTMAX_T */" >>$ac_stdint
951 +fi
952 +echo "" >>$ac_stdint
953 +
954 +  cat >>$ac_stdint <<STDINT_EOF
955 +/* .................... detections part ............................ */
956 +
957 +/* whether we need to define bitspecific types from compiler base types */
958 +#ifndef _STDINT_HEADER_INTPTR
959 +#ifndef _STDINT_HEADER_UINT32
960 +#ifndef _STDINT_HEADER_U_INT32
961 +#define _STDINT_NEED_INT_MODEL_T
962 +#else
963 +#define _STDINT_HAVE_U_INT_TYPES
964 +#endif
965 +#endif
966 +#endif
967 +
968 +#ifdef _STDINT_HAVE_U_INT_TYPES
969 +#undef _STDINT_NEED_INT_MODEL_T
970 +#endif
971 +
972 +#ifdef  _STDINT_CHAR_MODEL
973 +#if     _STDINT_CHAR_MODEL+0 == 122 || _STDINT_CHAR_MODEL+0 == 124
974 +#ifndef _STDINT_BYTE_MODEL
975 +#define _STDINT_BYTE_MODEL 12
976 +#endif
977 +#endif
978 +#endif
979 +
980 +#ifndef _STDINT_HAVE_INT_LEAST32_T
981 +#define _STDINT_NEED_INT_LEAST_T
982 +#endif
983 +
984 +#ifndef _STDINT_HAVE_INT_FAST32_T
985 +#define _STDINT_NEED_INT_FAST_T
986 +#endif
987 +
988 +#ifndef _STDINT_HEADER_INTPTR
989 +#define _STDINT_NEED_INTPTR_T
990 +#ifndef _STDINT_HAVE_INTMAX_T
991 +#define _STDINT_NEED_INTMAX_T
992 +#endif
993 +#endif
994 +
995 +
996 +/* .................... definition part ............................ */
997 +
998 +/* some system headers have good uint64_t */
999 +#ifndef _HAVE_UINT64_T
1000 +#if     defined _STDINT_HAVE_UINT64_T  || defined HAVE_UINT64_T
1001 +#define _HAVE_UINT64_T
1002 +#elif   defined _STDINT_HAVE_U_INT64_T || defined HAVE_U_INT64_T
1003 +#define _HAVE_UINT64_T
1004 +typedef u_int64_t uint64_t;
1005 +#endif
1006 +#endif
1007 +
1008 +#ifndef _HAVE_UINT64_T
1009 +/* .. here are some common heuristics using compiler runtime specifics */
1010 +#if defined __STDC_VERSION__ && defined __STDC_VERSION__ >= 199901L
1011 +#define _HAVE_UINT64_T
1012 +typedef long long int64_t;
1013 +typedef unsigned long long uint64_t;
1014 +
1015 +#elif !defined __STRICT_ANSI__
1016 +#if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__
1017 +#define _HAVE_UINT64_T
1018 +typedef __int64 int64_t;
1019 +typedef unsigned __int64 uint64_t;
1020 +
1021 +#elif defined __GNUC__ || defined __MWERKS__ || defined __ELF__
1022 +/* note: all ELF-systems seem to have loff-support which needs 64-bit */
1023 +#if !defined _NO_LONGLONG
1024 +#define _HAVE_UINT64_T
1025 +typedef long long int64_t;
1026 +typedef unsigned long long uint64_t;
1027 +#endif
1028 +
1029 +#elif defined __alpha || (defined __mips && defined _ABIN32)
1030 +#if !defined _NO_LONGLONG
1031 +typedef long int64_t;
1032 +typedef unsigned long uint64_t;
1033 +#endif
1034 +  /* compiler/cpu type to define int64_t */
1035 +#endif
1036 +#endif
1037 +#endif
1038 +
1039 +#if defined _STDINT_HAVE_U_INT_TYPES
1040 +/* int8_t int16_t int32_t defined by inet code, redeclare the u_intXX types */
1041 +typedef u_int8_t uint8_t;
1042 +typedef u_int16_t uint16_t;
1043 +typedef u_int32_t uint32_t;
1044 +
1045 +/* glibc compatibility */
1046 +#ifndef __int8_t_defined
1047 +#define __int8_t_defined
1048 +#endif
1049 +#endif
1050 +
1051 +#ifdef _STDINT_NEED_INT_MODEL_T
1052 +/* we must guess all the basic types. Apart from byte-adressable system, */
1053 +/* there a few 32-bit-only dsp-systems that we guard with BYTE_MODEL 8-} */
1054 +/* (btw, those nibble-addressable systems are way off, or so we assume) */
1055 +
1056 +dnl   /* have a look at "64bit and data size neutrality" at */
1057 +dnl   /* http://unix.org/version2/whatsnew/login_64bit.html */
1058 +dnl   /* (the shorthand "ILP" types always have a "P" part) */
1059 +
1060 +#if defined _STDINT_BYTE_MODEL
1061 +#if _STDINT_LONG_MODEL+0 == 242
1062 +/* 2:4:2 =  IP16 = a normal 16-bit system                */
1063 +typedef unsigned char   uint8_t;
1064 +typedef unsigned short  uint16_t;
1065 +typedef unsigned long   uint32_t;
1066 +#ifndef __int8_t_defined
1067 +#define __int8_t_defined
1068 +typedef          char    int8_t;
1069 +typedef          short   int16_t;
1070 +typedef          long    int32_t;
1071 +#endif
1072 +#elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL == 444
1073 +/* 2:4:4 =  LP32 = a 32-bit system derived from a 16-bit */
1074 +/* 4:4:4 = ILP32 = a normal 32-bit system                */
1075 +typedef unsigned char   uint8_t;
1076 +typedef unsigned short  uint16_t;
1077 +typedef unsigned int    uint32_t;
1078 +#ifndef __int8_t_defined
1079 +#define __int8_t_defined
1080 +typedef          char    int8_t;
1081 +typedef          short   int16_t;
1082 +typedef          int     int32_t;
1083 +#endif
1084 +#elif _STDINT_LONG_MODEL+0 == 484 || _STDINT_LONG_MODEL+0 == 488
1085 +/* 4:8:4 =  IP32 = a 32-bit system prepared for 64-bit    */
1086 +/* 4:8:8 =  LP64 = a normal 64-bit system                 */
1087 +typedef unsigned char   uint8_t;
1088 +typedef unsigned short  uint16_t;
1089 +typedef unsigned int    uint32_t;
1090 +#ifndef __int8_t_defined
1091 +#define __int8_t_defined
1092 +typedef          char    int8_t;
1093 +typedef          short   int16_t;
1094 +typedef          int     int32_t;
1095 +#endif
1096 +/* this system has a "long" of 64bit */
1097 +#ifndef _HAVE_UINT64_T
1098 +#define _HAVE_UINT64_T
1099 +typedef unsigned long   uint64_t;
1100 +typedef          long    int64_t;
1101 +#endif
1102 +#elif _STDINT_LONG_MODEL+0 == 448
1103 +/*      LLP64   a 64-bit system derived from a 32-bit system */
1104 +typedef unsigned char   uint8_t;
1105 +typedef unsigned short  uint16_t;
1106 +typedef unsigned int    uint32_t;
1107 +#ifndef __int8_t_defined
1108 +#define __int8_t_defined
1109 +typedef          char    int8_t;
1110 +typedef          short   int16_t;
1111 +typedef          int     int32_t;
1112 +#endif
1113 +/* assuming the system has a "long long" */
1114 +#ifndef _HAVE_UINT64_T
1115 +#define _HAVE_UINT64_T
1116 +typedef unsigned long long uint64_t;
1117 +typedef          long long  int64_t;
1118 +#endif
1119 +#else
1120 +#define _STDINT_NO_INT32_T
1121 +#endif
1122 +#else
1123 +#define _STDINT_NO_INT8_T
1124 +#define _STDINT_NO_INT32_T
1125 +#endif
1126 +#endif
1127 +
1128 +/*
1129 + * quote from SunOS-5.8 sys/inttypes.h:
1130 + * Use at your own risk.  As of February 1996, the committee is squarely
1131 + * behind the fixed sized types; the "least" and "fast" types are still being
1132 + * discussed.  The probability that the "fast" types may be removed before
1133 + * the standard is finalized is high enough that they are not currently
1134 + * implemented.
1135 + */
1136 +
1137 +#if defined _STDINT_NEED_INT_LEAST_T
1138 +typedef  int8_t    int_least8_t;
1139 +typedef  int16_t   int_least16_t;
1140 +typedef  int32_t   int_least32_t;
1141 +#ifdef _HAVE_UINT64_T
1142 +typedef  int64_t   int_least64_t;
1143 +#endif
1144 +
1145 +typedef uint8_t   uint_least8_t;
1146 +typedef uint16_t  uint_least16_t;
1147 +typedef uint32_t  uint_least32_t;
1148 +#ifdef _HAVE_UINT64_T
1149 +typedef uint64_t  uint_least64_t;
1150 +#endif
1151 +  /* least types */
1152 +#endif
1153 +
1154 +#if defined _STDINT_NEED_INT_FAST_T
1155 +typedef  int8_t    int_fast8_t; 
1156 +typedef  int       int_fast16_t;
1157 +typedef  int32_t   int_fast32_t;
1158 +#ifdef _HAVE_UINT64_T
1159 +typedef  int64_t   int_fast64_t;
1160 +#endif
1161 +
1162 +typedef uint8_t   uint_fast8_t; 
1163 +typedef unsigned  uint_fast16_t;
1164 +typedef uint32_t  uint_fast32_t;
1165 +#ifdef _HAVE_UINT64_T
1166 +typedef uint64_t  uint_fast64_t;
1167 +#endif
1168 +  /* fast types */
1169 +#endif
1170 +
1171 +#ifdef _STDINT_NEED_INTMAX_T
1172 +#ifdef _HAVE_UINT64_T
1173 +typedef  int64_t       intmax_t;
1174 +typedef uint64_t      uintmax_t;
1175 +#else
1176 +typedef          long  intmax_t;
1177 +typedef unsigned long uintmax_t;
1178 +#endif
1179 +#endif
1180 +
1181 +#ifdef _STDINT_NEED_INTPTR_T
1182 +#ifndef __intptr_t_defined
1183 +#define __intptr_t_defined
1184 +/* we encourage using "long" to store pointer values, never use "int" ! */
1185 +#if   _STDINT_LONG_MODEL+0 == 242 || _STDINT_LONG_MODEL+0 == 484
1186 +typedef  unsinged int   uintptr_t;
1187 +typedef           int    intptr_t;
1188 +#elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL+0 == 444
1189 +typedef  unsigned long  uintptr_t;
1190 +typedef           long   intptr_t;
1191 +#elif _STDINT_LONG_MODEL+0 == 448 && defined _HAVE_UINT64_T
1192 +typedef        uint64_t uintptr_t;
1193 +typedef         int64_t  intptr_t;
1194 +#else /* matches typical system types ILP32 and LP64 - but not IP16 or LLP64 */
1195 +typedef  unsigned long  uintptr_t;
1196 +typedef           long   intptr_t;
1197 +#endif
1198 +#endif
1199 +#endif
1200 +
1201 +  /* shortcircuit*/
1202 +#endif
1203 +  /* once */
1204 +#endif
1205 +#endif
1206 +STDINT_EOF
1207 +    if cmp -s $ac_stdint_h $ac_stdint 2>/dev/null; then
1208 +      AC_MSG_NOTICE([$ac_stdint_h is unchanged])
1209 +    else
1210 +      ac_dir=`AS_DIRNAME(["$ac_stdint_h"])`
1211 +      AS_MKDIR_P(["$ac_dir"])
1212 +      rm -f $ac_stdint_h
1213 +      mv $ac_stdint $ac_stdint_h
1214 +    fi
1215 +],[# variables for create stdint.h replacement
1216 +PACKAGE="$PACKAGE"
1217 +VERSION="$VERSION"
1218 +ac_stdint_h="$ac_stdint_h"
1219 +_ac_stdint_h=AS_TR_CPP(_$PACKAGE-$ac_stdint_h)
1220 +ac_cv_stdint_message="$ac_cv_stdint_message"
1221 +ac_cv_header_stdint_t="$ac_cv_header_stdint_t"
1222 +ac_cv_header_stdint_x="$ac_cv_header_stdint_x"
1223 +ac_cv_header_stdint_o="$ac_cv_header_stdint_o"
1224 +ac_cv_header_stdint_u="$ac_cv_header_stdint_u"
1225 +ac_cv_type_uint64_t="$ac_cv_type_uint64_t"
1226 +ac_cv_type_u_int64_t="$ac_cv_type_u_int64_t"
1227 +ac_cv_stdint_char_model="$ac_cv_stdint_char_model"
1228 +ac_cv_stdint_long_model="$ac_cv_stdint_long_model"
1229 +ac_cv_type_int_least32_t="$ac_cv_type_int_least32_t"
1230 +ac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t"
1231 +ac_cv_type_intmax_t="$ac_cv_type_intmax_t"
1232 +])
1233 +])