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
This commit is contained in:
Stef Walter 2012-06-04 10:39:34 +02:00
parent f2a9d3a478
commit d079041b14

View file

@ -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"