1 # remainder.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.
7 AC_DEFUN([gl_FUNC_REMAINDER],
9 AC_REQUIRE([gl_MATH_H_DEFAULTS])
11 dnl Test whether remainder() is declared. On IRIX 5.3 it is not declared.
12 AC_CHECK_DECL([remainder], , [HAVE_DECL_REMAINDER=0], [[#include <math.h>]])
15 AC_CACHE_CHECK([whether remainder() can be used without linking with libm],
16 [gl_cv_func_remainder_no_libm],
20 [[#ifndef __NO_MATH_INLINES
21 # define __NO_MATH_INLINES 1 /* for glibc */
26 [[return remainder (x, y) > 1;]])],
27 [gl_cv_func_remainder_no_libm=yes],
28 [gl_cv_func_remainder_no_libm=no])
30 if test $gl_cv_func_remainder_no_libm = no; then
31 AC_CACHE_CHECK([whether remainder() can be used with libm],
32 [gl_cv_func_remainder_in_libm],
38 [[#ifndef __NO_MATH_INLINES
39 # define __NO_MATH_INLINES 1 /* for glibc */
44 [[return remainder (x, y) > 1;]])],
45 [gl_cv_func_remainder_in_libm=yes],
46 [gl_cv_func_remainder_in_libm=no])
49 if test $gl_cv_func_remainder_in_libm = yes; then
53 if test $gl_cv_func_remainder_no_libm = no \
54 && test $gl_cv_func_remainder_in_libm = no; then
56 dnl Find libraries needed to link lib/remainder.c.
57 AC_REQUIRE([gl_FUNC_ROUND])
58 AC_REQUIRE([gl_FUNC_FMA])
60 dnl Append $ROUND_LIBM to REMAINDER_LIBM, avoiding gratuitous duplicates.
61 case " $REMAINDER_LIBM " in
63 *) REMAINDER_LIBM="$REMAINDER_LIBM $ROUND_LIBM" ;;
65 dnl Append $FMA_LIBM to REMAINDER_LIBM, avoiding gratuitous duplicates.
66 case " $REMAINDER_LIBM " in
68 *) REMAINDER_LIBM="$REMAINDER_LIBM $FMA_LIBM" ;;
71 AC_SUBST([REMAINDER_LIBM])