configure: Enable set of standard -Werror=foo flags

We're not going to depend on gnome-common (I assume) so this patch
nicks the systemd macro to test for compiler flags, and uses it to set
a similar set of -Werror=foo as the gnome-common one does.

See https://bugzilla.gnome.org/show_bug.cgi?id=608953
See https://mail.gnome.org/archives/desktop-devel-list/2012-July/msg00100.html

If we're going to be setting more strict compiler flags for GNOME, we
should really ensure GLib builds with them first, as it's kind of the
model citizen.

In particular, you can see several times that downstreams such as
Debian have come in and fixed -Wformat-security bugs.  We should never
let those get into tarballs, or even commits.

https://bugzilla.gnome.org/show_bug.cgi?id=687385
This commit is contained in:
Colin Walters
2012-11-01 19:39:20 -04:00
parent 055aa2b55e
commit 28b30caecb
2 changed files with 297 additions and 7 deletions

View File

@@ -527,13 +527,6 @@ dnl when using libtool 2.x create libtool early, because it's used in configure
m4_ifdef([LT_OUTPUT], [LT_OUTPUT])
if test "x$GCC" = "xyes"; then
case " $CFLAGS " in
*[[\ \ ]]-Wall[[\ \ ]]*) ;;
*) CFLAGS="$CFLAGS -Wall" ;;
esac
fi
AS_IF([test "$glib_native_win32" = "yes"], [
if test x$enable_static = xyes -a x$enable_shared = xyes; then
AC_MSG_ERROR([Can not build both shared and static at the same time on Windows.])
@@ -3532,6 +3525,15 @@ fi
AC_SUBST(GLIB_LINK_FLAGS)
dnl Compiler flags; macro originates from systemd
dnl See https://bugzilla.gnome.org/show_bug.cgi?id=608953
CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
-Wall -Wstrict-prototypes -Werror=declaration-after-statement \
-Werror=missing-prototypes -Werror=implicit-function-declaration \
-Werror=pointer-arith -Werror=init-self -Werror=format-security \
-Werror=format=2 -Werror=missing-include-dirs])
CFLAGS="$CFLAGS $with_cflags"
#
# Define variables corresponding to the correct include paths to use for
# in-tree building.