[PATCH macros 1/2] Make XORG_TESTSET_CFLAG work for multiple languages
Chase Douglas
chase.douglas at canonical.com
Thu Mar 1 10:04:45 PST 2012
On 03/01/2012 09:52 AM, Jon TURNEY wrote:
>
>
> On 29/02/2012 20:24, Chase Douglas wrote:
>> Signed-off-by: Chase Douglas<chase.douglas-Z7WLFzj8eWMS+FvcfC7Uqw at public.gmane.org>
>> ---
>> xorg-macros.m4.in | 53 ++++++++++++++++++++++++++++++++---------------------
>> 1 files changed, 32 insertions(+), 21 deletions(-)
>>
>> diff --git a/xorg-macros.m4.in b/xorg-macros.m4.in
>> index 8550ca0..9041542 100644
>> --- a/xorg-macros.m4.in
>> +++ b/xorg-macros.m4.in
>> @@ -1449,49 +1449,60 @@ AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
>> # -Werror=unused-command-line-argument
>> #
>> 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="$CFLAGS"
>> +AC_LANG_COMPILER_REQUIRE
>> +
>> +AC_LANG_CASE(
>> + [C], [
>> + AC_REQUIRE([AC_PROG_CC_C99])
>> + define([PREFIX], [C])
>> + ],
>> + [C++], [
>> + define([PREFIX], [CXX])
>> + ]
>> +)
>> +
>> +[xorg_testset_save_]PREFIX[FLAGS]="$PREFIX[FLAGS]"
>>
>> if test "x$xorg_testset_unknown_warning_option" = "x" ; then
>> - CFLAGS="$CFLAGS -Werror=unknown-warning-option"
>> - AC_CACHE_CHECK([if $CC supports -Werror=unknown-warning-option],
>> - xorg_cv_cc_flag_unknown_warning_option,
>> + PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option"
>> + AC_CACHE_CHECK([if compiler supports -Werror=unknown-warning-option],
>> + xorg_cv_compiler_flag_unknown_warning_option,
>> AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
>> - [xorg_cv_cc_flag_unknown_warning_option=yes],
>> - [xorg_cv_cc_flag_unknown_warning_option=no]))
>> - xorg_testset_unknown_warning_option=$xorg_cv_cc_flag_unknown_warning_option
>> - CFLAGS="$xorg_testset_save_CFLAGS"
>> + [xorg_cv_compiler_flag_unknown_warning_option=yes],
>> + [xorg_cv_compiler_flag_unknown_warning_option=no]))
>> + xorg_testset_unknown_warning_option=$xorg_cv_compiler_flag_unknown_warning_option
>> + PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]"
>
> This looks wrong.
>
> Using a single cache variable for all languages will assume that the compilers
> for all languages support the same set of flags, when caching is used.
>
> Wouldn't it be better to use the language as part of the cache variable name?
To be honest, if you are switching between languages and calling
XORG_TESTSET_CFLAG (or one of it's callers) things are very likely to be
broken still. This patch set is meant to make it work for multiple
languages, but only one language per project. Making this reentrant with
different languages can be provided in later patches when it becomes
necessary.
That may be the case very soon, btw, if we put xorg-gtest into a project
like xserver. At which point I'll need to revisit this :).
-- Chase
More information about the xorg-devel
mailing list