New module 'exp2l'.
[gnulib.git] / m4 / exp2l.m4
1 # exp2l.m4 serial 1
2 dnl Copyright (C) 2010-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_EXP2L],
8 [
9   AC_REQUIRE([gl_MATH_H_DEFAULTS])
10   AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
11   AC_REQUIRE([gl_FUNC_EXP2])
12
13   dnl Persuade glibc <math.h> to declare exp2l().
14   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
15
16   dnl Test whether exp2l() exists. Assume that exp2l(), if it exists, is
17   dnl defined in the same library as exp2().
18   save_LIBS="$LIBS"
19   LIBS="$LIBS $EXP2_LIBM"
20   AC_CHECK_FUNCS([exp2l])
21   LIBS="$save_LIBS"
22   if test $ac_cv_func_exp2l = yes; then
23     HAVE_EXP2L=1
24     EXP2L_LIBM="$EXP2_LIBM"
25     dnl Also check whether it's declared.
26     dnl IRIX 6.5 has exp2l() in libm but doesn't declare it in <math.h>.
27     AC_CHECK_DECL([exp2l], , [HAVE_DECL_EXP2L=0], [[#include <math.h>]])
28   else
29     HAVE_EXP2L=0
30     HAVE_DECL_EXP2L=0
31     dnl Find libraries needed to link lib/exp2l.c.
32     if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
33       EXP2L_LIBM="$EXP2_LIBM"
34     else
35       AC_REQUIRE([gl_FUNC_ISNANL])
36       AC_REQUIRE([gl_FUNC_ROUNDL])
37       AC_REQUIRE([gl_FUNC_LDEXPL])
38       EXP2L_LIBM=
39       dnl Append $ISNANL_LIBM to EXP2L_LIBM, avoiding gratuitous duplicates.
40       case " $EXP2L_LIBM " in
41         *" $ISNANL_LIBM "*) ;;
42         *) EXP2L_LIBM="$EXP2L_LIBM $ISNANL_LIBM" ;;
43       esac
44       dnl Append $ROUNDL_LIBM to EXP2L_LIBM, avoiding gratuitous duplicates.
45       case " $EXP2L_LIBM " in
46         *" $ROUNDL_LIBM "*) ;;
47         *) EXP2L_LIBM="$EXP2L_LIBM $ROUNDL_LIBM" ;;
48       esac
49       dnl Append $LDEXPL_LIBM to EXP2L_LIBM, avoiding gratuitous duplicates.
50       case " $EXP2L_LIBM " in
51         *" $LDEXPL_LIBM "*) ;;
52         *) EXP2L_LIBM="$EXP2L_LIBM $LDEXPL_LIBM" ;;
53       esac
54     fi
55   fi
56   AC_SUBST([EXP2L_LIBM])
57 ])