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 -Wcomment \
23 -Wformat=2 -Wno-unused-variable -Wno-unused-function -Wno-unused-label -Wwrite-strings \
28 AC_MSG_RESULT($warnCFLAGS)
31 [ --enable-iso-c Try to warn if code is not ISO C ],,
34 AC_MSG_CHECKING(the language compliance flags for this compiler)
36 if test "x$GCC" = "xyes"; then
39 *) complCFLAGS="$complCFLAGS -ansi" ;;
44 *) complCFLAGS="$complCFLAGS -pedantic" ;;
47 AC_MSG_RESULT($complCFLAGS)
50 AC_MSG_CHECKING(the optimization flags for this compiler)
52 if test "x$GCC" = "xyes" ; then
53 optCFLAGS="-ffast-math -funroll-loops -fno-strict-aliasing"
56 *) optCFLAGS="$optCFLAGS -O3" ;;
59 AC_MSG_RESULT($optCFLAGS)
61 # Take the right flags
62 if test "x$cflags_set" != "xyes" ; then
63 if test "x$enable_iso_c" != "xno"; then
64 CFLAGS="$CFLAGS $complCFLAGS $optCFLAGS"
66 if test "x$enable_compile_warnings" != "xno" ; then
67 CFLAGS="$CFLAGS $warnCFLAGS $optCFLAGS"