b409829945f73ec00d0423a0d240506ce7540924
[pspp] / m4 / ceilf.m4
1 # ceilf.m4 serial 2
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
7 AC_DEFUN([gl_FUNC_CEILF],
8 [
9   AC_REQUIRE([gl_MATH_H_DEFAULTS])
10   dnl Persuade glibc <math.h> to declare ceilf().
11   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
12   dnl Test whether ceilf() is declared.
13   AC_CHECK_DECLS([ceilf], , , [#include <math.h>])
14   if test "$ac_cv_have_decl_ceilf" = yes; then
15     dnl Test whether ceilf() can be used without libm.
16     gl_FUNC_CEILF_LIBS
17     if test "$CEILF_LIBM" = "?"; then
18       CEILF_LIBM=
19     fi
20   else
21     HAVE_DECL_CEILF=0
22     AC_LIBOBJ([ceilf])
23     CEILF_LIBM=
24   fi
25   AC_SUBST([HAVE_DECL_CEILF])
26   AC_SUBST([CEILF_LIBM])
27 ])
28
29 # Determines the libraries needed to get the ceilf() function.
30 # Sets CEILF_LIBM.
31 AC_DEFUN([gl_FUNC_CEILF_LIBS],
32 [
33   AC_CACHE_VAL([gl_func_ceilf_libm], [
34     gl_func_ceilf_libm=?
35     AC_TRY_LINK([
36        #ifndef __NO_MATH_INLINES
37        # define __NO_MATH_INLINES 1 /* for glibc */
38        #endif
39        #include <math.h>
40        float x;],
41       [x = ceilf(x);],
42       [gl_func_ceilf_libm=])
43     if test "$gl_func_ceilf_libm" = "?"; then
44       save_LIBS="$LIBS"
45       LIBS="$LIBS -lm"
46       AC_TRY_LINK([
47          #ifndef __NO_MATH_INLINES
48          # define __NO_MATH_INLINES 1 /* for glibc */
49          #endif
50          #include <math.h>
51          float x;],
52         [x = ceilf(x);],
53         [gl_func_ceilf_libm="-lm"])
54       LIBS="$save_LIBS"
55     fi
56   ])
57   CEILF_LIBM="$gl_func_ceilf_libm"
58 ])