ax_check_compiler_flags.m4 1.1 KB

1234567891011121314151617181920212223242526
  1. AC_DEFUN([AX_CHECK_COMPILER_FLAGS],
  2. [AC_PREREQ(2.59) dnl for _AC_LANG_PREFIX
  3. AC_MSG_CHECKING([whether _AC_LANG compiler accepts $1])
  4. dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
  5. AS_LITERAL_IF([$1],
  6. [AC_CACHE_VAL(AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1), [
  7. ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
  8. _AC_LANG_PREFIX[]FLAGS="$1"
  9. AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
  10. AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=yes,
  11. AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=no)
  12. _AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])],
  13. [ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
  14. _AC_LANG_PREFIX[]FLAGS="$1"
  15. AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
  16. eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=yes,
  17. eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=no)
  18. _AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])
  19. eval ax_check_compiler_flags=$AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)
  20. AC_MSG_RESULT($ax_check_compiler_flags)
  21. if test "x$ax_check_compiler_flags" = xyes; then
  22. m4_default([$2], :)
  23. else
  24. m4_default([$3], :)
  25. fi
  26. ])dnl AX_CHECK_COMPILER_FLAG