check_solaris_c99.m4 962 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # CHECK_SOLARIS_C99
  2. # ----------------
  3. # On Solaris, the default standard library is c89-compatible. Some linkers
  4. # require -std=c99 to link to the c99-compatible library.
  5. AC_DEFUN([CHECK_SOLARIS_C99],
  6. [AC_REQUIRE([AC_CANONICAL_TARGET])
  7. case $target_os in
  8. *solaris* | *sunos*)
  9. AC_MSG_CHECKING([Solaris c99 standard library])
  10. AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
  11. int main(void) {
  12. char * eptr;
  13. strtod("0x1", &eptr);
  14. return (eptr[0] != '\0');
  15. }]])],
  16. [AC_MSG_RESULT([yes])],
  17. [# If we failed, try adding -std=c99 to the LDFLAGS.
  18. LDFLAGS="${LDFLAGS} -std=c99"
  19. AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
  20. int main(void) {
  21. char * eptr;
  22. strtod("0x1", &eptr);
  23. return (eptr[0] != '\0');
  24. }]])],
  25. [AC_MSG_RESULT([yes, if linked with -std=c99])],
  26. [AC_MSG_RESULT([no])
  27. AC_MSG_ERROR([c99 required])],
  28. )],
  29. [AC_MSG_RESULT([skipping due to cross-compiling])])
  30. ;;
  31. *)
  32. ;;
  33. esac
  34. ])# CHECK_SOLARIS_C99