[gnome-control-center] build: Only enable _FORTIFY_SOURCE if optimization enabled



commit d079041b14db5dc3fb10f6ac4e9c6700df2e956b
Author: Stef Walter <stefw gnome org>
Date:   Mon Jun 4 10:39:34 2012 +0200

    build: Only enable _FORTIFY_SOURCE if optimization enabled
    
    Otherwise we get a spew of warnings when building non-optimized
    
    https://bugzilla.gnome.org/show_bug.cgi?id=677373

 configure.ac |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 8ea837a..a97dfcd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -312,9 +312,22 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
         -Wuninitialized \
         -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes \
         -Wnested-externs -Wpointer-arith \
-        -Wcast-align -Wsign-compare -Wp,-D_FORTIFY_SOURCE=2 \
+        -Wcast-align -Wsign-compare \
         $CFLAGS"
 
+	# Only add this when optimizing is enabled (default)
+	AC_MSG_CHECKING([whether optimization is enabled])
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if __OPTIMIZE__ == 0
+	                                     #error No optimization
+	                                     #endif
+	                                   ]], [[]])],
+	                  [has_optimization=yes],
+	                  [has_optimization=no])
+	if test $has_optimization = yes; then
+		CFLAGS="$CFLAGS -Wp,-D_FORTIFY_SOURCE=2"
+	fi
+	AC_MSG_RESULT($has_optimization)
+
         for option in -Wno-strict-aliasing -Wno-sign-compare; do
                 SAVE_CFLAGS="$CFLAGS"
                 CFLAGS="$CFLAGS $option"



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]