check_solaris_c99.m4 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. # This should never arise, because the outer _ifelse
  29. # would jump to the action-if-cross-compiling rather
  30. # than executing its action-if-false. However, adding
  31. # this explicitly makes autoconf happier.
  32. [AC_MSG_RESULT([skipping due to cross-compiling])]
  33. )],
  34. [AC_MSG_RESULT([skipping due to cross-compiling])])
  35. ;;
  36. *)
  37. ;;
  38. esac
  39. ])# CHECK_SOLARIS_C99