New module 'cbrtl'.
[gnulib.git] / m4 / cbrtl.m4
1 # cbrtl.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_CBRTL],
8 [
9   AC_REQUIRE([gl_MATH_H_DEFAULTS])
10   AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
11   AC_REQUIRE([gl_FUNC_CBRT])
12
13   dnl Test whether cbrtl() exists. Assume that cbrtl(), if it exists, is
14   dnl defined in the same library as cbrt().
15   save_LIBS="$LIBS"
16   LIBS="$LIBS $CBRT_LIBM"
17   AC_CHECK_FUNCS([cbrtl])
18   LIBS="$save_LIBS"
19   if test $ac_cv_func_cbrtl = yes; then
20     CBRTL_LIBM="$CBRT_LIBM"
21     dnl Also check whether it's declared.
22     dnl IRIX 6.5 has cbrtl() in libm but doesn't declare it in <math.h>.
23     AC_CHECK_DECL([cbrtl], , [HAVE_DECL_CBRTL=0], [[#include <math.h>]])
24   else
25     HAVE_CBRTL=0
26     HAVE_DECL_CBRTL=0
27     dnl Find libraries needed to link lib/cbrtl.c.
28     if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
29       CBRTL_LIBM="$CBRT_LIBM"
30     else
31       AC_REQUIRE([gl_FUNC_FREXPL])
32       AC_REQUIRE([gl_FUNC_LDEXPL])
33       CBRTL_LIBM=
34       dnl Append $FREXPL_LIBM to CBRTL_LIBM, avoiding gratuitous duplicates.
35       case " $CBRTL_LIBM " in
36         *" $FREXPL_LIBM "*) ;;
37         *) CBRTL_LIBM="$CBRTL_LIBM $FREXPL_LIBM" ;;
38       esac
39       dnl Append $LDEXPL_LIBM to CBRTL_LIBM, avoiding gratuitous duplicates.
40       case " $CBRTL_LIBM " in
41         *" $LDEXPL_LIBM "*) ;;
42         *) CBRTL_LIBM="$CBRTL_LIBM $LDEXPL_LIBM" ;;
43       esac
44     fi
45   fi
46   AC_SUBST([CBRTL_LIBM])
47 ])