mc-cflags.m4 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. case "$CC" in
  13. clang*)
  14. CFLAGS="-Werror $1"
  15. ;;
  16. *)
  17. CFLAGS="$1"
  18. ;;
  19. esac
  20. AC_COMPILE_IFELSE(
  21. [AC_LANG_PROGRAM([], [[return 0;]])],
  22. [mc_check_one_cflag=yes],
  23. [mc_check_one_cflag=no])
  24. CFLAGS=$safe_CFLAGS
  25. AC_MSG_RESULT([$mc_check_one_cflag])
  26. if test x$mc_check_one_cflag = xyes; then
  27. mc_configured_cflags="$mc_configured_cflags $1"
  28. fi
  29. ])
  30. AC_DEFUN([mc_CHECK_CFLAGS],[
  31. AC_LANG_PUSH(C)
  32. mc_configured_cflags=""
  33. dnl Sorted -f options:
  34. dnl AC_MSG_CHECKING([CC is $CC])
  35. case "$CC" in
  36. gcc*)
  37. mc_CHECK_ONE_CFLAG([-fdiagnostics-show-option])
  38. dnl mc_CHECK_ONE_CFLAG([-fno-stack-protector])
  39. ;;
  40. *)
  41. ;;
  42. esac
  43. dnl Sorted -W options:
  44. mc_CHECK_ONE_CFLAG([-Wassign-enum])
  45. mc_CHECK_ONE_CFLAG([-Wbad-function-cast])
  46. mc_CHECK_ONE_CFLAG([-Wcomment])
  47. mc_CHECK_ONE_CFLAG([-Wconditional-uninitialized])
  48. mc_CHECK_ONE_CFLAG([-Wdeclaration-after-statement])
  49. mc_CHECK_ONE_CFLAG([-Wfloat-conversion])
  50. mc_CHECK_ONE_CFLAG([-Wfloat-equal])
  51. mc_CHECK_ONE_CFLAG([-Wformat])
  52. mc_CHECK_ONE_CFLAG([-Wformat-security])
  53. mc_CHECK_ONE_CFLAG([-Wformat-signedness])
  54. mc_CHECK_ONE_CFLAG([-Wimplicit])
  55. mc_CHECK_ONE_CFLAG([-Wimplicit-fallthrough])
  56. mc_CHECK_ONE_CFLAG([-Wignored-qualifiers])
  57. mc_CHECK_ONE_CFLAG([-Wlogical-not-parentheses])
  58. mc_CHECK_ONE_CFLAG([-Wmaybe-uninitialized])
  59. mc_CHECK_ONE_CFLAG([-Wmissing-braces])
  60. mc_CHECK_ONE_CFLAG([-Wmissing-declarations])
  61. mc_CHECK_ONE_CFLAG([-Wmissing-field-initializers])
  62. mc_CHECK_ONE_CFLAG([-Wmissing-format-attribute])
  63. mc_CHECK_ONE_CFLAG([-Wmissing-parameter-type])
  64. mc_CHECK_ONE_CFLAG([-Wmissing-prototypes])
  65. mc_CHECK_ONE_CFLAG([-Wmissing-variable-declarations])
  66. mc_CHECK_ONE_CFLAG([-Wnested-externs])
  67. mc_CHECK_ONE_CFLAG([-Wno-long-long])
  68. mc_CHECK_ONE_CFLAG([-Wno-unreachable-code])
  69. mc_CHECK_ONE_CFLAG([-Wparentheses])
  70. mc_CHECK_ONE_CFLAG([-Wpointer-arith])
  71. mc_CHECK_ONE_CFLAG([-Wpointer-sign])
  72. mc_CHECK_ONE_CFLAG([-Wredundant-decls])
  73. mc_CHECK_ONE_CFLAG([-Wreturn-type])
  74. mc_CHECK_ONE_CFLAG([-Wsequence-point])
  75. mc_CHECK_ONE_CFLAG([-Wshadow])
  76. mc_CHECK_ONE_CFLAG([-Wsign-compare])
  77. dnl mc_CHECK_ONE_CFLAG([-Wstrict-aliasing])
  78. mc_CHECK_ONE_CFLAG([-Wstrict-prototypes])
  79. mc_CHECK_ONE_CFLAG([-Wswitch])
  80. mc_CHECK_ONE_CFLAG([-Wswitch-default])
  81. mc_CHECK_ONE_CFLAG([-Wtype-limits])
  82. mc_CHECK_ONE_CFLAG([-Wundef])
  83. mc_CHECK_ONE_CFLAG([-Wuninitialized])
  84. mc_CHECK_ONE_CFLAG([-Wunreachable-code])
  85. mc_CHECK_ONE_CFLAG([-Wunused-but-set-variable])
  86. mc_CHECK_ONE_CFLAG([-Wunused-function])
  87. mc_CHECK_ONE_CFLAG([-Wunused-label])
  88. mc_CHECK_ONE_CFLAG([-Wunused-parameter])
  89. mc_CHECK_ONE_CFLAG([-Wunused-result])
  90. mc_CHECK_ONE_CFLAG([-Wunused-value])
  91. mc_CHECK_ONE_CFLAG([-Wunused-variable])
  92. mc_CHECK_ONE_CFLAG([-Wwrite-strings])
  93. AC_LANG_POP()
  94. ])