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_ACOSL],
10 AC_REQUIRE([gl_MATH_H_DEFAULTS])
11 AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
13 dnl Persuade glibc <math.h> to declare acosl().
14 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
17 AC_CACHE_CHECK([whether acosl() can be used without linking with libm],
18 [gl_cv_func_acosl_no_libm],
22 [[#ifndef __NO_MATH_INLINES
23 # define __NO_MATH_INLINES 1 /* for glibc */
26 long double (* volatile funcptr) (long double) = acosl;
28 [[return funcptr (x) > 1
29 || acosl (x) > 1;]])],
30 [gl_cv_func_acosl_no_libm=yes],
31 [gl_cv_func_acosl_no_libm=no])
33 if test $gl_cv_func_acosl_no_libm = no; then
34 AC_CACHE_CHECK([whether acosl() can be used with libm],
35 [gl_cv_func_acosl_in_libm],
41 [[#ifndef __NO_MATH_INLINES
42 # define __NO_MATH_INLINES 1 /* for glibc */
45 long double (* volatile funcptr) (long double) = acosl;
47 [[return funcptr (x) > 1
48 || acosl (x) > 1;]])],
49 [gl_cv_func_acosl_in_libm=yes],
50 [gl_cv_func_acosl_in_libm=no])
53 if test $gl_cv_func_acosl_in_libm = yes; then
57 if test $gl_cv_func_acosl_no_libm = yes \
58 || test $gl_cv_func_acosl_in_libm = yes; then
59 dnl Also check whether it's declared.
60 dnl Mac OS X 10.3 has acosl() in libc but doesn't declare it in <math.h>.
61 AC_CHECK_DECL([acosl], , [HAVE_DECL_ACOSL=0], [[#include <math.h>]])
65 dnl Find libraries needed to link lib/acosl.c.
66 if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
67 AC_REQUIRE([gl_FUNC_ACOS])
68 ACOSL_LIBM="$ACOS_LIBM"
70 AC_REQUIRE([gl_FUNC_ASINL])
71 AC_REQUIRE([gl_FUNC_SQRTL])
72 dnl Append $ASINL_LIBM to ACOSL_LIBM, avoiding gratuitous duplicates.
73 case " $ACOSL_LIBM " in
75 *) ACOSL_LIBM="$ACOSL_LIBM $ASINL_LIBM" ;;
77 dnl Append $SQRTL_LIBM to ACOSL_LIBM, avoiding gratuitous duplicates.
78 case " $ACOSL_LIBM " in
80 *) ACOSL_LIBM="$ACOSL_LIBM $SQRTL_LIBM" ;;
84 AC_SUBST([ACOSL_LIBM])