16 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
17 |
# 02111-1307 USA |
# 02111-1307 USA |
18 |
|
|
19 |
# serial 4 |
# serial 5 |
20 |
|
|
21 |
m4_define([_AC_LIB_GMP], |
m4_define([_AC_LIB_GMP], |
22 |
[AC_ARG_WITH(gmp, |
[case $LIBADD_GMP:$ac_cv_header_gmp_h in |
23 |
[ --without-gmp don't use GNU multiple precision arithmetic library], |
:yes) |
|
[use_gmp=$withval], [use_gmp=yes]) |
|
|
|
|
|
case $use_gmp:$GMP_LIB:$ac_cv_header_gmp_h in |
|
|
*::yes) |
|
24 |
AC_MSG_WARN([gmp library not found or does not appear to work |
AC_MSG_WARN([gmp library not found or does not appear to work |
25 |
but `gmp.h' is present]) |
but `gmp.h' is present]) |
26 |
ac_cv_using_lib_gmp=no |
ac_cv_using_lib_gmp=no |
27 |
;; |
;; |
28 |
*:-lgmp:no) |
-lgmp:no) |
29 |
AC_MSG_WARN([gmp works but `gmp.h' is missing]) |
AC_MSG_WARN([gmp works but `gmp.h' is missing]) |
30 |
ac_cv_using_lib_gmp=no |
ac_cv_using_lib_gmp=no |
31 |
;; |
;; |
32 |
yes:*:yes) |
*:yes) |
33 |
ac_cv_using_lib_gmp=yes |
ac_cv_using_lib_gmp=yes |
34 |
;; |
;; |
35 |
no:*) |
*) |
36 |
ac_cv_using_lib_gmp=no |
ac_cv_using_lib_gmp=no |
37 |
;; |
;; |
38 |
esac |
esac |
|
|
|
|
if test "$ac_cv_using_lib_gmp" = yes; then |
|
|
AC_DEFINE(WITH_GMP, 1, |
|
|
[Define to 1 if the GNU multiple precision library should be used.]) |
|
|
fi |
|
39 |
])# _AC_LIB_GMP |
])# _AC_LIB_GMP |
40 |
|
|
41 |
AC_DEFUN([AC_LIB_GMP], |
AC_DEFUN([AC_LIB_GMP], |
42 |
[AC_CHECK_HEADERS([gmp.h]) |
[AC_CHECK_HEADERS([gmp.h]) |
43 |
AC_CHECK_LIB([gmp], [mpq_init], [GMP_LIB=-lgmp]) |
# Some versions of gmp provide mpq_init as a macro, so we need to |
44 |
AC_SUBST([GMP_LIB])dnl |
# include the header file, otherwise the detection will fail. |
45 |
|
gmp_save_LIBS="$LIBS" |
46 |
|
LIBS="$LIBS -lgmp" |
47 |
|
AC_TRY_LINK([#if HAVE_GMP_H |
48 |
|
# include <gmp.h> |
49 |
|
#endif], |
50 |
|
[mpq_t n; mpq_init (n);], |
51 |
|
[LIBADD_GMP=-lgmp]) |
52 |
|
LIBS="$gmp_save_LIBS" |
53 |
|
|
54 |
AC_CACHE_CHECK([if using GNU multiple precision arithmetic library], |
AC_CACHE_CHECK([if using GNU multiple precision arithmetic library], |
55 |
[ac_cv_using_lib_gmp], |
[ac_cv_using_lib_gmp], |
56 |
[_AC_LIB_GMP]) |
[_AC_LIB_GMP]) |
57 |
AC_SUBST([USE_GMP], [$ac_cv_using_lib_gmp])dnl |
|
58 |
|
# Don't try to link in libgmp if we are not using it after the last call |
59 |
|
if test "x$ac_cv_using_lib_gmp" = xyes; then |
60 |
|
AC_DEFINE(USE_GMP, 1, [Define to 1 if using gmp library.]) |
61 |
|
else |
62 |
|
LIBADD_GMP= |
63 |
|
fi |
64 |
|
|
65 |
|
AC_SUBST([USE_GMP], [$ac_cv_using_lib_gmp]) |
66 |
|
AC_SUBST([LIBADD_GMP]) |
67 |
])# AC_LIB_GMP |
])# AC_LIB_GMP |