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