maint: don't specify XZ_OPT=-9ev in dist-related rule
[gnulib.git] / m4 / remainderl.m4
1 # remainderl.m4 serial 2
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_REMAINDERL],
8 [
9   m4_divert_text([DEFAULTS], [gl_remainderl_required=plain])
10   AC_REQUIRE([gl_MATH_H_DEFAULTS])
11   AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
12   AC_REQUIRE([gl_FUNC_REMAINDER])
13
14   dnl Test whether remainderl() exists. Assume that remainderl(), if it exists, is
15   dnl defined in the same library as remainder().
16   save_LIBS="$LIBS"
17   LIBS="$LIBS $REMAINDER_LIBM"
18   AC_CACHE_CHECK([for remainderl],
19     [gl_cv_func_remainderl],
20     [
21       AC_LINK_IFELSE(
22         [AC_LANG_PROGRAM(
23            [[#ifndef __NO_MATH_INLINES
24              # define __NO_MATH_INLINES 1 /* for glibc */
25              #endif
26              #include <math.h>
27              long double (*funcptr) (long double, long double) = remainderl;
28              long double x;
29              long double y;]],
30            [[return funcptr (x, y) > 1
31                     || remainderl (x, y) > 1;]])],
32         [gl_cv_func_remainderl=yes],
33         [gl_cv_func_remainderl=no])
34     ])
35   LIBS="$save_LIBS"
36   if test $gl_cv_func_remainderl = yes; then
37     REMAINDERL_LIBM="$REMAINDER_LIBM"
38     m4_ifdef([gl_FUNC_REMAINDERL_IEEE], [
39       if test $gl_remainderl_required = ieee && test $REPLACE_REMAINDERL = 0; then
40         AC_CACHE_CHECK([whether remainderl works according to ISO C 99 with IEC 60559],
41           [gl_cv_func_remainderl_ieee],
42           [
43             save_LIBS="$LIBS"
44             LIBS="$LIBS $REMAINDERL_LIBM"
45             AC_RUN_IFELSE(
46               [AC_LANG_SOURCE([[
47 #ifndef __NO_MATH_INLINES
48 # define __NO_MATH_INLINES 1 /* for glibc */
49 #endif
50 #include <math.h>
51 /* Compare two numbers with ==.
52    This is a separate function because IRIX 6.5 "cc -O" miscompiles an
53    'x == x' test.  */
54 static int
55 numeric_equal (long double x, long double y)
56 {
57   return x == y;
58 }
59 static long double dummy (long double x, long double y) { return 0; }
60 int main (int argc, char *argv[])
61 {
62   long double (*my_remainderl) (long double, long double) = argc ? remainderl : dummy;
63   long double f;
64   /* Test remainderl(...,0.0L).
65      This test fails on OSF/1 5.1.  */
66   f = my_remainderl (2.0L, 0.0L);
67   if (numeric_equal (f, f))
68     return 1;
69   return 0;
70 }
71               ]])],
72               [gl_cv_func_remainderl_ieee=yes],
73               [gl_cv_func_remainderl_ieee=no],
74               [gl_cv_func_remainderl_ieee="guessing no"])
75             LIBS="$save_LIBS"
76           ])
77         case "$gl_cv_func_remainderl_ieee" in
78           *yes) ;;
79           *) REPLACE_REMAINDERL=1 ;;
80         esac
81       fi
82     ])
83   else
84     HAVE_REMAINDERL=0
85   fi
86   if test $HAVE_REMAINDERL = 0 || test $REPLACE_REMAINDERL = 1; then
87     dnl Find libraries needed to link lib/remainderl.c.
88     if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
89       REMAINDERL_LIBM="$REMAINDER_LIBM"
90     else
91       AC_REQUIRE([gl_FUNC_ROUNDL])
92       AC_REQUIRE([gl_FUNC_FMAL])
93       REMAINDERL_LIBM=
94       dnl Append $ROUNDL_LIBM to REMAINDERL_LIBM, avoiding gratuitous duplicates.
95       case " $REMAINDERL_LIBM " in
96         *" $ROUNDL_LIBM "*) ;;
97         *) REMAINDERL_LIBM="$REMAINDERL_LIBM $ROUNDL_LIBM" ;;
98       esac
99       dnl Append $FMAL_LIBM to REMAINDERL_LIBM, avoiding gratuitous duplicates.
100       case " $REMAINDERL_LIBM " in
101         *" $FMAL_LIBM "*) ;;
102         *) REMAINDERL_LIBM="$REMAINDERL_LIBM $FMAL_LIBM" ;;
103       esac
104     fi
105   fi
106   AC_SUBST([REMAINDERL_LIBM])
107 ])