[PATCH util-macros 2/6] Add XORG_TESTSET_CFLAG which can be used to test what flags the compiler supports

Gaetan Nadon memsize at videotron.ca
Wed Nov 2 08:55:39 PDT 2011


On Tue, 2011-11-01 at 13:16 -0700, Jeremy Huddleston wrote:

> Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
> ---
>  xorg-macros.m4.in |   27 +++++++++++++++++++++++++++
>  1 files changed, 27 insertions(+), 0 deletions(-)
> 
> diff --git a/xorg-macros.m4.in b/xorg-macros.m4.in
> index 3b02190..c4a521f 100644
> --- a/xorg-macros.m4.in
> +++ b/xorg-macros.m4.in
> @@ -1378,6 +1378,33 @@ AC_CHECK_DECL([__INTEL_COMPILER], [INTELCC="yes"], [INTELCC="no"])
>  AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
>  ]) # XORG_COMPILER_BRAND
>  
> +# XORG_TESTSET_CFLAG(<variable>, <flag>, [<alternative flag>, ...])
> +# ---------------
> +# Minimum version: 1.16.0
> +#
> +# Append the given flag to the given variable if the compiler supports it.

What is the definition of "support"?
I vaguely recall reading compiler manuals stating that (some) non
supported flags are ignored so as not to break the build. These may
appear to be "supported" but do not do anything useful. Would "support"
here means "it does anything (including nothing) but not break the
build"?

This should be clarified to avoid one using this macro as a way to test
for the presence of a particular working compiler feature.


> +#
> +AC_DEFUN([XORG_TESTSET_CFLAG], [
> +# If the module's configure.ac calls AC_PROG_CC later on, CC gets set to C89
> +AC_REQUIRE([AC_PROG_CC_C99])
> +ifelse([$#], [0], [AC_MSG_ERROR("Incorrect arguments to XORG_TESTSET_CFLAG")],
> +       [$#], [1], :,
> +       [save_CFLAGS="$CFLAGS"
> +        CFLAGS="$CFLAGS $2"
> +        AC_MSG_CHECKING([if $CC supports $2])
> +        AC_COMPILE_IFELSE([AC_LANG_SOURCE([], [return 0;])],
> +                          supported=yes, supported=no)
> +        CFLAGS="$save_CFLAGS"
> +        if test "$supported" = "yes" ; then
> +            AC_MSG_RESULT([yes])
> +            $1="$$1 $2"
> +        else
> +            AC_MSG_RESULT([no])
> +            dnl XORG_TESTSET_CFLAG($1, shift(shift($@))))
> +        fi
> +       ])
> +]) # XORG_TESTSET_CFLAG
> +
>  # XORG_CWARNFLAGS
>  # ---------------
>  # Minimum version: 1.2.0



Same comment regarding AC_LANG_SOURCE vs AC_LANG_PROGRAM.

The following macro usage does not produce any error, perhaps it should:

        XORG_TESTSET_CFLAG([GIVEN])

As for recursion, recall the discussion about
AC_PATH_PROGS_FEATURE_CHECK introduced in autoconf 2.62 which xcb wanted
to use mainly because of the recursion capabilities. I am no expert in
m4, but there are examples where it has been done. I recall having a
look at the time and it was not trivial in the autoconf code.




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg-devel/attachments/20111102/8a596196/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.x.org/archives/xorg-devel/attachments/20111102/8a596196/attachment-0001.pgp>


More information about the xorg-devel mailing list