You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1241 lines
37 KiB

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