add isl_local_space_is_params
[isl.git] / m4 / ax_detect_gmp.m4
blob43fa20dc53198b6318e652d3306ee71819c10f84
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                 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"
10         fi
11         MP_LIBS=-lgmp
12         SAVE_CPPFLAGS="$CPPFLAGS"
13         SAVE_LDFLAGS="$LDFLAGS"
14         SAVE_LIBS="$LIBS"
15         CPPFLAGS="$MP_CPPFLAGS $CPPFLAGS"
16         LDFLAGS="$MP_LDFLAGS $LDFLAGS"
17         LIBS="$MP_LIBS $LIBS"
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>]], [[
21                 mpz_t n, d;
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"
27         LIBS="$SAVE_LIBS"
28         ;;
29 build)
30         MP_CPPFLAGS="-I$gmp_srcdir -I$with_gmp_builddir"
31         MP_LIBS="$with_gmp_builddir/libgmp.la"
32         ;;
33 esac
34 SAVE_CPPFLAGS="$CPPFLAGS"
35 SAVE_LDFLAGS="$LDFLAGS"
36 SAVE_LIBS="$LIBS"
37 CPPFLAGS="$MP_CPPFLAGS $CPPFLAGS"
38 LDFLAGS="$MP_LDFLAGS $LDFLAGS"
39 LIBS="$MP_LIBS $LIBS"
40 need_get_memory_functions=false
41 AC_CHECK_DECLS(mp_get_memory_functions,[],[
42         need_get_memory_functions=true
43 ],[#include <gmp.h>])
44 CPPFLAGS="$SAVE_CPPFLAGS"
45 LDFLAGS="$SAVE_LDFLAGS"
46 LIBS="$SAVE_LIBS"
47 AM_CONDITIONAL(NEED_GET_MEMORY_FUNCTIONS, test x$need_get_memory_functions = xtrue)