aboutsummaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorJonathan Gray <[email protected]>2015-03-17 13:16:05 +1100
committerJose Fonseca <[email protected]>2015-03-18 10:53:20 +0000
commit8475526a3842580f00a043bca8f821e14e9f5eb7 (patch)
tree156b1cfb656fb36be6fb85c655d813a117ad5b59 /configure.ac
parenteeb504e0ae7796e7ba475f6e9d6c26daa6b06608 (diff)
configure: check if compiler supports -Werror=vla.
Check if the compiler supports -Werror=vla before using it. -Wvla was introduced with GCC 4.3 and is not present in 4.2. Fixes the build on OpenBSD. v2: Fix statement order, and quote $save_CFLAGS. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89433 Signed-off-by: Jonathan Gray <[email protected]> Signed-off-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac16
1 files changed, 14 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index a3b0ebd6cf9..8c90b414679 100644
--- a/configure.ac
+++ b/configure.ac
@@ -278,8 +278,20 @@ if test "x$GCC" = xyes; then
# - non-Linux/Posix OpenGL portions needs to build on MSVC 2013 (which
# supports most of C99)
# - the rest has no compiler compiler restrictions
- MSVC2013_COMPAT_CFLAGS="-Werror=vla -Werror=pointer-arith"
- MSVC2013_COMPAT_CXXFLAGS="-Werror=vla -Werror=pointer-arith"
+ MSVC2013_COMPAT_CFLAGS="-Werror=pointer-arith"
+ MSVC2013_COMPAT_CXXFLAGS="-Werror=pointer-arith"
+
+ # Enable -Werror=vla if compiler supports it
+ save_CFLAGS="$CFLAGS"
+ AC_MSG_CHECKING([whether $CC supports -Werror=vla])
+ CFLAGS="$CFLAGS -Werror=vla"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM()],
+ [MSVC2013_COMPAT_CFLAGS="$MSVC2013_COMPAT_CFLAGS -Werror=vla";
+ MSVC2013_COMPAT_CXXFLAGS="$MSVC2013_COMPAT_CXXFLAGS -Werror=vla";
+ AC_MSG_RESULT([yes])],
+ AC_MSG_RESULT([no]));
+ CFLAGS="$save_CFLAGS"
+
MSVC2008_COMPAT_CFLAGS="$MSVC2013_COMPAT_CFLAGS -Werror=declaration-after-statement"
MSVC2008_COMPAT_CXXFLAGS="$MSVC2013_COMPAT_CXXFLAGS"
fi