logb: Provide missing declaration for Cygwin.
[gnulib.git] / m4 / logb.m4
1 # logb.m4 serial 1
2 dnl Copyright (C) 2010 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_FUNC_LOGB],
8 [
9   AC_REQUIRE([gl_MATH_H_DEFAULTS])
10   dnl Test whether logb() is declared.
11   AC_CHECK_DECLS([logb], , , [#include <math.h>])
12   if test "$ac_cv_have_decl_logb" != yes; then
13     HAVE_DECL_LOGB=0
14   fi
15   dnl Test whether logb() can be used without libm.
16   LOGB_LIBM=?
17   AC_TRY_LINK([
18      #ifndef __NO_MATH_INLINES
19      # define __NO_MATH_INLINES 1 /* for glibc */
20      #endif
21      #include <math.h>
22      extern double logb (double x);
23      double x;],
24     [x = logb(x);],
25     [LOGB_LIBM=])
26   if test "$LOGB_LIBM" = "?"; then
27     save_LIBS="$LIBS"
28     LIBS="$LIBS -lm"
29     AC_TRY_LINK([
30        #ifndef __NO_MATH_INLINES
31        # define __NO_MATH_INLINES 1 /* for glibc */
32        #endif
33        #include <math.h>
34        extern double logb (double x);
35        double x;],
36       [x = logb(x);],
37       [LOGB_LIBM="-lm"])
38     LIBS="$save_LIBS"
39   fi
40   if test "$LOGB_LIBM" = "?"; then
41     LOGB_LIBM=
42   fi
43   AC_SUBST([LOGB_LIBM])
44 ])