From e119f805835f58579cd7ced7ea90ecf15995de75 Mon Sep 17 00:00:00 2001 From: keescook Date: Wed, 30 Apr 2008 06:09:51 +0000 Subject: [PATCH] correctly test compiler for -Werror=... --- configure.ac | 25 ++++++++++++++++++++++--- 1 file 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 -- 2.30.2