Code

915e566434f0aa22a84e18a99ae8b7b883d2365d
[nagiosplug.git] / gl / m4 / floorf.m4
1 # floorf.m4 serial 4
2 dnl Copyright (C) 2007, 2009 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_FLOORF],
8 [
9   AC_REQUIRE([gl_MATH_H_DEFAULTS])
10   dnl Persuade glibc <math.h> to declare floorf().
11   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
12   dnl Test whether floorf() is declared.
13   AC_CHECK_DECLS([floorf], , , [#include <math.h>])
14   if test "$ac_cv_have_decl_floorf" = yes; then
15     dnl Test whether floorf() can be used without libm.
16     gl_FUNC_FLOORF_LIBS
17     if test "$FLOORF_LIBM" = "?"; then
18       dnl Sun C 5.0 on Solaris declares floorf() and has it in the system-wide
19       dnl libm.so, but not in the libm.so that the compiler uses.
20       REPLACE_FLOORF=1
21     fi
22   else
23     REPLACE_FLOORF=1
24   fi
25   if test $REPLACE_FLOORF = 1; then
26     AC_LIBOBJ([floorf])
27     FLOORF_LIBM=
28   fi
29   AC_SUBST([REPLACE_FLOORF])
30   AC_SUBST([FLOORF_LIBM])
31 ])
33 # Determines the libraries needed to get the floorf() function.
34 # Sets FLOORF_LIBM.
35 AC_DEFUN([gl_FUNC_FLOORF_LIBS],
36 [
37   gl_CACHE_VAL_SILENT([gl_cv_func_floorf_libm], [
38     gl_cv_func_floorf_libm=?
39     AC_TRY_LINK([
40        #ifndef __NO_MATH_INLINES
41        # define __NO_MATH_INLINES 1 /* for glibc */
42        #endif
43        #include <math.h>
44        float x;],
45       [x = floorf(x);],
46       [gl_cv_func_floorf_libm=])
47     if test "$gl_cv_func_floorf_libm" = "?"; then
48       save_LIBS="$LIBS"
49       LIBS="$LIBS -lm"
50       AC_TRY_LINK([
51          #ifndef __NO_MATH_INLINES
52          # define __NO_MATH_INLINES 1 /* for glibc */
53          #endif
54          #include <math.h>
55          float x;],
56         [x = floorf(x);],
57         [gl_cv_func_floorf_libm="-lm"])
58       LIBS="$save_LIBS"
59     fi
60   ])
61   FLOORF_LIBM="$gl_cv_func_floorf_libm"
62 ])