Gnulib has changed again. Reimport. Adjust. Rinse. Repeat.
[m4/ericb.git] / ltdl / m4 / gmp.m4
blob1bdffda3d8adecb910effb54a453e73de850fb8c
1 # -*- Autoconf -*-
2 # Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 # 02110-1301  USA
19 # serial 7
21 m4_define([_m4_LIB_GMP],
22 [AC_ARG_WITH(gmp,
23 [  --without-gmp           don't use GNU multiple precision arithmetic library],
24 [use_gmp=$withval], [use_gmp=yes])
26 case $use_gmp:$LIBADD_GMP:$ac_cv_header_gmp_h in
27   *::yes)
28     AC_MSG_WARN([gmp library not found or does not appear to work
29                  but `gmp.h' is present])
30     m4_cv_using_lib_gmp=no
31     ;;
32   *:-lgmp:no)
33     AC_MSG_WARN([gmp works but `gmp.h' is missing])
34     m4_cv_using_lib_gmp=no
35     ;;
36   yes:*:yes)
37     m4_cv_using_lib_gmp=yes
38     ;;
39   no:*)
40     m4_cv_using_lib_gmp=no
41     ;;
42 esac
43 ])# _m4_LIB_GMP
46 AC_DEFUN([m4_LIB_GMP],
47 [AC_PREREQ(2.56)dnl We use the new compiler based header checking in 2.56
48 AC_CHECK_HEADERS([gmp.h], [], [], [AC_INCLUDES_DEFAULT])
49 m4_pattern_allow([^m4_gmp_save_LIBS$])
50 m4_pattern_allow([^m4_cv_using_lib_gmp])
51 # Some versions of gmp provide mpq_init as a macro, so we need to
52 # include the header file, otherwise the detection will fail.
53 m4_gmp_save_LIBS="$LIBS"
54 LIBS="$LIBS -lgmp"
55 AC_TRY_LINK([#if HAVE_GMP_H
56 #  include <gmp.h>
57 #endif],
58   [mpq_t n; mpq_init (n);],
59   [LIBADD_GMP=-lgmp])
60 LIBS=$m4_gmp_save_LIBS
61 AC_SUBST([LIBADD_GMP])
63 AC_CACHE_CHECK([if using GNU multiple precision arithmetic library],
64                [m4_cv_using_lib_gmp],
65                [_m4_LIB_GMP])
67 # Don't try to link in libgmp if we are not using it after the last call
68 if test "$m4_cv_using_lib_gmp" = yes; then
69   AC_DEFINE(USE_GMP, 1,
70     [Define to 1 if using the GNU multiple precision library.])
73 AC_SUBST([USE_GMP], [$m4_cv_using_lib_gmp])
74 ])# m4_LIB_GMP