maint: update copyright
[gnulib.git] / m4 / log2l.m4
1 # log2l.m4 serial 1
2 dnl Copyright (C) 2010-2014 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_LOG2L],
8 [
9   AC_REQUIRE([gl_MATH_H_DEFAULTS])
10   AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
11   AC_REQUIRE([gl_FUNC_LOG2])
12
13   dnl Persuade glibc <math.h> to declare log2l().
14   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
15
16   dnl Test whether log2l() exists. Assume that log2l(), if it exists, is
17   dnl defined in the same library as log2().
18   save_LIBS="$LIBS"
19   LIBS="$LIBS $LOG2_LIBM"
20   AC_CHECK_FUNCS([log2l])
21   LIBS="$save_LIBS"
22   if test $ac_cv_func_log2l = yes; then
23     LOG2L_LIBM="$LOG2_LIBM"
24     HAVE_LOG2L=1
25     dnl Also check whether it's declared.
26     dnl IRIX 6.5 has log2l() in libm but doesn't declare it in <math.h>.
27     AC_CHECK_DECL([log2l], , [HAVE_DECL_LOG2L=0], [[#include <math.h>]])
28
29     save_LIBS="$LIBS"
30     LIBS="$LIBS $LOG2L_LIBM"
31     gl_FUNC_LOG2L_WORKS
32     LIBS="$save_LIBS"
33     case "$gl_cv_func_log2l_works" in
34       *yes) ;;
35       *) REPLACE_LOG2L=1 ;;
36     esac
37   else
38     HAVE_LOG2L=0
39     HAVE_DECL_LOG2L=0
40   fi
41   if test $HAVE_LOG2L = 0 || test $REPLACE_LOG2L = 1; then
42     dnl Find libraries needed to link lib/log2l.c.
43     if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
44       LOG2L_LIBM="$LOG2_LIBM"
45     else
46       AC_REQUIRE([gl_FUNC_ISNANL])
47       AC_REQUIRE([gl_FUNC_FREXPL])
48       AC_REQUIRE([gl_FUNC_LOGL])
49       LOG2L_LIBM=
50       dnl Append $ISNANL_LIBM to LOG2L_LIBM, avoiding gratuitous duplicates.
51       case " $LOG2L_LIBM " in
52         *" $ISNANL_LIBM "*) ;;
53         *) LOG2L_LIBM="$LOG2L_LIBM $ISNANL_LIBM" ;;
54       esac
55       dnl Append $FREXPL_LIBM to LOG2L_LIBM, avoiding gratuitous duplicates.
56       case " $LOG2L_LIBM " in
57         *" $FREXPL_LIBM "*) ;;
58         *) LOG2L_LIBM="$LOG2L_LIBM $FREXPL_LIBM" ;;
59       esac
60       dnl Append $LOGL_LIBM to LOG2L_LIBM, avoiding gratuitous duplicates.
61       case " $LOG2L_LIBM " in
62         *" $LOGL_LIBM "*) ;;
63         *) LOG2L_LIBM="$LOG2L_LIBM $LOGL_LIBM" ;;
64       esac
65     fi
66   fi
67   AC_SUBST([LOG2L_LIBM])
68 ])
69
70 dnl Test whether log2l() works.
71 dnl On OSF/1 5.1, log2l(-0.0) is NaN.
72 AC_DEFUN([gl_FUNC_LOG2L_WORKS],
73 [
74   AC_REQUIRE([AC_PROG_CC])
75   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
76   AC_CACHE_CHECK([whether log2l works], [gl_cv_func_log2l_works],
77     [
78       AC_RUN_IFELSE(
79         [AC_LANG_SOURCE([[
80 #include <math.h>
81 #ifndef log2l /* for AIX */
82 extern
83 #ifdef __cplusplus
84 "C"
85 #endif
86 long double log2l (long double);
87 #endif
88 volatile long double x;
89 volatile long double y;
90 int main ()
91 {
92   /* This test fails on OSF/1 5.1.  */
93   x = -0.0L;
94   y = log2l (x);
95   if (!(y + y == y))
96     return 1;
97   return 0;
98 }
99 ]])],
100         [gl_cv_func_log2l_works=yes],
101         [gl_cv_func_log2l_works=no],
102         [case "$host_os" in
103            osf*) gl_cv_func_log2l_works="guessing no";;
104            *)    gl_cv_func_log2l_works="guessing yes";;
105          esac
106         ])
107     ])
108 ])