1AC_DEFUN([AX_DETECT_GMP], [ 2AC_DEFINE([USE_GMP_FOR_MP], [], [use gmp to implement isl_int]) 3AX_SUBMODULE(gmp,system|build,system) 4case "$with_gmp" in 5system) 6 if test "x$with_gmp_prefix" != "x"; then 7 MP_CPPFLAGS="-I$with_gmp_prefix/include" 8 MP_LDFLAGS="-L$with_gmp_prefix/lib" 9 fi 10 MP_LIBS=-lgmp 11 SAVE_CPPFLAGS="$CPPFLAGS" 12 SAVE_LDFLAGS="$LDFLAGS" 13 SAVE_LIBS="$LIBS" 14 CPPFLAGS="$MP_CPPFLAGS $CPPFLAGS" 15 LDFLAGS="$MP_LDFLAGS $LDFLAGS" 16 LIBS="$MP_LIBS $LIBS" 17 AC_CHECK_HEADER([gmp.h], [], [AC_ERROR([gmp.h header not found])]) 18 AC_CHECK_LIB([gmp], [main], [], [AC_ERROR([gmp library not found])]) 19 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gmp.h>]], [[ 20 mpz_t n, d; 21 if (mpz_divisible_p(n, d)) 22 mpz_divexact_ui(n, n, 4); 23 ]])], [], [AC_ERROR([gmp library too old])]) 24 CPPFLAGS="$SAVE_CPPFLAGS" 25 LDFLAGS="$SAVE_LDFLAGS" 26 LIBS="$SAVE_LIBS" 27 ;; 28build) 29 MP_CPPFLAGS="-I$gmp_srcdir -I$with_gmp_builddir" 30 MP_LIBS="$with_gmp_builddir/libgmp.la" 31 ;; 32esac 33SAVE_CPPFLAGS="$CPPFLAGS" 34SAVE_LDFLAGS="$LDFLAGS" 35SAVE_LIBS="$LIBS" 36CPPFLAGS="$MP_CPPFLAGS $CPPFLAGS" 37LDFLAGS="$MP_LDFLAGS $LDFLAGS" 38LIBS="$MP_LIBS $LIBS" 39need_get_memory_functions=false 40AC_CHECK_DECLS(mp_get_memory_functions,[],[ 41 need_get_memory_functions=true 42],[#include <gmp.h>]) 43CPPFLAGS="$SAVE_CPPFLAGS" 44LDFLAGS="$SAVE_LDFLAGS" 45LIBS="$SAVE_LIBS" 46AM_CONDITIONAL(NEED_GET_MEMORY_FUNCTIONS, test x$need_get_memory_functions = xtrue) 47]) 48