maint: update copyright
[gnulib.git] / m4 / expm1l.m4
1 # expm1l.m4 serial 2
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_EXPM1L],
8 [
9   AC_REQUIRE([gl_MATH_H_DEFAULTS])
10   AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
11
12   dnl Persuade glibc <math.h> to declare expm1l().
13   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
14
15   EXPM1L_LIBM=
16   AC_CACHE_CHECK([whether expm1l() can be used without linking with libm],
17     [gl_cv_func_expm1l_no_libm],
18     [
19       AC_LINK_IFELSE(
20         [AC_LANG_PROGRAM(
21            [[#ifndef __NO_MATH_INLINES
22              # define __NO_MATH_INLINES 1 /* for glibc */
23              #endif
24              #include <math.h>
25              extern
26              #ifdef __cplusplus
27              "C"
28              #endif
29              long double expm1l (long double);
30              long double (*funcptr) (long double) = expm1l;
31              long double x;]],
32            [[return funcptr (x) > 0.5
33                     || expm1l (x) > 0.5;]])],
34         [gl_cv_func_expm1l_no_libm=yes],
35         [gl_cv_func_expm1l_no_libm=no])
36     ])
37   if test $gl_cv_func_expm1l_no_libm = no; then
38     AC_CACHE_CHECK([whether expm1l() can be used with libm],
39       [gl_cv_func_expm1l_in_libm],
40       [
41         save_LIBS="$LIBS"
42         LIBS="$LIBS -lm"
43         AC_LINK_IFELSE(
44           [AC_LANG_PROGRAM(
45              [[#ifndef __NO_MATH_INLINES
46                # define __NO_MATH_INLINES 1 /* for glibc */
47                #endif
48                #include <math.h>
49                extern
50                #ifdef __cplusplus
51                "C"
52                #endif
53                long double expm1l (long double);
54                long double (*funcptr) (long double) = expm1l;
55                long double x;]],
56              [[return funcptr (x) > 0.5
57                       || expm1l (x) > 0.5;]])],
58           [gl_cv_func_expm1l_in_libm=yes],
59           [gl_cv_func_expm1l_in_libm=no])
60         LIBS="$save_LIBS"
61       ])
62     if test $gl_cv_func_expm1l_in_libm = yes; then
63       EXPM1L_LIBM=-lm
64     fi
65   fi
66   if test $gl_cv_func_expm1l_no_libm = yes \
67      || test $gl_cv_func_expm1l_in_libm = yes; then
68     HAVE_EXPM1L=1
69     dnl Also check whether it's declared.
70     dnl IRIX 6.5 has expm1l() in libm but doesn't declare it in <math.h>.
71     AC_CHECK_DECL([expm1l], , [HAVE_DECL_EXPM1L=0], [[#include <math.h>]])
72   else
73     HAVE_EXPM1L=0
74     HAVE_DECL_EXPM1L=0
75     dnl Find libraries needed to link lib/expm1l.c.
76     if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
77       AC_REQUIRE([gl_FUNC_EXPM1])
78       EXPM1L_LIBM="$EXPM1_LIBM"
79     else
80       AC_REQUIRE([gl_FUNC_ISNANL])
81       AC_REQUIRE([gl_FUNC_EXPL])
82       AC_REQUIRE([gl_FUNC_ROUNDL])
83       AC_REQUIRE([gl_FUNC_LDEXPL])
84       EXPM1L_LIBM=
85       dnl Append $ISNANL_LIBM to EXPM1L_LIBM, avoiding gratuitous duplicates.
86       case " $EXPM1L_LIBM " in
87         *" $ISNANL_LIBM "*) ;;
88         *) EXPM1L_LIBM="$EXPM1L_LIBM $ISNANL_LIBM" ;;
89       esac
90       dnl Append $EXPL_LIBM to EXPM1L_LIBM, avoiding gratuitous duplicates.
91       case " $EXPM1L_LIBM " in
92         *" $EXPL_LIBM "*) ;;
93         *) EXPM1L_LIBM="$EXPM1L_LIBM $EXPL_LIBM" ;;
94       esac
95       dnl Append $ROUNDL_LIBM to EXPM1L_LIBM, avoiding gratuitous duplicates.
96       case " $EXPM1L_LIBM " in
97         *" $ROUNDL_LIBM "*) ;;
98         *) EXPM1L_LIBM="$EXPM1L_LIBM $ROUNDL_LIBM" ;;
99       esac
100       dnl Append $LDEXPL_LIBM to EXPM1L_LIBM, avoiding gratuitous duplicates.
101       case " $EXPM1L_LIBM " in
102         *" $LDEXPL_LIBM "*) ;;
103         *) EXPM1L_LIBM="$EXPM1L_LIBM $LDEXPL_LIBM" ;;
104       esac
105     fi
106   fi
107   AC_SUBST([EXPM1L_LIBM])
108 ])