floorf.m4 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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.
  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. REPLACE_FLOORF=1
  23. fi
  24. if test $REPLACE_FLOORF = 1; then
  25. AC_LIBOBJ([floorf])
  26. FLOORF_LIBM=
  27. fi
  28. AC_SUBST([REPLACE_FLOORF])
  29. AC_SUBST([FLOORF_LIBM])
  30. ])
  31. # Determines the libraries needed to get the floorf() function.
  32. # Sets FLOORF_LIBM.
  33. AC_DEFUN([gl_FUNC_FLOORF_LIBS],
  34. [
  35. gl_CACHE_VAL_SILENT([gl_cv_func_floorf_libm], [
  36. gl_cv_func_floorf_libm=?
  37. AC_TRY_LINK([
  38. #ifndef __NO_MATH_INLINES
  39. # define __NO_MATH_INLINES 1 /* for glibc */
  40. #endif
  41. #include <math.h>
  42. float x;],
  43. [x = floorf(x);],
  44. [gl_cv_func_floorf_libm=])
  45. if test "$gl_cv_func_floorf_libm" = "?"; then
  46. save_LIBS="$LIBS"
  47. LIBS="$LIBS -lm"
  48. AC_TRY_LINK([
  49. #ifndef __NO_MATH_INLINES
  50. # define __NO_MATH_INLINES 1 /* for glibc */
  51. #endif
  52. #include <math.h>
  53. float x;],
  54. [x = floorf(x);],
  55. [gl_cv_func_floorf_libm="-lm"])
  56. LIBS="$save_LIBS"
  57. fi
  58. ])
  59. FLOORF_LIBM="$gl_cv_func_floorf_libm"
  60. ])