Defining build options based on available compiler version

Thomas Spura tomspur at fedoraproject.org
Sat Jul 30 19:38:29 UTC 2011


On Sat, 30 Jul 2011 19:44:41 +0300
Jussi Lehtola wrote:

> Hi,
> 
> 
> I tried using 
>  %global gccver %(gcc -dumpversion)
>  %if %{gccver} >= 4.6.0
>   foo here
>  %endif
> 
> to conditionalize usage of quadruple precision support in a spec file
> that ships on multiple distros, but the comparison gives the error
> 
>  parseExpressionBoolean returns -1
> 
> Is there a way to check if the gcc version is sufficient with some rpm
> macro?

Using python for parsing seems to work, but it looks a bit weird ;)

%global true_or_false %(python -c "print('%{gccver}' >= '4.6.0')")
%if %{true_or_false} == "True"
echo "true"
%else
echo "false"
%endif

Hope that helps,
	Thomsa


More information about the devel mailing list