log: Fix bug introduced on 2012-03-09.
[gnulib.git] / m4 / log.m4
1 # log.m4 serial 2
2 dnl Copyright (C) 2011-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_LOG],
8 [
9   AC_REQUIRE([gl_MATH_H_DEFAULTS])
10
11   dnl Determine LOG_LIBM.
12   gl_COMMON_DOUBLE_MATHFUNC([log])
13
14   save_LIBS="$LIBS"
15   LIBS="$LIBS $LOG_LIBM"
16   gl_FUNC_LOG_WORKS
17   LIBS="$save_LIBS"
18   case "$gl_cv_func_log_works" in
19     *yes) ;;
20     *) REPLACE_LOG=1 ;;
21   esac
22 ])
23
24 dnl Test whether log() works.
25 dnl On OSF/1 5.1, log(-0.0) is NaN.
26 AC_DEFUN([gl_FUNC_LOG_WORKS],
27 [
28   AC_REQUIRE([AC_PROG_CC])
29   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
30   AC_CACHE_CHECK([whether log works], [gl_cv_func_log_works],
31     [
32       AC_RUN_IFELSE(
33         [AC_LANG_SOURCE([[
34 #include <math.h>
35 volatile double x;
36 double y;
37 int main ()
38 {
39   x = -0.0;
40   y = log (x);
41   if (!(y + y == y))
42     return 1;
43   return 0;
44 }
45 ]])],
46         [gl_cv_func_log_works=yes],
47         [gl_cv_func_log_works=no],
48         [case "$host_os" in
49            osf*) gl_cv_func_log_works="guessing no";;
50            *)    gl_cv_func_log_works="guessing yes";;
51          esac
52         ])
53     ])
54 ])