a80a9c1997-02-11Fredrik Hübinette (Hubbe) AC_INIT(mpz_glue.c) AC_CONFIG_HEADER(gmp_machine.h)
e269811998-09-20Fredrik Hübinette (Hubbe) AC_MODULE_INIT()
a80a9c1997-02-11Fredrik Hübinette (Hubbe) 
7a5e471999-11-22Fredrik Hübinette (Hubbe) #############################################################################
51ed781999-10-03Fredrik Hübinette (Hubbe) 
91d0102014-10-14Martin Nilsson PIKE_FEATURE_NODEP([Gmp (bignums)])
f655492001-02-13Mirar (Pontus Hagland) 
72cdcd2016-02-09Henrik Grubbström (Grubba) PIKE_PKG_CONFIG(libmpfr)
4653742015-11-29Henrik Grubbström (Grubba) ORIG_CHECK_HEADERS(gmp.h mpfr.h mpf2mpfr.h)
91d0102014-10-14Martin Nilsson AC_CHECK_LIB(gmp, main)
4653742015-11-29Henrik Grubbström (Grubba) AC_CHECK_LIB(mpfr, mpfr_init)
91d0102014-10-14Martin Nilsson AC_TRY_LINK([ #include <gmp.h>
e5cbd92014-10-31Martin Nilsson ], [mpz_import], [], [
40262c2014-10-14Martin Nilsson  AC_MSG_ERROR([ Cannot compile bignums without the GMP library.
e5cbd92014-10-31Martin Nilsson Your GMP library is too old (<4.1) or does not work.
6be5232011-03-08Martin Stjernholm 
91d0102014-10-14Martin Nilsson To compile Pike you are required to install a working GMP
40262c2014-10-14Martin Nilsson library on your system. ])
91d0102014-10-14Martin Nilsson ])
6be5232011-03-08Martin Stjernholm 
91d0102014-10-14Martin Nilsson if test "$ac_cv_header_gmp_h" = "yes" ; then
e2791e2003-03-28Martin Stjernholm 
ff3a162004-09-26Marcus Comstedt  echo >>confdefs.h '
91d0102014-10-14Martin Nilsson #include <gmp.h>'
5d481c2005-06-16Henrik Grubbström (Grubba) 
5692c32015-07-08Martin Nilsson  PIKE_FEATURE_OK([Gmp (bignums)])
ff3a162004-09-26Marcus Comstedt  AC_CHECK_SIZEOF(mp_limb_t, 0)
4f561d2003-05-19Martin Stjernholm 
e2b9d82014-12-02Martin Nilsson  # Side channel secure powm added in 5.0 AC_MSG_CHECKING(for mpz_powm_sec) AC_TRY_LINK([], [mpz_powm_sec], [ AC_DEFINE(HAVE_GMP5) AC_MSG_RESULT(yes) ], [AC_MSG_RESULT(no)]) # Side channel secure invert added in 6.0 AC_MSG_CHECKING(for mpn_sec_invert) AC_TRY_LINK([], [mpn_sec_invert], [ AC_DEFINE(HAVE_GMP6) AC_MSG_RESULT(yes) ], [AC_MSG_RESULT(no)])
5d481c2005-06-16Henrik Grubbström (Grubba)  # Some packages of gmp have a gmp.h that lies about the number # bits in limbs when running with the non-default ABI. # (eg /opt/csw/include/gmp.h on Solaris 10/sparc). AC_MSG_CHECKING(if GMP_NUMB_BITS is valid and lacks nails) AC_CACHE_VAL([pike_cv_gmp_numb_bits_valid], [ AC_TRY_COMPILE([
5937102008-09-15Henrik Grubbström (Grubba) #if GMP_NUMB_BITS != (SIZEOF_MP_LIMB_T * CHAR_BIT)
5d481c2005-06-16Henrik Grubbström (Grubba) #error Cannot cope with GMP using nail bits.
5937102008-09-15Henrik Grubbström (Grubba) #error GMP_NUMB_BITS != (SIZEOF_MP_LIMB_T * CHAR_BIT)
5d481c2005-06-16Henrik Grubbström (Grubba) #endif ], [], [pike_cv_gmp_numb_bits_valid=yes], [pike_cv_gmp_numb_bits_valid=no]) ]) AC_MSG_RESULT($pike_cv_gmp_numb_bits_valid) if test "x$pike_cv_gmp_numb_bits_valid" = "xno"; then AC_DEFINE(PIKE_GMP_LIMB_BITS_INVALID) AC_MSG_CHECKING(for the actual number of numb bits) AC_CACHE_VAL([pike_cv_actual_gmp_numb_bits], [ rm -f confdefs.out.2 AC_TRY_RUN([ #include <stdio.h> int main(int argc, char **argv) { mpz_t mpz; mp_limb_t limb; int bits = 0; FILE *fp = fopen("confdefs.out.2", "w"); /* weird filename to circumvent configure weirdness */ if (!fp) return 1; mpz_init(mpz); mpz_set_ui(mpz, 1); limb = mpz_getlimbn(mpz, 0); while ((mpz->_mp_size < 2) || !(mpz_getlimbn(mpz, 1) & 1)) { mpz_mul_2exp(mpz, mpz, 1); bits++; } fprintf(fp, "%d\n", bits); return 0; } ], [ pike_cv_actual_gmp_numb_bits="`cat confdefs.out.2`" rm -f confdefs.out.2 ], [ pike_cv_actual_gmp_numb_bits="" ], [ pike_cv_actual_gmp_numb_bits="" ]) ]) if test "x$pike_cv_actual_gmp_numb_bits" = "x"; then AC_MSG_RESULT([unknown - using $ac_cv_sizeof_mp_limb_t * CHAR_BIT]) else AC_MSG_RESULT($pike_cv_actual_gmp_numb_bits) AC_DEFINE_UNQUOTED(PIKE_GMP_NUMB_BITS, $pike_cv_actual_gmp_numb_bits) fi fi
91d0102014-10-14Martin Nilsson else
40262c2014-10-14Martin Nilsson  AC_MSG_ERROR([ Cannot compile bignums without the GMP library. To
b5ab692013-06-11Martin Nilsson compile Pike you are required to install a working GMP
40262c2014-10-14Martin Nilsson library on your system. ])
a80a9c1997-02-11Fredrik Hübinette (Hubbe) fi
76e0652003-02-25Mirar (Pontus Hagland) AC_OUTPUT(Makefile,echo FOO >stamp-h )