tac: fix mem corruption when failing to read non seekable inputs
[coreutils.git] / m4 / gmp.m4
blobcff874b8b3d65177f0985a280b97376e9ed422f3
1 # Tests for GNU GMP (or any compatible replacement).
3 dnl Copyright (C) 2008-2016 Free Software Foundation, Inc.
5 dnl This file is free software; the Free Software Foundation
6 dnl gives unlimited permission to copy and/or distribute it,
7 dnl with or without modifications, as long as this notice is preserved.
9 dnl Written by James Youngman.
11 dnl Check for libgmp.  We avoid use of AC_CHECK_LIBS because we don't want to
12 dnl add this to $LIBS for all targets.
13 AC_DEFUN([cu_GMP],
15   LIB_GMP=
16   AC_SUBST([LIB_GMP])
18   AC_ARG_WITH([gmp],
19     AS_HELP_STRING([--without-gmp],
20       [do not use the GNU MP library for arbitrary precision
21        calculation (default: use it if available)]),
22     [cu_use_gmp=$withval],
23     [cu_use_gmp=auto])
25   if test $cu_use_gmp != no; then
26     dnl It was noticed on one MacOS X 10.5.8 system at least
27     dnl that the libs were available but the header wasn't
28     HAVE_GMP=0
29     AC_CHECK_HEADERS_ONCE([gmp.h])
30     if test $ac_cv_header_gmp_h = yes; then
31       cu_saved_libs=$LIBS
32       AC_SEARCH_LIBS([__gmpz_init], [gmp],
33         [test "$ac_cv_search___gmpz_init" = "none required" ||
34            LIB_GMP=$ac_cv_search___gmpz_init
35          AC_DEFINE([HAVE_GMP], [1],
36            [Define if you have GNU libgmp (or replacement)])
37          HAVE_GMP=1
38          # This only available in GMP >= 5
39          AC_CHECK_DECLS([mpz_inits], [], [], [[#include <gmp.h>]])
40         ])
41       LIBS=$cu_saved_libs
42     fi
43     if test $HAVE_GMP != 1; then
44      AC_MSG_WARN([libgmp development library was not found or not usable.])
45      AC_MSG_WARN([AC_PACKAGE_NAME will be built without GMP support.])
46     fi
47   fi