prepare NEWS.stable
[gnulib.git] / m4 / logb.m4
1 # logb.m4 serial 5
2 dnl Copyright (C) 2010-2012 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
11   dnl Persuade glibc <math.h> to declare logb().
12   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
13
14   dnl Test whether logb() is declared.
15   AC_CHECK_DECLS([logb], , , [[#include <math.h>]])
16   if test "$ac_cv_have_decl_logb" != yes; then
17     HAVE_DECL_LOGB=0
18   fi
19   dnl Test whether logb() can be used without libm.
20   LOGB_LIBM=?
21   AC_LINK_IFELSE(
22     [AC_LANG_PROGRAM(
23        [[#ifndef __NO_MATH_INLINES
24          # define __NO_MATH_INLINES 1 /* for glibc */
25          #endif
26          #include <math.h>
27          extern
28          #ifdef __cplusplus
29          "C"
30          #endif
31          double logb (double x);
32          double x;]],
33        [[x = logb(x);]])],
34     [LOGB_LIBM=])
35   if test "$LOGB_LIBM" = "?"; then
36     save_LIBS="$LIBS"
37     LIBS="$LIBS -lm"
38     AC_LINK_IFELSE(
39       [AC_LANG_PROGRAM(
40          [[#ifndef __NO_MATH_INLINES
41            # define __NO_MATH_INLINES 1 /* for glibc */
42            #endif
43            #include <math.h>
44            extern
45            #ifdef __cplusplus
46            "C"
47            #endif
48            double logb (double x);
49            double x;]],
50          [[x = logb(x);]])],
51       [LOGB_LIBM="-lm"])
52     LIBS="$save_LIBS"
53   fi
54   if test "$LOGB_LIBM" = "?"; then
55     LOGB_LIBM=
56   fi
57   AC_SUBST([LOGB_LIBM])
58 ])