<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.32.2">
</HEAD>
<BODY>
On Thu, 2011-11-03 at 01:19 -0700, Jeremy Huddleston wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
Signed-off-by: Jeremy Huddleston &lt;<A HREF="mailto:jeremyhu@apple.com">jeremyhu@apple.com</A>&gt;
---
 xorg-macros.m4.in |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/xorg-macros.m4.in b/xorg-macros.m4.in
index 534afba..1ece326 100644
--- a/xorg-macros.m4.in
+++ b/xorg-macros.m4.in
@@ -1378,6 +1378,58 @@ AC_CHECK_DECL([__INTEL_COMPILER], [INTELCC=&quot;yes&quot;], [INTELCC=&quot;no&quot;])
 AC_CHECK_DECL([__SUNPRO_C], [SUNCC=&quot;yes&quot;], [SUNCC=&quot;no&quot;])
 ]) # XORG_COMPILER_BRAND
 
+# XORG_TESTSET_CFLAG(&lt;variable&gt;, &lt;flag&gt;, [&lt;alternative flag&gt;, ...])
+# ---------------
+# Minimum version: 1.16.0
+#
+# Test if the compiler works when passed the given flag as a command line argument.
+# If it succeeds, the flag is appeneded to the given variable.  If not, it tries the
+# next flag in the list until there are no more options.
+#
+# Note that this does not guarantee that the compiler supports the flag as some
+# compilers will simply ignore arguments that they do not understand, but we do
+# attempt to weed out false positives by using -Werror=unknown-warning-option
+#
+AC_DEFUN([XORG_TESTSET_CFLAG], [
+AC_REQUIRE([AC_PROG_CC_C99])
+m4_if([$#], 0, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])])
+m4_if([$#], 1, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])])
+
+xorg_testset_save_CFLAGS=&quot;$CFLAGS&quot;
+
+if test &quot;x$xorg_testset_unknown_warning_option&quot; = &quot;x&quot; ; then
+        CFLAGS=&quot;$CFLAGS -Werror=unknown-warning-option&quot;
+        AC_MSG_CHECKING([if $CC supports -Werror=unknown-warning-option])
+        AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
+                          [xorg_testset_unknown_warning_option=yes],
+                          [xorg_testset_unknown_warning_option=no])
+        AC_MSG_RESULT([$xorg_testset_unknown_warning_option])
+        CFLAGS=&quot;$xorg_testset_save_CFLAGS&quot;
+fi
+
+found=&quot;no&quot;
+m4_foreach([flag], m4_cdr($@), [
+        if test $found = &quot;no&quot; ; then
+                if test &quot;x$xorg_testset_unknown_warning_option&quot; = &quot;xyes&quot; ; then
+                        CFLAGS=&quot;$CFLAGS -Werror=unknown-warning-option ]flag[&quot;
+                else
+                        CFLAGS=&quot;$CFLAGS ]flag[&quot;
+                fi
+
+                AC_MSG_CHECKING([if $CC supports ]flag[])
+                AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
+                                  [supported=yes], [supported=no])
+                AC_MSG_RESULT([$supported])
+                CFLAGS=&quot;$xorg_testset_save_CFLAGS&quot;
+
+                if test &quot;$supported&quot; = &quot;yes&quot; ; then
+                        $1=&quot;$$1 ]flag[&quot;
+                        found=&quot;yes&quot;
+                fi
+        fi
+])
+]) # XORG_TESTSET_CFLAG
+
 # XORG_CWARNFLAGS
 # ---------------
 # Minimum version: 1.2.0
</PRE>
</BLOCKQUOTE>
<BR>
I am not sure if some of the flags I tested make sense, for example:
<BLOCKQUOTE>
<PRE>
checking if gcc -std=gnu99 supports &quot;-!!!&quot;... yes
checking if gcc -std=gnu99 supports &quot;-12345&quot;... yes
</PRE>
</BLOCKQUOTE>
Reviewed-by: Gaetan Nadon &lt;memsize@videotron.ca&gt;<BR>
<BR>
</BODY>
</HTML>