mc-cflags.m4 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. dnl @synopsis MC_CHECK_CFLAGS
  2. dnl
  3. dnl Check flags supported by C compiler
  4. dnl
  5. dnl @author Slava Zanko <slavazanko@gmail.com>
  6. dnl @version 2013-01-16
  7. dnl @license GPL
  8. dnl @copyright Free Software Foundation, Inc.
  9. AC_DEFUN([MC_CHECK_ONE_CFLAG],[
  10. AC_MSG_CHECKING([whether ${CC} accepts $1])
  11. safe_CFLAGS=$CFLAGS
  12. CFLAGS="$1"
  13. AC_COMPILE_IFELSE(
  14. [AC_LANG_PROGRAM([], [[return 0;]])],
  15. [mc_check_one_cflag=yes],
  16. [mc_check_one_cflag=no])
  17. CFLAGS=$safe_CFLAGS
  18. AC_MSG_RESULT([$mc_check_one_cflag])
  19. if test x$mc_check_one_cflag = xyes; then
  20. mc_configured_cflags="$mc_configured_cflags $1"
  21. fi
  22. ])
  23. AC_DEFUN([MC_CHECK_CFLAGS],[
  24. AC_LANG_PUSH(C)
  25. mc_configured_cflags=""
  26. dnl Sorted -f options:
  27. dnl AC_MSG_CHECKING([CC is $CC])
  28. case "$CC" in
  29. gcc*)
  30. MC_CHECK_ONE_CFLAG([-fdiagnostics-show-option])
  31. dnl MC_CHECK_ONE_CFLAG([-fno-stack-protector])
  32. ;;
  33. *)
  34. ;;
  35. esac
  36. dnl Sorted -W options:
  37. dnl MC_CHECK_ONE_CFLAG([-Wbad-function-cast])
  38. MC_CHECK_ONE_CFLAG([-Wcomment])
  39. MC_CHECK_ONE_CFLAG([-Wdeclaration-after-statement])
  40. MC_CHECK_ONE_CFLAG([-Wfloat-equal])
  41. MC_CHECK_ONE_CFLAG([-Wformat])
  42. MC_CHECK_ONE_CFLAG([-Wformat-security])
  43. MC_CHECK_ONE_CFLAG([-Wimplicit])
  44. MC_CHECK_ONE_CFLAG([-Wignored-qualifiers])
  45. MC_CHECK_ONE_CFLAG([-Wmissing-braces])
  46. MC_CHECK_ONE_CFLAG([-Wmissing-declarations])
  47. MC_CHECK_ONE_CFLAG([-Wmissing-parameter-type])
  48. MC_CHECK_ONE_CFLAG([-Wmissing-prototypes])
  49. MC_CHECK_ONE_CFLAG([-Wnested-externs])
  50. MC_CHECK_ONE_CFLAG([-Wno-long-long])
  51. MC_CHECK_ONE_CFLAG([-Wno-unreachable-code])
  52. MC_CHECK_ONE_CFLAG([-Wparentheses])
  53. MC_CHECK_ONE_CFLAG([-Wpointer-sign])
  54. MC_CHECK_ONE_CFLAG([-Wreturn-type])
  55. MC_CHECK_ONE_CFLAG([-Wsequence-point])
  56. MC_CHECK_ONE_CFLAG([-Wshadow])
  57. MC_CHECK_ONE_CFLAG([-Wsign-compare])
  58. dnl MC_CHECK_ONE_CFLAG([-Wstrict-aliasing])
  59. MC_CHECK_ONE_CFLAG([-Wswitch])
  60. MC_CHECK_ONE_CFLAG([-Wtype-limits])
  61. MC_CHECK_ONE_CFLAG([-Wuninitialized])
  62. MC_CHECK_ONE_CFLAG([-Wunused-but-set-variable])
  63. MC_CHECK_ONE_CFLAG([-Wunused-function])
  64. MC_CHECK_ONE_CFLAG([-Wunused-label])
  65. MC_CHECK_ONE_CFLAG([-Wunused-parameter])
  66. MC_CHECK_ONE_CFLAG([-Wunused-result])
  67. MC_CHECK_ONE_CFLAG([-Wunused-value])
  68. MC_CHECK_ONE_CFLAG([-Wunused-variable])
  69. MC_CHECK_ONE_CFLAG([-Wwrite-strings])
  70. AC_LANG_POP()
  71. ])