Blame isl-0.14/m4/ax_detect_gmp.m4

Packit fb9d21
AC_DEFUN([AX_DETECT_GMP], [
Packit fb9d21
AC_DEFINE([USE_GMP_FOR_MP], [], [use gmp to implement isl_int])
Packit fb9d21
AX_SUBMODULE(gmp,system|build,system)
Packit fb9d21
case "$with_gmp" in
Packit fb9d21
system)
Packit fb9d21
	if test "x$with_gmp_prefix" != "x"; then
Packit fb9d21
		isl_configure_args="$isl_configure_args --with-gmp=$with_gmp_prefix"
Packit fb9d21
		MP_CPPFLAGS="-I$with_gmp_prefix/include"
Packit fb9d21
		MP_LDFLAGS="-L$with_gmp_prefix/lib"
Packit fb9d21
	fi
Packit fb9d21
	MP_LIBS=-lgmp
Packit fb9d21
	SAVE_CPPFLAGS="$CPPFLAGS"
Packit fb9d21
	SAVE_LDFLAGS="$LDFLAGS"
Packit fb9d21
	SAVE_LIBS="$LIBS"
Packit fb9d21
	CPPFLAGS="$MP_CPPFLAGS $CPPFLAGS"
Packit fb9d21
	LDFLAGS="$MP_LDFLAGS $LDFLAGS"
Packit fb9d21
	LIBS="$MP_LIBS $LIBS"
Packit fb9d21
	AC_CHECK_HEADER([gmp.h], [], [AC_ERROR([gmp.h header not found])])
Packit fb9d21
	AC_CHECK_LIB([gmp], [main], [], [AC_ERROR([gmp library not found])])
Packit fb9d21
	AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gmp.h>]], [[
Packit fb9d21
		mpz_t n, d;
Packit fb9d21
		if (mpz_divisible_p(n, d))
Packit fb9d21
			mpz_divexact_ui(n, n, 4);
Packit fb9d21
	]])], [], [AC_ERROR([gmp library too old])])
Packit fb9d21
	CPPFLAGS="$SAVE_CPPFLAGS"
Packit fb9d21
	LDFLAGS="$SAVE_LDFLAGS"
Packit fb9d21
	LIBS="$SAVE_LIBS"
Packit fb9d21
	;;
Packit fb9d21
build)
Packit fb9d21
	MP_CPPFLAGS="-I$gmp_srcdir -I$with_gmp_builddir"
Packit fb9d21
	MP_LIBS="$with_gmp_builddir/libgmp.la"
Packit fb9d21
	;;
Packit fb9d21
esac
Packit fb9d21
SAVE_CPPFLAGS="$CPPFLAGS"
Packit fb9d21
SAVE_LDFLAGS="$LDFLAGS"
Packit fb9d21
SAVE_LIBS="$LIBS"
Packit fb9d21
CPPFLAGS="$MP_CPPFLAGS $CPPFLAGS"
Packit fb9d21
LDFLAGS="$MP_LDFLAGS $LDFLAGS"
Packit fb9d21
LIBS="$MP_LIBS $LIBS"
Packit fb9d21
need_get_memory_functions=false
Packit fb9d21
AC_CHECK_DECLS(mp_get_memory_functions,[],[
Packit fb9d21
	need_get_memory_functions=true
Packit fb9d21
],[#include <gmp.h>])
Packit fb9d21
CPPFLAGS="$SAVE_CPPFLAGS"
Packit fb9d21
LDFLAGS="$SAVE_LDFLAGS"
Packit fb9d21
LIBS="$SAVE_LIBS"
Packit fb9d21
AM_CONDITIONAL(NEED_GET_MEMORY_FUNCTIONS, test x$need_get_memory_functions = xtrue)
Packit fb9d21
])