| 1 |
dnl Check for MPFR and dependencies |
| 2 |
dnl Copyright (C) 2004, 2005, 2021 Free Software Foundation, Inc. |
| 3 |
dnl |
| 4 |
dnl This file is free software, distributed under the terms of the GNU |
| 5 |
dnl General Public License. As a special exception to the GNU General |
| 6 |
dnl Public License, this file may be distributed as part of a program |
| 7 |
dnl that contains a configuration script generated by Autoconf, under |
| 8 |
dnl the same distribution terms as the rest of that program. |
| 9 |
dnl |
| 10 |
dnl Defines HAVE_MPFR to 1 if a working MPFR/GMP setup is |
| 11 |
dnl found, and sets @LIBMPFR@ to the necessary libraries. |
| 12 |
|
| 13 |
AC_DEFUN([GNUPG_CHECK_MPFR], |
| 14 |
[ |
| 15 |
AC_ARG_WITH([mpfr], |
| 16 |
AS_HELP_STRING([--with-mpfr=DIR], |
| 17 |
[look for the mpfr and gmp libraries in DIR]), |
| 18 |
[_do_mpfr=$withval],[_do_mpfr=yes]) |
| 19 |
|
| 20 |
if test "$_do_mpfr" != "no" ; then |
| 21 |
if test -d "$withval" ; then |
| 22 |
CPPFLAGS="${CPPFLAGS} -I$withval/include" |
| 23 |
LDFLAGS="${LDFLAGS} -L$withval/lib" |
| 24 |
fi |
| 25 |
|
| 26 |
_mpfr_save_libs=$LIBS |
| 27 |
_combo="-lmpfr -lgmp" |
| 28 |
LIBS="$LIBS $_combo" |
| 29 |
|
| 30 |
AC_MSG_CHECKING([whether mpfr via "$_combo" is present and usable]) |
| 31 |
|
| 32 |
AC_LINK_IFELSE([ |
| 33 |
AC_LANG_PROGRAM([ |
| 34 |
#include <stdio.h> |
| 35 |
#include <mpfr.h> |
| 36 |
#include <gmp.h> |
| 37 |
],[ |
| 38 |
mpfr_t p; |
| 39 |
mpz_t z; |
| 40 |
mpfr_init(p); |
| 41 |
mpz_init(z); |
| 42 |
mpfr_printf("%Rf%Zd", p, z); |
| 43 |
mpfr_clear(p); |
| 44 |
mpz_clear(z); |
| 45 |
])],_found_mpfr=yes,_found_mpfr=no) |
| 46 |
|
| 47 |
AC_MSG_RESULT([$_found_mpfr]) |
| 48 |
|
| 49 |
LIBS=$_mpfr_save_libs |
| 50 |
|
| 51 |
if test $_found_mpfr = yes ; then |
| 52 |
AC_DEFINE(HAVE_MPFR,1, |
| 53 |
[Define to 1 if you have fully functional mpfr and gmp libraries.]) |
| 54 |
AC_SUBST(LIBMPFR,$_combo) |
| 55 |
break |
| 56 |
fi |
| 57 |
|
| 58 |
unset _mpfr_save_libs |
| 59 |
unset _combo |
| 60 |
unset _found_mpfr |
| 61 |
fi |
| 62 |
])dnl |