ceil-ieee tests: More tests.
[gnulib.git] / m4 / fmodl.m4
1 # fmodl.m4 serial 1
2 dnl Copyright (C) 2011-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_FMODL],
8 [
9   AC_REQUIRE([gl_MATH_H_DEFAULTS])
10   AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
11   AC_REQUIRE([gl_FUNC_FMOD])
12
13   dnl Test whether fmodl() is declared.
14   dnl AIX 5.1 has fmodl() in libc but doesn't declare it in <math.h>, and the
15   dnl function produces NaN results for finite values.
16   AC_CHECK_DECL([fmodl],
17     [ac_cv_have_decl_fmodl=yes], [ac_cv_have_decl_fmodl=no],
18     [[#include <math.h>]])
19
20   dnl Test whether fmodl() exists. Assume that fmodl(), if it exists, is
21   dnl defined in the same library as fmod().
22   save_LIBS="$LIBS"
23   LIBS="$LIBS $FMOD_LIBM"
24   AC_CHECK_FUNCS([fmodl])
25   LIBS="$save_LIBS"
26   if test $ac_cv_func_fmodl = yes; then
27     if test $ac_cv_have_decl_fmodl = yes; then
28       FMODL_LIBM="$FMOD_LIBM"
29     else
30       REPLACE_FMODL=1
31     fi
32   else
33     HAVE_FMODL=0
34   fi
35   if test $HAVE_FMODL = 0 || test $REPLACE_FMODL = 1; then
36     if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
37       FMODL_LIBM="$FMOD_LIBM"
38     else
39       AC_REQUIRE([gl_FUNC_TRUNCL])
40       AC_REQUIRE([gl_FUNC_FMAL])
41       FMODL_LIBM=
42       dnl Append $TRUNCL_LIBM to FMODL_LIBM, avoiding gratuitous duplicates.
43       case " $FMODL_LIBM " in
44         *" $TRUNCL_LIBM "*) ;;
45         *) FMODL_LIBM="$FMODL_LIBM $TRUNCL_LIBM" ;;
46       esac
47       dnl Append $FMAL_LIBM to FMODL_LIBM, avoiding gratuitous duplicates.
48       case " $FMODL_LIBM " in
49         *" $FMAL_LIBM "*) ;;
50         *) FMODL_LIBM="$FMODL_LIBM $FMAL_LIBM" ;;
51       esac
52     fi
53   fi
54   AC_SUBST([FMODL_LIBM])
55 ])