ax_cflags_warn_all_ansi.m4 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. AC_DEFUN([AX_CFLAGS_WARN_ALL_ANSI],[dnl
  2. AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
  3. AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_warn_all_ansi])dnl
  4. AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum ansi warnings],
  5. VAR,[VAR="no, unknown"
  6. AC_LANG_SAVE
  7. AC_LANG_C
  8. ac_save_[]FLAGS="$[]FLAGS"
  9. # IRIX C compiler:
  10. # -use_readonly_const is the default for IRIX C,
  11. # puts them into .rodata, but they are copied later.
  12. # need to be "-G0 -rdatashared" for strictmode but
  13. # I am not sure what effect that has really. - guidod
  14. for ac_arg dnl
  15. in "-pedantic % -Wall -std=c99 -pedantic" dnl GCC
  16. "-xstrconst % -v -xc99=all" dnl Solaris C
  17. "-std1 % -verbose -w0 -warnprotos -std1" dnl Digital Unix
  18. " % -qlanglvl=ansi -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX
  19. " % -ansi -ansiE -fullwarn" dnl IRIX
  20. "+ESlit % +w1 -Aa" dnl HP-UX C
  21. "-Xc % -pvctl[,]fullmsg -Xc" dnl NEC SX-5 (Super-UX 10)
  22. "-h conform % -h msglevel 2 -h conform" dnl Cray C (Unicos)
  23. #
  24. do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
  25. AC_TRY_COMPILE([],[return 0;],
  26. [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
  27. done
  28. FLAGS="$ac_save_[]FLAGS"
  29. AC_LANG_RESTORE
  30. ])
  31. case ".$VAR" in
  32. .ok|.ok,*) m4_ifvaln($3,$3) ;;
  33. .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
  34. AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
  35. m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
  36. *) m4_ifvaln($3,$3,[
  37. if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
  38. then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
  39. else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
  40. m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
  41. fi ]) ;;
  42. esac
  43. AS_VAR_POPDEF([VAR])dnl
  44. AS_VAR_POPDEF([FLAGS])dnl
  45. ])
  46. dnl the only difference - the LANG selection... and the default FLAGS
  47. AC_DEFUN([AX_CXXFLAGS_WARN_ALL_ANSI],[dnl
  48. AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
  49. AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_warn_all_ansi])dnl
  50. AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum ansi warnings],
  51. VAR,[VAR="no, unknown"
  52. AC_LANG_SAVE
  53. AC_LANG_CXX
  54. ac_save_[]FLAGS="$[]FLAGS"
  55. # IRIX C compiler:
  56. # -use_readonly_const is the default for IRIX C,
  57. # puts them into .rodata, but they are copied later.
  58. # need to be "-G0 -rdatashared" for strictmode but
  59. # I am not sure what effect that has really. - guidod
  60. for ac_arg dnl
  61. in "-pedantic % -Wall -ansi -pedantic" dnl GCC
  62. "-xstrconst % -v -Xc" dnl Solaris C
  63. "-std1 % -verbose -w0 -warnprotos -std1" dnl Digital Unix
  64. " % -qlanglvl=ansi -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX
  65. " % -ansi -ansiE -fullwarn" dnl IRIX
  66. "+ESlit % +w1 -Aa" dnl HP-UX C
  67. "-Xc % -pvctl[,]fullmsg -Xc" dnl NEC SX-5 (Super-UX 10)
  68. "-h conform % -h msglevel 2 -h conform" dnl Cray C (Unicos)
  69. #
  70. do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
  71. AC_TRY_COMPILE([],[return 0;],
  72. [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
  73. done
  74. FLAGS="$ac_save_[]FLAGS"
  75. AC_LANG_RESTORE
  76. ])
  77. case ".$VAR" in
  78. .ok|.ok,*) m4_ifvaln($3,$3) ;;
  79. .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
  80. AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
  81. m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
  82. *) m4_ifvaln($3,$3,[
  83. if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
  84. then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
  85. else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
  86. m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
  87. fi ]) ;;
  88. esac
  89. AS_VAR_POPDEF([VAR])dnl
  90. AS_VAR_POPDEF([FLAGS])dnl
  91. ])