Modernize AC_TRY_LINK invocations.
[gnulib.git] / m4 / floor.m4
1 # floor.m4 serial 4
2 dnl Copyright (C) 2007, 2009, 2010 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_FLOOR],
8 [
9   dnl Test whether floor() can be used without libm.
10   gl_FUNC_FLOOR_LIBS
11   if test "$FLOOR_LIBM" = "?"; then
12     FLOOR_LIBM=
13   fi
14   AC_SUBST([FLOOR_LIBM])
15 ])
16
17 # Determines the libraries needed to get the floor() function.
18 # Sets FLOOR_LIBM.
19 AC_DEFUN([gl_FUNC_FLOOR_LIBS],
20 [
21   gl_CACHE_VAL_SILENT([gl_cv_func_floor_libm], [
22     gl_cv_func_floor_libm=?
23     AC_LINK_IFELSE(
24       [AC_LANG_PROGRAM(
25          [[#ifndef __NO_MATH_INLINES
26            # define __NO_MATH_INLINES 1 /* for glibc */
27            #endif
28            #include <math.h>
29            double x;]],
30          [[x = floor(x);]])],
31       [gl_cv_func_floor_libm=])
32     if test "$gl_cv_func_floor_libm" = "?"; then
33       save_LIBS="$LIBS"
34       LIBS="$LIBS -lm"
35       AC_LINK_IFELSE(
36         [AC_LANG_PROGRAM(
37            [[#ifndef __NO_MATH_INLINES
38              # define __NO_MATH_INLINES 1 /* for glibc */
39              #endif
40              #include <math.h>
41              double x;]],
42            [[x = floor(x);]])],
43         [gl_cv_func_floor_libm="-lm"])
44       LIBS="$save_LIBS"
45     fi
46   ])
47   FLOOR_LIBM="$gl_cv_func_floor_libm"
48 ])