From 7635606bcde36d7d73b2f652c772c1e6b8efb047 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 9 May 2011 19:03:12 +0100 Subject: [PATCH 3/5] Use TP_ADD_COMPILER_FLAG to simplify application of warning-like CFLAGS This also means we check for support for them. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=19681 --- configure.ac | 60 +++++++++++++-------------------------------------------- 1 files changed, 14 insertions(+), 46 deletions(-) diff --git a/configure.ac b/configure.ac index ff6c40a..e097718 100644 --- a/configure.ac +++ b/configure.ac @@ -1117,52 +1117,6 @@ cc_supports_flag() { test "x$rc" = xyes } -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 - *[\ \ ]-fno-common[\ \ ]*) ;; - *) if cc_supports_flag -fno-common; then - CFLAGS="$CFLAGS -fno-common" - fi - ;; - esac - - ### Disabled warnings, and compiler flag overrides - - # This one is special - it's not a warning override. - # http://bugs.freedesktop.org/show_bug.cgi?id=10599 - case " $CFLAGS " in - *[\ \ ]-fno-strict-aliasing[\ \ ]*) ;; - *) CFLAGS="$CFLAGS -fno-strict-aliasing" ;; - esac - ### End disabled warnings - - if test "x$enable_ansi" = "xyes"; then - case " $CFLAGS " in - *[\ \ ]-ansi[\ \ ]*) ;; - *) CFLAGS="$CFLAGS -ansi" ;; - esac - - case " $CFLAGS " in - *[\ \ ]-D_POSIX_C_SOURCE*) ;; - *) CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=199309L" ;; - esac - - case " $CFLAGS " in - *[\ \ ]-D_BSD_SOURCE[\ \ ]*) ;; - *) CFLAGS="$CFLAGS -D_BSD_SOURCE" ;; - esac - - case " $CFLAGS " in - *[\ \ ]-pedantic[\ \ ]*) ;; - *) CFLAGS="$CFLAGS -pedantic" ;; - esac - fi -fi] - TP_COMPILER_WARNINGS([WARNING_CFLAGS], dnl Use -Werror by default if: dnl - we're not on Windows (too many warnings), and @@ -1191,6 +1145,20 @@ TP_COMPILER_WARNINGS([WARNING_CFLAGS], pointer-sign \ ]) +if test "x$GCC" = "xyes"; then + # We're treating -fno-common like a warning: it makes the linker more + # strict, because on some systems the linker is *always* this strict + TP_ADD_COMPILER_FLAG([WARNING_CFLAGS], [-fno-common]) + + # http://bugs.freedesktop.org/show_bug.cgi?id=10599 + TP_ADD_COMPILER_FLAG([WARNING_CFLAGS], [-fno-strict-aliasing]) + + if test "x$enable_ansi" = "xyes"; then + TP_ADD_COMPILER_FLAG([WARNING_CFLAGS], + [-ansi -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -pedantic]) + fi +fi + 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) -- 1.7.5.1