New module 'log1pf'.
[gnulib.git] / m4 / log1pf.m4
1 # log1pf.m4 serial 1
2 dnl Copyright (C) 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_LOG1PF],
8 [
9   AC_REQUIRE([gl_MATH_H_DEFAULTS])
10   AC_REQUIRE([gl_FUNC_LOG1P])
11
12   dnl Persuade glibc <math.h> to declare log1pf().
13   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
14
15   dnl Test whether log1pf() exists. Assume that log1pf(), if it exists, is
16   dnl defined in the same library as log1p().
17   save_LIBS="$LIBS"
18   LIBS="$LIBS $LOG1P_LIBM"
19   AC_CHECK_FUNCS([log1pf])
20   LIBS="$save_LIBS"
21   if test $ac_cv_func_log1pf = yes; then
22     LOG1PF_LIBM="$LOG1P_LIBM"
23
24     save_LIBS="$LIBS"
25     LIBS="$LIBS $LOG1PF_LIBM"
26     gl_FUNC_LOG1PF_WORKS
27     LIBS="$save_LIBS"
28     case "$gl_cv_func_log1pf_works" in
29       *yes) ;;
30       *) REPLACE_LOG1PF=1 ;;
31     esac
32   else
33     HAVE_LOG1PF=0
34   fi
35   if test $HAVE_LOG1PF = 0 || test $REPLACE_LOG1PF = 1; then
36     dnl Find libraries needed to link lib/log1pf.c.
37     LOG1PF_LIBM="$LOG1P_LIBM"
38   fi
39   AC_SUBST([LOG1PF_LIBM])
40 ])
41
42 dnl Test whether log1pf() works.
43 dnl On IRIX 6.5, log1pf(-1.0f) returns +Infinity instead of -Infinity.
44 AC_DEFUN([gl_FUNC_LOG1PF_WORKS],
45 [
46   AC_REQUIRE([AC_PROG_CC])
47   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
48   AC_CACHE_CHECK([whether log1pf works], [gl_cv_func_log1pf_works],
49     [
50       AC_RUN_IFELSE(
51         [AC_LANG_SOURCE([[
52 #include <math.h>
53 volatile float x;
54 float y;
55 int main ()
56 {
57   x = -1.0f;
58   y = log1pf (x);
59   if (!(y + y == y && y < 0.0f))
60     return 1;
61   return 0;
62 }
63 ]])],
64         [gl_cv_func_log1pf_works=yes],
65         [gl_cv_func_log1pf_works=no],
66         [case "$host_os" in
67            irix*) gl_cv_func_log1pf_works="guessing no";;
68            *)     gl_cv_func_log1pf_works="guessing yes";;
69          esac
70         ])
71     ])
72 ])