3 dnl GNOME_COMPILE_WARNINGS
4 dnl Turn on many useful compiler warnings
5 dnl For now, only works on GCC
6 AC_DEFUN([GNOME_COMPILE_WARNINGS],[
7 AC_ARG_ENABLE(compile-warnings,
8 [ --enable-compile-warnings=[no/minimum/yes] Turn on compiler warnings.],,enable_compile_warnings=yes)
10 AC_MSG_CHECKING(the warning flags for this compiler)
12 if test "x$GCC" = "xyes"; then
15 *) warnCFLAGS="-g -Wall -Wunused" ;;
18 ## -W is not all that useful. And it cannot be controlled
19 ## with individual -Wno-xxx flags, unlike -Wall
20 if test "x$enable_compile_warnings" = "xyes"; then
21 warnCFLAGS="$warnCFLAGS -Wmissing-prototypes -Wmissing-declarations \
22 -finline-functions -Wshadow -Wpointer-arith -Wchar-subscripts \
23 -Wformat=2 -Wno-unused-variable -Wno-unused-function -Wwrite-strings -Werror"
27 AC_MSG_RESULT($warnCFLAGS)
30 [ --enable-iso-c Try to warn if code is not ISO C ],,
33 AC_MSG_CHECKING(the language compliance flags for this compiler)
35 if test "x$GCC" = "xyes"; then
38 *) complCFLAGS="$complCFLAGS -ansi" ;;
43 *) complCFLAGS="$complCFLAGS -pedantic" ;;
46 AC_MSG_RESULT($complCFLAGS)
49 AC_MSG_CHECKING(the optimization flags for this compiler)
51 if test "x$GCC" = "xyes" ; then
52 optCFLAGS="-ffast-math -funroll-loops -fno-strict-aliasing"
58 AC_MSG_RESULT($complCFLAGS)
60 # Take the right flags
61 if test "x$cflags_set" != "xyes" ; then
62 if test "x$enable_iso_c" != "xno"; then
63 CFLAGS="$CFLAGS $complCFLAGS"
65 if test "x$enable_compile_warnings" != "xno" ; then
66 CFLAGS="$CFLAGS $warnCFLAGS"