ax_detect_gmp.m4 revision 1.1 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)
4 case "$with_gmp" in
5 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"
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_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>]], [[
20 mpz_t n, d;
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"
26 LIBS="$SAVE_LIBS"
27 ;;
28 build)
29 MP_CPPFLAGS="-I$gmp_srcdir -I$with_gmp_builddir"
30 MP_LIBS="$with_gmp_builddir/libgmp.la"
31 ;;
32 esac
33 SAVE_CPPFLAGS="$CPPFLAGS"
34 SAVE_LDFLAGS="$LDFLAGS"
35 SAVE_LIBS="$LIBS"
36 CPPFLAGS="$MP_CPPFLAGS $CPPFLAGS"
37 LDFLAGS="$MP_LDFLAGS $LDFLAGS"
38 LIBS="$MP_LIBS $LIBS"
39 need_get_memory_functions=false
40 AC_CHECK_DECLS(mp_get_memory_functions,[],[
41 need_get_memory_functions=true
42 ],[#include <gmp.h>])
43 CPPFLAGS="$SAVE_CPPFLAGS"
44 LDFLAGS="$SAVE_LDFLAGS"
45 LIBS="$SAVE_LIBS"
46 AM_CONDITIONAL(NEED_GET_MEMORY_FUNCTIONS, test x$need_get_memory_functions = xtrue)
47 ])
48