1 AC_DEFUN([AX_DETECT_GMP], [
2 AC_DEFINE([USE_GMP_FOR_MP], [], [use gmp to implement isl_int])
3 AX_SUBMODULE(gmp,system|build,system)
6 if test "x$with_gmp_prefix" != "x"; then
7 isl_configure_args="$isl_configure_args --with-gmp=$with_gmp_prefix"
8 MP_CPPFLAGS="-I$with_gmp_prefix/include"
9 MP_LDFLAGS="-L$with_gmp_prefix/lib"
12 SAVE_CPPFLAGS="$CPPFLAGS"
13 SAVE_LDFLAGS="$LDFLAGS"
15 CPPFLAGS="$MP_CPPFLAGS $CPPFLAGS"
16 LDFLAGS="$MP_LDFLAGS $LDFLAGS"
18 AC_CHECK_HEADER([gmp.h], [], [AC_ERROR([gmp.h header not found])])
19 AC_CHECK_LIB([gmp], [main], [], [AC_ERROR([gmp library not found])])
20 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gmp.h>]], [[
22 if (mpz_divisible_p(n, d))
23 mpz_divexact_ui(n, n, 4);
24 ]])], [], [AC_ERROR([gmp library too old])])
25 CPPFLAGS="$SAVE_CPPFLAGS"
26 LDFLAGS="$SAVE_LDFLAGS"
30 MP_CPPFLAGS="-I$gmp_srcdir -I$with_gmp_builddir"
31 MP_LIBS="$with_gmp_builddir/libgmp.la"
34 SAVE_CPPFLAGS="$CPPFLAGS"
35 SAVE_LDFLAGS="$LDFLAGS"
37 CPPFLAGS="$MP_CPPFLAGS $CPPFLAGS"
38 LDFLAGS="$MP_LDFLAGS $LDFLAGS"
40 need_get_memory_functions=false
41 AC_CHECK_DECLS(mp_get_memory_functions,[],[
42 need_get_memory_functions=true
44 CPPFLAGS="$SAVE_CPPFLAGS"
45 LDFLAGS="$SAVE_LDFLAGS"
47 AM_CONDITIONAL(NEED_GET_MEMORY_FUNCTIONS, test x$need_get_memory_functions = xtrue)