* ChangeLog: Fix misspelling
[gnulib.git] / m4 / tanl.m4
blobe1ac7924f8696abdd834e8c9b89378934123e06f
1 # tanl.m4
2 # serial 10
3 dnl Copyright (C) 2010-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 AC_DEFUN([gl_FUNC_TANL],
10   AC_REQUIRE([gl_MATH_H_DEFAULTS])
11   AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
13   dnl Persuade glibc <math.h> to declare tanl().
14   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
16   TANL_LIBM=
17   AC_CACHE_CHECK([whether tanl() can be used without linking with libm],
18     [gl_cv_func_tanl_no_libm],
19     [
20       AC_LINK_IFELSE(
21         [AC_LANG_PROGRAM(
22            [[#ifndef __NO_MATH_INLINES
23              # define __NO_MATH_INLINES 1 /* for glibc */
24              #endif
25              #include <math.h>
26              long double (* volatile funcptr) (long double) = tanl;
27              long double x;]],
28            [[return funcptr (x) > 0.4
29                     || tanl (x) > 0.4;]])],
30         [gl_cv_func_tanl_no_libm=yes],
31         [gl_cv_func_tanl_no_libm=no])
32     ])
33   if test $gl_cv_func_tanl_no_libm = no; then
34     AC_CACHE_CHECK([whether tanl() can be used with libm],
35       [gl_cv_func_tanl_in_libm],
36       [
37         saved_LIBS="$LIBS"
38         LIBS="$LIBS -lm"
39         AC_LINK_IFELSE(
40           [AC_LANG_PROGRAM(
41              [[#ifndef __NO_MATH_INLINES
42                # define __NO_MATH_INLINES 1 /* for glibc */
43                #endif
44                #include <math.h>
45                long double (* volatile funcptr) (long double) = tanl;
46                long double x;]],
47              [[return funcptr (x) > 0.4
48                       || tanl (x) > 0.4;]])],
49           [gl_cv_func_tanl_in_libm=yes],
50           [gl_cv_func_tanl_in_libm=no])
51         LIBS="$saved_LIBS"
52       ])
53     if test $gl_cv_func_tanl_in_libm = yes; then
54       TANL_LIBM=-lm
55     fi
56   fi
57   if test $gl_cv_func_tanl_no_libm = yes \
58      || test $gl_cv_func_tanl_in_libm = yes; then
59     dnl Also check whether it's declared.
60     dnl Mac OS X 10.3 has tanl() in libc but doesn't declare it in <math.h>.
61     AC_CHECK_DECL([tanl], , [HAVE_DECL_TANL=0], [[#include <math.h>]])
62   else
63     HAVE_DECL_TANL=0
64     HAVE_TANL=0
65     dnl Find libraries needed to link lib/tanl.c, lib/trigl.c.
66     if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
67       AC_REQUIRE([gl_FUNC_TAN])
68       TANL_LIBM="$TAN_LIBM"
69     else
70       AC_REQUIRE([gl_FUNC_ISNANL])
71       AC_REQUIRE([gl_FUNC_FLOOR])
72       AC_REQUIRE([gl_FUNC_FLOORL])
73       dnl Append $ISNANL_LIBM to TANL_LIBM, avoiding gratuitous duplicates.
74       case " $TANL_LIBM " in
75         *" $ISNANL_LIBM "*) ;;
76         *) TANL_LIBM="$TANL_LIBM $ISNANL_LIBM" ;;
77       esac
78       dnl Append $FLOOR_LIBM to TANL_LIBM, avoiding gratuitous duplicates.
79       case " $TANL_LIBM " in
80         *" $FLOOR_LIBM "*) ;;
81         *) TANL_LIBM="$TANL_LIBM $FLOOR_LIBM" ;;
82       esac
83       dnl Append $FLOORL_LIBM to TANL_LIBM, avoiding gratuitous duplicates.
84       case " $TANL_LIBM " in
85         *" $FLOORL_LIBM "*) ;;
86         *) TANL_LIBM="$TANL_LIBM $FLOORL_LIBM" ;;
87       esac
88     fi
89   fi
90   AC_SUBST([TANL_LIBM])