2 ## Copyright (C) 2000-2001, 2003, 2006-2008, 2010, 2013 Free Software
5 ## This file is part of GNU M4.
7 ## GNU M4 is free software: you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation, either version 3 of the License, or
10 ## (at your option) any later version.
12 ## GNU M4 is distributed in the hope that it will be useful,
13 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ## GNU General Public License for more details.
17 ## You should have received a copy of the GNU General Public License
18 ## along with this program. If not, see <http://www.gnu.org/licenses/>.
22 m4_define([_M4_LIB_GMP],
24 [AS_HELP_STRING([--without-gmp],
25 [don't use GNU multiple precision arithmetic library])],
26 [use_gmp=$withval], [use_gmp=yes])
28 case $use_gmp:$LIBADD_GMP:$ac_cv_header_gmp_h in
30 M4_cv_using_lib_gmp=no
33 AC_MSG_WARN([gmp library not found or does not appear to work
34 but `gmp.h' is present])
35 M4_cv_using_lib_gmp=no
38 AC_MSG_WARN([gmp works but `gmp.h' is missing])
39 M4_cv_using_lib_gmp=no
42 M4_cv_using_lib_gmp=yes
45 M4_cv_using_lib_gmp=no
46 AC_MSG_WARN([could not detect gmp library])
52 AC_DEFUN([M4_LIB_GMP],
53 [AC_PREREQ([2.56])dnl We use the new compiler based header checking in 2.56
54 AC_CHECK_HEADERS([gmp.h], [], [], [AC_INCLUDES_DEFAULT])
55 m4_pattern_allow([^M4_gmp_save_LIBS$])
56 # Some versions of gmp provide mpq_init as a macro, so we need to
57 # include the header file, otherwise the detection will fail.
58 M4_gmp_save_LIBS="$LIBS"
60 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if HAVE_GMP_H
63 [[mpq_t n; mpq_init (n);]])],
65 LIBS=$M4_gmp_save_LIBS
66 AC_SUBST([LIBADD_GMP])
70 # Don't try to link in libgmp if we are not using it after the last call
71 if test "$M4_cv_using_lib_gmp" = yes; then
72 AC_DEFINE([USE_GMP], [1],
73 [Define to 1 if using the GNU multiple precision library.])
76 AC_SUBST([USE_GMP], [$M4_cv_using_lib_gmp])