Product SiteDocumentation Site

10.6.2. Using conditional blocks

The %if macro enables all the directives up to the %endif directive, if the condition is true. This is much like scripting languages. For example:
%if %{old_5x}
%define b5x 1
%undefine b6x
%endif
In this case, if the %old_5x macro has a value, the test will be true and all the directives inside the block will get executed.
A %else allows you to specify what to do if the test is not successful. For example:
%if %{old_5x}
%define b5x 1
%undefine b6x
%else
%define b6x 1
%undefine b5x
%endif
In this case, if the %old_5x macro has a value, then all the directives up to the %else will get executed. Otherwise, if the %old_5x macro has no value, the directives from the %else to the %endif will get executed.
Again, use an exclamation point to negate the test. For example:
%if ! %{old_5x}
%define b5x 1
%undefine b6x
%endif
You can use a && for an AND test. For example:
%if %{old_5x} && %{old_6x}
%{error: You cannot build for .5x and .6x at the same time}
%quit
%endif