Fix bugs in round modules reported by Bruno Haible.
[gnulib.git] / m4 / check-math-lib.m4
1 # check-math-lib.m4 serial 1
2 dnl Copyright (C) 2007 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 dnl
7 dnl AC_CHECK_MATH_LIB (VARIABLE, EXPRESSION)
8 dnl
9 dnl Checks whether EXPRESSION requires -lm to compile and link.  If so, sets
10 dnl the shell VARIABLE to -lm, otherwise to the empty string.
11 dnl
12 dnl Example: AC_CHECK_MATH_LIB([ROUNDF_LIBM], [x = roundf (x);])
13 AC_DEFUN([gl_CHECK_MATH_LIB], [
14   save_LIBS=$LIBS
15   $1=?
16   for libm in "" "-lm"; do
17     LIBS="$save_LIBS $libm"
18     AC_TRY_LINK([
19        #ifndef __NO_MATH_INLINES
20        # define __NO_MATH_INLINES 1 /* for glibc */
21        #endif
22        #include <math.h>
23        double x;],
24       [$2],
25       [$1=$libm
26 break])
27   done
28   LIBS=$save_LIBS
29   if test "$$1" = "?"; then
30     $1=
31   fi
32 ])