compiler_flag_chk.m4 1003 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. dnl From stackoverflow, with some changes
  2. dnl @synopsis CXX_FLAGS_CHECK [compiler flags]
  3. dnl @summary check whether compiler supports given C++ flags or not
  4. AC_DEFUN([CXX_FLAG_CHECK],
  5. [dnl
  6. AC_MSG_CHECKING([if $CXX supports $1])
  7. AC_LANG_PUSH([C++])
  8. ac_saved_cxxflags="$CXXFLAGS"
  9. CXXFLAGS="-Werror $1"
  10. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
  11. [cxx_flag_check=yes],
  12. [cxx_flag_check=no]
  13. )
  14. AC_MSG_RESULT([$cxx_flag_check])
  15. CXXFLAGS="$ac_saved_cxxflags"
  16. if test "$cxx_flag_check" = yes
  17. then
  18. CXX_COMPILER_FLAGS="$1 $CXX_COMPILER_FLAGS "
  19. fi
  20. AC_LANG_POP([C++])
  21. ])
  22. AC_DEFUN([C_FLAG_CHECK],
  23. [dnl
  24. AC_MSG_CHECKING([if $CC supports $1])
  25. AC_LANG_PUSH([C])
  26. ac_saved_ccflags="$CFLAGS"
  27. CFLAGS="-Werror $1"
  28. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
  29. [cc_flag_check=yes],
  30. [cc_flag_check=no]
  31. )
  32. AC_MSG_RESULT([$cc_flag_check])
  33. CFLAGS="$ac_saved_ccflags"
  34. if test "$cc_flag_check" = yes
  35. then
  36. C_COMPILER_FLAGS="$1 $C_COMPILER_FLAGS "
  37. fi
  38. AC_LANG_POP([C])
  39. ])