-AC_CACHE_CHECK(
- [whether ${CC} accepts -Wno-long-long],
- [ac_cv_prog_cc_w_no_long_long],
- [save_CFLAGS="$CFLAGS"
- CFLAGS="-Wno-long-long"
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([[]])],
- [ac_cv_prog_cc_w_no_long_long=yes],
- [ac_cv_prog_cc_w_no_long_long=no])
- CFLAGS="$save_CFLAGS"
- ])
-
-AC_CACHE_CHECK(
- [whether ${CC} accepts -Wno-variadic-macros],
- [ac_cv_prog_cc_w_no_variadic_macros],
- [save_CFLAGS="$CFLAGS"
- CFLAGS="-Wno-variadic-macros"
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([[]])],
- [ac_cv_prog_cc_w_no_variadic_macros=yes],
- [ac_cv_prog_cc_w_no_variadic_macros=no])
- CFLAGS="$save_CFLAGS"
- ])
-
-AC_CACHE_CHECK(
- [whether ${CC} accepts -Wno-overlength-strings],
- [ac_cv_prog_cc_w_no_overlength_strings],
- [save_CFLAGS="$CFLAGS"
- CFLAGS="-Wno-overlength-strings"
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([[]])],
- [ac_cv_prog_cc_w_no_overlength_strings=yes],
- [ac_cv_prog_cc_w_no_overlength_strings=no])
- CFLAGS="$save_CFLAGS"
- ])
-
-strict_warn=
-if test $ac_cv_prog_cc_w_no_long_long = yes \
- && test $ac_cv_prog_cc_w_no_variadic_macros = yes \
- && test $ac_cv_prog_cc_w_no_overlength_strings = yes ; then
- strict_warn="-pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings"
-fi
-
-# Add -Wold-style-definition if it's accepted
-AC_CACHE_CHECK(
- [whether ${CC} accepts -Wold-style-definition],
- [ac_cv_prog_cc_w_old_style_definition],
- [save_CFLAGS="$CFLAGS"
- CFLAGS="-Wold-style-definition"
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([[]])],
- [ac_cv_prog_cc_w_old_style_definition=yes],
- [ac_cv_prog_cc_w_old_style_definition=no])
- CFLAGS="$save_CFLAGS"
- ])
-if test $ac_cv_prog_cc_w_old_style_definition = yes ; then
- strict_warn="${strict_warn} -Wold-style-definition"
-fi
-
-# Add -Wmissing-format-attribute if it's accepted
-AC_CACHE_CHECK(
- [whether ${CC} accepts -Wmissing-format-attribute],
- [ac_cv_prog_cc_w_missing_format_attribute],
- [save_CFLAGS="$CFLAGS"
- CFLAGS="-Wmissing-format-attribute"
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([[]])],
- [ac_cv_prog_cc_w_missing_format_attribute=yes],
- [ac_cv_prog_cc_w_missing_format_attribute=no])
- CFLAGS="$save_CFLAGS"
- ])
-if test $ac_cv_prog_cc_w_missing_format_attribute = yes ; then
- strict_warn="${strict_warn} -Wmissing-format-attribute"
-fi
-
-# Enable -Werror, period.
-AC_ARG_ENABLE(werror_always,
-[ --enable-werror-always enable -Werror always], [],
-[enable_werror_always=no])
-if test x${enable_werror_always} = xyes ; then
- strict_warn="${strict_warn} -Werror"
-fi
-AC_SUBST(strict_warn)
-
-# Get C++ compatibility warning flag, if supported.
-AC_CACHE_CHECK(
- [whether ${CC} accepts -Wc++-compat],
- [ac_cv_prog_cc_w_cxx_compat],
- [save_CFLAGS="$CFLAGS"
- CFLAGS="-Wc++-compat"
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([[]])],
- [ac_cv_prog_cc_w_cxx_compat=yes],
- [ac_cv_prog_cc_w_cxx_compat=no])
- CFLAGS="$save_CFLAGS"
- ])
-if test x${ac_cv_prog_cc_w_cxx_compat} = xyes; then
- cxx_compat_warn="-Wc++-compat"
-fi
-AC_SUBST(cxx_compat_warn)
-
-
-# If the native compiler is GCC, we can enable warnings even in stage1.
-# That's useful for people building cross-compilers, or just running a
-# quick `make'.
+ACX_PROG_CC_WARNING_OPTS(
+ m4_quote(m4_do([-W -Wall -Wwrite-strings -Wstrict-prototypes ],
+ [-Wmissing-prototypes -Wcast-qual])), [loose_warn])
+ACX_PROG_CC_WARNING_OPTS(
+ m4_quote(m4_do([-Wold-style-definition -Wc++-compat ],
+ [-Wmissing-format-attribute])), [strict_warn])
+ACX_PROG_CC_WARNING_ALMOST_PEDANTIC(
+ m4_quote(m4_do([-Wno-long-long -Wno-variadic-macros ],
+ [-Wno-overlength-strings])), [strict_warn])
+ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual], [strict_warn])
+
+# The above macros do nothing if the compiler is not GCC. However, the
+# Makefile has more goo to add other flags, so this variabl is used to
+# enables warnings only for GCC.