2 dnl Copyright (C) 2012-2018 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.
7 AC_DEFUN([gl_FUNC_CBRTF],
9 AC_REQUIRE([gl_MATH_H_DEFAULTS])
10 AC_REQUIRE([gl_FUNC_CBRT])
12 dnl Persuade glibc <math.h> to declare cbrtf().
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
15 dnl Test whether cbrtf() exists. Assume that cbrtf(), if it exists, is
16 dnl defined in the same library as cbrt().
18 LIBS="$LIBS $CBRT_LIBM"
19 AC_CHECK_FUNCS([cbrtf])
21 if test $ac_cv_func_cbrtf = yes; then
22 CBRTF_LIBM="$CBRT_LIBM"
23 dnl Also check whether it's declared.
24 dnl IRIX 6.5 has cbrtf() in libm but doesn't declare it in <math.h>.
25 AC_CHECK_DECL([cbrtf], , [HAVE_DECL_CBRTF=0], [[#include <math.h>]])
27 LIBS="$LIBS $CBRTF_LIBM"
30 case "$gl_cv_func_cbrtf_works" in
38 if test $HAVE_CBRTF = 0 || test $REPLACE_CBRTF = 1; then
39 dnl Find libraries needed to link lib/cbrtf.c.
40 AC_REQUIRE([gl_FUNC_FABSF])
41 AC_REQUIRE([gl_FUNC_FREXPF])
42 AC_REQUIRE([gl_FUNC_LDEXPF])
44 dnl Append $FABSF_LIBM to CBRTF_LIBM, avoiding gratuitous duplicates.
45 case " $CBRTF_LIBM " in
47 *) CBRTF_LIBM="$CBRTF_LIBM $FABSF_LIBM" ;;
49 dnl Append $FREXPF_LIBM to CBRTF_LIBM, avoiding gratuitous duplicates.
50 case " $CBRTF_LIBM " in
51 *" $FREXPF_LIBM "*) ;;
52 *) CBRTF_LIBM="$CBRTF_LIBM $FREXPF_LIBM" ;;
54 dnl Append $LDEXPF_LIBM to CBRTF_LIBM, avoiding gratuitous duplicates.
55 case " $CBRTF_LIBM " in
56 *" $LDEXPF_LIBM "*) ;;
57 *) CBRTF_LIBM="$CBRTF_LIBM $LDEXPF_LIBM" ;;
60 AC_SUBST([CBRTF_LIBM])
63 dnl Test whether cbrtf() works.
64 dnl It returns wrong values on IRIX 6.5.
65 AC_DEFUN([gl_FUNC_CBRTF_WORKS],
67 AC_REQUIRE([AC_PROG_CC])
68 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
69 AC_CACHE_CHECK([whether cbrtf works], [gl_cv_func_cbrtf_works],
83 /* This test fails on IRIX 6.5. */
91 [gl_cv_func_cbrtf_works=yes],
92 [gl_cv_func_cbrtf_works=no],
94 irix*) gl_cv_func_cbrtf_works="guessing no";;
95 # Guess yes on native Windows.
96 mingw*) gl_cv_func_cbrtf_works="guessing yes";;
97 *) gl_cv_func_cbrtf_works="guessing yes";;