summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKees Cook <kees@outflux.net>2008-04-30 06:09:51 +0000
committerkeescook <keescook@users.sourceforge.net>2008-04-30 06:09:51 +0000
commit1251633acaa7f0f4cb08ffc33e64787d697f2cd5 (patch)
tree76c4b6a2613091c387520a76e9a75f5eb7e15ebb
parentfix remaining format warnings (diff)
downloadinkscape-1251633acaa7f0f4cb08ffc33e64787d697f2cd5.tar.gz
inkscape-1251633acaa7f0f4cb08ffc33e64787d697f2cd5.zip
correctly test compiler for -Werror=...
(bzr r5552)
-rw-r--r--configure.ac25
1 files changed, 22 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index 313d349a8..b28048dd1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,17 +33,36 @@ AC_HEADER_STDC
dnl These next few lines are needed only while libcroco is in our source tree.
AC_PROG_CC
AM_PROG_CC_C_O
-AC_MSG_NOTICE([Testing -Wno-pointer-sign])
if test "$GCC" = "yes"; then
# Enable some warnings from gcc.
AC_LANG_PUSH(C)
# -Wno-pointer-sign is probably new in gcc 4.0; certainly it isn't accepted
# by gcc 2.95.
+ AC_MSG_CHECKING([support for -Wno-pointer-sign])
ink_svd_CFLAGS="$CFLAGS"
CFLAGS="-Wno-pointer-sign $CFLAGS"
- AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), AC_MSG_NOTICE([ compiler supports -Wno-pointer-sign]), CFLAGS="$ink_svd_CFLAGS")
- CFLAGS="-Wall -Wformat -Werror=format-security -W -D_FORTIFY_SOURCE=2 $CFLAGS"
+ AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), [gcc_opt_ok=yes], [gcc_opt_ok=no])
+ AC_MSG_RESULT([$gcc_opt_ok])
+ if test "x$gcc_opt_ok" != "xyes"; then
+ CFLAGS="$ink_svd_CFLAGS"
+ fi
+
+ # This seems safe so far...
+ CFLAGS="-Wall -Wformat -Wformat-security $CFLAGS"
+
+ # Test for -Werror=... (introduced some time post-4.0)
+ AC_MSG_CHECKING([support for -Werror=format-security])
+ ink_svd_CFLAGS="$CFLAGS"
+ CFLAGS="-Werror=format-security $CFLAGS"
+ AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), [gcc_opt_ok=yes], [gcc_opt_ok=no])
+ AC_MSG_RESULT([$gcc_opt_ok])
+ if test "x$gcc_opt_ok" != "xyes"; then
+ CFLAGS="$ink_svd_CFLAGS"
+ fi
+
+ # Fortify source requires -O2 or higher...
+ CFLAGS="-W -D_FORTIFY_SOURCE=2 $CFLAGS"
AC_LANG_POP
fi