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 MP_CPPFLAGS="-I$with_gmp_prefix/include"
8 MP_LDFLAGS="-L$with_gmp_prefix/lib"
11 SAVE_CPPFLAGS="$CPPFLAGS"
12 SAVE_LDFLAGS="$LDFLAGS"
14 CPPFLAGS="$MP_CPPFLAGS $CPPFLAGS"
15 LDFLAGS="$MP_LDFLAGS $LDFLAGS"
17 AC_CHECK_HEADER([gmp.h], [], [AC_MSG_ERROR([gmp.h header not found])])
18 AC_CHECK_LIB([gmp], [main], [], [AC_MSG_ERROR([gmp library not found])])
19 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gmp.h>]], [[
21 if (mpz_divisible_p(n, d))
22 mpz_divexact_ui(n, n, 4);
23 ]])], [], [AC_MSG_ERROR([gmp library too old])])
24 CPPFLAGS="$SAVE_CPPFLAGS"
25 LDFLAGS="$SAVE_LDFLAGS"
29 MP_CPPFLAGS="-I$gmp_srcdir -I$with_gmp_builddir"
30 MP_LIBS="$with_gmp_builddir/libgmp.la"
33 SAVE_CPPFLAGS="$CPPFLAGS"
34 SAVE_LDFLAGS="$LDFLAGS"
36 CPPFLAGS="$MP_CPPFLAGS $CPPFLAGS"
37 LDFLAGS="$MP_LDFLAGS $LDFLAGS"
39 need_get_memory_functions=false
40 AC_CHECK_DECLS(mp_get_memory_functions,[],[
41 need_get_memory_functions=true
43 CPPFLAGS="$SAVE_CPPFLAGS"
44 LDFLAGS="$SAVE_LDFLAGS"
46 AM_CONDITIONAL(NEED_GET_MEMORY_FUNCTIONS, test x$need_get_memory_functions = xtrue)