check-math-lib.m4 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. # check-math-lib.m4 serial 3
  2. dnl Copyright (C) 2007, 2009-2012 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. dnl
  7. dnl gl_CHECK_MATH_LIB (VARIABLE, EXPRESSION)
  8. dnl
  9. dnl Sets the shell VARIABLE according to the libraries needed by EXPRESSION
  10. dnl to compile and link: to the empty string if no extra libraries are needed,
  11. dnl to "-lm" if -lm is needed, or to "missing" if it does not compile and
  12. dnl link either way.
  13. dnl
  14. dnl Example: gl_CHECK_MATH_LIB([ROUNDF_LIBM], [x = roundf (x);])
  15. AC_DEFUN([gl_CHECK_MATH_LIB], [
  16. save_LIBS=$LIBS
  17. $1=missing
  18. for libm in "" "-lm"; do
  19. LIBS="$save_LIBS $libm"
  20. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  21. #ifndef __NO_MATH_INLINES
  22. # define __NO_MATH_INLINES 1 /* for glibc */
  23. #endif
  24. #include <math.h>
  25. double x;]],
  26. [$2])],
  27. [$1=$libm
  28. break])
  29. done
  30. LIBS=$save_LIBS
  31. ])