1 dnl Turn on the additional warnings last, so -Werror doesn't affect other tests.
2 AC_DEFUN([IMENDIO_COMPILE_WARNINGS],[
3 if test -f $srcdir/autogen.sh; then
4 default_compile_warnings="error"
6 default_compile_warnings="no"
9 AC_ARG_WITH(compile-warnings, [ --with-compile-warnings=[no/yes/error] Compiler warnings ], [enable_compile_warnings="$withval"], [enable_compile_warnings="$default_compile_warnings"])
12 if test "x$GCC" != xyes; then
13 enable_compile_warnings=no
17 realsave_CFLAGS="$CFLAGS"
19 case "$enable_compile_warnings" in
24 warning_flags="-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations"
27 warning_flags="-Wall -Wunused -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wcast-align -std=c99"
28 CFLAGS="$warning_flags $CFLAGS"
29 for option in -Wno-sign-compare -Wno-pointer-sign; do
31 CFLAGS="$CFLAGS $option"
32 AC_MSG_CHECKING([whether gcc understands $option])
33 AC_TRY_COMPILE([], [],
37 AC_MSG_RESULT($has_option)
38 if test $has_option = yes; then
39 warning_flags="$warning_flags $option"
45 if test "$enable_compile_warnings" = "error" ; then
46 warning_flags="$warning_flags -Werror"
50 AC_MSG_ERROR(Unknown argument '$enable_compile_warnings' to --enable-compile-warnings)
53 CFLAGS="$realsave_CFLAGS"
54 AC_MSG_CHECKING(what warning flags to pass to the C compiler)
55 AC_MSG_RESULT($warning_flags)
57 WARN_CFLAGS="$warning_flags"