floorf.m4 1.8 KB

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