]> www.ginac.de Git - cln.git/blob - autoconf/acinclude.m4
Recommendation for g++-3.1 users.
[cln.git] / autoconf / acinclude.m4
1 # Is the gmp header file new enough? (should be implemented with an argument)
2 AC_DEFUN(CL_GMP_H_VERSION,
3 [AC_CACHE_CHECK([for recent enough gmp.h], cl_cv_new_gmp_h, [
4   AC_TRY_CPP([#include <gmp.h>
5 #if !defined(__GNU_MP_VERSION) || (__GNU_MP_VERSION < 3)
6  #error "ancient gmp.h"
7 #endif],
8 cl_cv_new_gmp_h="yes", cl_cv_new_gmp_h="no")
9 ])])dnl
10
11 # Does libgmp provide some functionality introduced in version 3.0?
12 AC_DEFUN(CL_GMP_CHECK,
13 [AC_CACHE_CHECK([for working libgmp], cl_cv_new_libgmp, [
14     SAVELIBS=$LIBS
15     LIBS="$LIBS -lgmp"
16     AC_TRY_LINK([#include <gmp.h>],[mpn_divexact_by3(0,0,0)],
17 cl_cv_new_libgmp="yes", cl_cv_new_libgmp="no"; LIBS=$SAVELIBS)
18 ])])
19
20 # What is sizeof(mp_limb_t)?  (It has to match sizeof(uintD) later.)
21 AC_DEFUN(CL_GMP_SET_UINTD,
22 [AC_CACHE_CHECK([how large gmp demands uintD to be], cl_cv_gmp_set_uintd, [
23     AC_TRY_RUN([#include <stdio.h>
24 #include <gmp.h>
25 int main() {
26     FILE *f=fopen("conftestval", "w");
27     if (!f) return(255);
28     if (sizeof(mp_limb_t) > sizeof(long))
29         fprintf(f, "long long");
30     else if (sizeof(mp_limb_t) == sizeof(long))
31         fprintf(f, "long");
32     else if (sizeof(mp_limb_t) == sizeof(int))
33         fprintf(f, "int");
34     else return(sizeof(mp_limb_t));
35 #if defined(__GMP_BITS_PER_MP_LIMB)
36     /* Is there a nail in a limb? */
37     if (8*sizeof(mp_limb_t)!=__GMP_BITS_PER_MP_LIMB)
38         return(254);
39 #endif
40     return(0);
41 }], cl_cv_gmp_set_uintd=`cat conftestval`
42     cl_gmp_demands="GMP_DEMANDS_UINTD_`echo ${cl_cv_gmp_set_uintd} | sed -e 'y/ gilnot/_GILNOT/'`",
43     gmp_retval="$ac_status"
44     if test x$gmp_retval = "x255"; then AC_MSG_ERROR([error opening output file.]); fi
45     if test x$gmp_retval = "x254"; then AC_MSG_ERROR([nails in MP limbs are unsupported.]); fi
46     AC_MSG_ERROR([Don't know which C-type has sizeof $gmp_retval.]),
47     AC_MSG_ERROR([cross-compiling - cannot determine]))
48 ])
49 AC_DEFINE_UNQUOTED($cl_gmp_demands)
50 ])