Add isinf module.
[gnulib.git] / m4 / isinf.m4
1 # isinf.m4 serial 1
2 dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 AC_DEFUN([gl_ISINF],
8 [
9   AC_REQUIRE([gl_MATH_H_DEFAULTS])
10   dnl Persuade glibc <math.h> to declare isinf.
11   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
12   AC_CHECK_DECLS([isinf], , , [#include <math.h>])
13   if test "$ac_cv_have_decl_isinf" = yes; then
14     gl_CHECK_MATH_LIB([ISINF_LIBM], [x = isinf (x);])
15     if test "$ISINF_LIBM" != missing; then
16       dnl Test whether isinf() on 'long double' works.
17       gl_ISINFL_WORKS
18       case "$gl_cv_func_isinfl_works" in
19         *yes) ;;
20         *)    ISINF_LIBM=missing;;
21       esac
22     fi
23   fi
24   if test "$ac_cv_have_decl_isinf" != yes ||
25      test "$ISINF_LIBM" = missing; then
26     REPLACE_ISINF=1
27     AC_LIBOBJ([isinf])
28     ISINF_LIBM=
29   fi
30   AC_SUBST([REPLACE_ISINF])
31   AC_SUBST([ISINF_LIBM])
32 ])
33
34 dnl Test whether isinf() correctly returns false for LDBL_MAX.
35 AC_DEFUN([gl_ISINFL_WORKS],
36 [
37   AC_REQUIRE([AC_PROG_CC])
38   AC_REQUIRE([AC_C_BIGENDIAN])
39   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
40   AC_CACHE_CHECK([whether isinf(long double) works], [gl_cv_func_isinfl_works],
41     [
42       AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <float.h>
43                                        #include <math.h>]],
44                                      [[return !!isinf(LDBL_MAX);]])],
45                     [gl_cv_func_isinfl_works=yes],
46                     [gl_cv_func_isinfl_works=no],
47                     [gl_cv_func_isinfl_works="guessing no"])
48     ])
49 ])