math.m4 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. dnl GCC_CHECK_LIBM
  2. dnl
  3. dnl Check whether -lm is available. This is a pre-requisite for
  4. dnl GCC_CHECK_MATH_FUNC so that it will link with -lm.
  5. AC_DEFUN([GCC_CHECK_LIBM],
  6. [AC_CHECK_LIB([m],[sin])])
  7. dnl GCC_CHECK_MATH_HEADERS
  8. dnl
  9. dnl Check for math.h and complex.h. This is a pre-requisite for
  10. dnl GCC_CHECK_MATH_FUNC so that it includes the right headers.
  11. dnl (Some systems, such as AIX or OpenVMS may define macro for math
  12. dnl functions).
  13. AC_DEFUN([GCC_CHECK_MATH_HEADERS],
  14. [AC_CHECK_HEADERS_ONCE(math.h complex.h)])
  15. dnl GCC_CHECK_MATH_FUNC([name])
  16. dnl
  17. dnl Check whether math function NAME is available on the system (by compiling
  18. dnl and linking a C program) and run define HAVE_name on success.
  19. dnl
  20. dnl Note that OpenVMS system insists on including complex.h before math.h
  21. AC_DEFUN([GCC_CHECK_MATH_FUNC],
  22. [
  23. AC_REQUIRE([GCC_CHECK_LIBM])
  24. AC_REQUIRE([GCC_CHECK_MATH_HEADERS])
  25. AC_CACHE_CHECK([for $1], [gcc_cv_math_func_$1],
  26. [AC_LINK_IFELSE([
  27. #ifdef HAVE_COMPLEX_H
  28. #include <complex.h>
  29. #endif
  30. #ifdef HAVE_MATH_H
  31. #include <math.h>
  32. #endif
  33. int (*ptr)() = (int (*)())$1;
  34. int
  35. main ()
  36. {
  37. return 0;
  38. }
  39. ],
  40. [gcc_cv_math_func_$1=yes],
  41. [gcc_cv_math_func_$1=no])])
  42. if test $gcc_cv_math_func_$1 = yes; then
  43. AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$1),[1],
  44. [Define to 1 if you have the `$1' function.])
  45. fi
  46. ])