summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2011-05-09 19:02:46 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2011-05-25 16:57:02 +0100
commite9bf1355d7c16a0ca842dd9b9b17f6ce4a4f863e (patch)
tree223f94d8d4464658f15410f40282cdd0fa7b413d
parentad4e7af759d7e86a79508525949b6fabef53753f (diff)
downloaddbus-e9bf1355d7c16a0ca842dd9b9b17f6ce4a4f863e.tar.gz
Use TP_COMPILER_WARNINGS for all -Wfoo options
This consistently checks whether all these options actually work in the current version of gcc. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=19681 Reviewed-by: Colin Walters <walters@verbum.org>
-rw-r--r--configure.ac118
1 files changed, 34 insertions, 84 deletions
diff --git a/configure.ac b/configure.ac
index 940bfae5..ff6c40a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1117,72 +1117,10 @@ cc_supports_flag() {
test "x$rc" = xyes
}
-# Don't bother with -Werror on Windows for now, too many warnings
-if test x$dbus_win != xyes -a x$dbus_cygwin != xyes -a x$USE_MAINTAINER_MODE = xyes; then
- if cc_supports_flag "-Werror"; then
- CFLAGS="$CFLAGS -Werror"
- fi
-fi
-
dnl This whole "if" block is in m4 quotes ([]) because it uses them
dnl for character ranges internally. m4 macros cannot be used inside this
dnl block.
[if test "x$GCC" = "xyes"; then
- case " $CFLAGS " in
- *[\ \ ]-Wall[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wall" ;;
- esac
-
- case " $CFLAGS " in
- *[\ \ ]-Wchar-subscripts[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wchar-subscripts" ;;
- esac
-
- case " $CFLAGS " in
- *[\ \ ]-Wmissing-declarations[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wmissing-declarations" ;;
- esac
-
- case " $CFLAGS " in
- *[\ \ ]-Wmissing-prototypes[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wmissing-prototypes" ;;
- esac
-
- case " $CFLAGS " in
- *[\ \ ]-Wnested-externs[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wnested-externs" ;;
- esac
-
- case " $CFLAGS " in
- *[\ \ ]-Wpointer-arith[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wpointer-arith" ;;
- esac
-
- case " $CFLAGS " in
- *[\ \ ]-Wcast-align[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wcast-align" ;;
- esac
-
- case " $CFLAGS " in
- *[\ \ ]-Wno-address[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wno-address" ;;
- esac
-
- case " $CFLAGS " in
- *[\ \ ]-Wfloat-equal[\ \ ]*) ;;
- *) if cc_supports_flag -Wfloat-equal; then
- CFLAGS="$CFLAGS -Wfloat-equal"
- fi
- ;;
- esac
-
- case " $CFLAGS " in
- *[\ \ ]-Wdeclaration-after-statement[\ \ ]*) ;;
- *) if cc_supports_flag -Wdeclaration-after-statement; then
- CFLAGS="$CFLAGS -Wdeclaration-after-statement"
- fi
- ;;
- esac
case " $CFLAGS " in
*[\ \ ]-fno-common[\ \ ]*) ;;
@@ -1194,28 +1132,6 @@ dnl block.
### Disabled warnings, and compiler flag overrides
- # Let's just ignore unused for now
- case " $CFLAGS " in
- *[\ \ ]-Wno-unused[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wno-unused" ;;
- esac
-
- # This group is for warnings we currently don't pass.
- # We would like to, however. Please fix.
-
- # http://bugs.freedesktop.org/show_bug.cgi?id=17433
- case " $CFLAGS " in
- *[\ \ ]-Wno-sign-compare[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wno-sign-compare" ;;
- esac
- case " $CFLAGS " in
- *[\ \ ]-Wno-pointer-sign[\ \ ]*) ;;
- *) if cc_supports_flag -Wno-pointer-sign; then
- CFLAGS="$CFLAGS -Wno-pointer-sign"
- fi
- ;;
- esac
-
# This one is special - it's not a warning override.
# http://bugs.freedesktop.org/show_bug.cgi?id=10599
case " $CFLAGS " in
@@ -1247,6 +1163,40 @@ dnl block.
fi
fi]
+TP_COMPILER_WARNINGS([WARNING_CFLAGS],
+ dnl Use -Werror by default if:
+ dnl - we're not on Windows (too many warnings), and
+ dnl - we're in maintainer mode (a D-Bus developer, not a distro or end-user)
+ dnl Override with --enable-Werror or --disable-Werror
+ [test x$dbus_win != xyes -a x$dbus_cygwin != xyes -a x$USE_MAINTAINER_MODE = xyes],
+
+ dnl enable these warnings if possible:
+ [all \
+ char-subscripts \
+ missing-declarations \
+ missing-prototypes \
+ nested-externs \
+ pointer-arith \
+ cast-align \
+ no-address \
+ float-equal \
+ declaration-after-statement \
+ ],
+
+ dnl disable these warnings if possible, make them non-fatal if possible,
+ dnl and don't enable -Werror unless we succeeded:
+ dnl (unused is by design, sign-compare and pointer-sign are fd.o #17433)
+ [unused \
+ sign-compare \
+ pointer-sign \
+ ])
+
+dnl In principle we should put WARNING_CFLAGS in each Makefile.am like
+dnl telepathy-glib does, since CFLAGS is meant to be reserved for the user...
+dnl but prepending to CFLAGS (so the user can override it with later CFLAGS)
+dnl is the next best thing
+CFLAGS="$WARNING_CFLAGS $CFLAGS"
+
# Disabling gc-sections makes our binaries bigger, but some toolchains
# have known-broken support for it which discards sections that are needed.
# See https://bugs.freedesktop.org/show_bug.cgi?id=33466