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