maint: run update-copyright for 2014.
[m4/ericb.git] / build-aux / m4 / gmp.m4
blobad9640d209b6c5cbff9ad478d966a082f6a71df2
1 ## -*- Autoconf -*-
2 ## Copyright (C) 2000-2001, 2003, 2006-2008, 2010, 2013-2014 Free
3 ## Software Foundation, Inc.
4 ##
5 ## This file is part of GNU M4.
6 ##
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/>.
20 # serial 10
22 m4_define([_M4_LIB_GMP],
23 [AC_ARG_WITH([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
29   no:*)
30     M4_cv_using_lib_gmp=no
31     ;;
32   *::yes)
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
36     ;;
37   *:-lgmp:no)
38     AC_MSG_WARN([gmp works but `gmp.h' is missing])
39     M4_cv_using_lib_gmp=no
40     ;;
41   yes:*:yes)
42     M4_cv_using_lib_gmp=yes
43     ;;
44   *)
45     M4_cv_using_lib_gmp=no
46     AC_MSG_WARN([could not detect gmp library])
47     ;;
48 esac
49 ])# _M4_LIB_GMP
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"
59 LIBS="$LIBS -lgmp"
60 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if HAVE_GMP_H
61 #  include <gmp.h>
62 #endif]],
63   [[mpq_t n; mpq_init (n);]])],
64   [LIBADD_GMP=-lgmp])
65 LIBS=$M4_gmp_save_LIBS
66 AC_SUBST([LIBADD_GMP])
68 _M4_LIB_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])
77 ])# M4_LIB_GMP