mc-cflags.m4 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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([-Wignored-qualifiers])
  56. mc_CHECK_ONE_CFLAG([-Wlogical-not-parentheses])
  57. mc_CHECK_ONE_CFLAG([-Wmaybe-uninitialized])
  58. mc_CHECK_ONE_CFLAG([-Wmissing-braces])
  59. mc_CHECK_ONE_CFLAG([-Wmissing-declarations])
  60. mc_CHECK_ONE_CFLAG([-Wmissing-field-initializers])
  61. mc_CHECK_ONE_CFLAG([-Wmissing-format-attribute])
  62. mc_CHECK_ONE_CFLAG([-Wmissing-parameter-type])
  63. mc_CHECK_ONE_CFLAG([-Wmissing-prototypes])
  64. mc_CHECK_ONE_CFLAG([-Wmissing-variable-declarations])
  65. mc_CHECK_ONE_CFLAG([-Wnested-externs])
  66. mc_CHECK_ONE_CFLAG([-Wno-long-long])
  67. mc_CHECK_ONE_CFLAG([-Wno-unreachable-code])
  68. mc_CHECK_ONE_CFLAG([-Wparentheses])
  69. mc_CHECK_ONE_CFLAG([-Wpointer-arith])
  70. mc_CHECK_ONE_CFLAG([-Wpointer-sign])
  71. mc_CHECK_ONE_CFLAG([-Wredundant-decls])
  72. mc_CHECK_ONE_CFLAG([-Wreturn-type])
  73. mc_CHECK_ONE_CFLAG([-Wsequence-point])
  74. mc_CHECK_ONE_CFLAG([-Wshadow])
  75. mc_CHECK_ONE_CFLAG([-Wsign-compare])
  76. dnl mc_CHECK_ONE_CFLAG([-Wstrict-aliasing])
  77. mc_CHECK_ONE_CFLAG([-Wstrict-prototypes])
  78. mc_CHECK_ONE_CFLAG([-Wswitch])
  79. mc_CHECK_ONE_CFLAG([-Wswitch-default])
  80. mc_CHECK_ONE_CFLAG([-Wtype-limits])
  81. mc_CHECK_ONE_CFLAG([-Wundef])
  82. mc_CHECK_ONE_CFLAG([-Wuninitialized])
  83. mc_CHECK_ONE_CFLAG([-Wunreachable-code])
  84. mc_CHECK_ONE_CFLAG([-Wunused-but-set-variable])
  85. mc_CHECK_ONE_CFLAG([-Wunused-function])
  86. mc_CHECK_ONE_CFLAG([-Wunused-label])
  87. mc_CHECK_ONE_CFLAG([-Wunused-parameter])
  88. mc_CHECK_ONE_CFLAG([-Wunused-result])
  89. mc_CHECK_ONE_CFLAG([-Wunused-value])
  90. mc_CHECK_ONE_CFLAG([-Wunused-variable])
  91. mc_CHECK_ONE_CFLAG([-Wwrite-strings])
  92. AC_LANG_POP()
  93. ])