Conditionals

The %ifxxx conditionals are used to begin a section of the spec file that is specific to a particular architecture or operating system. They are followed by one or more architecture or operating system specifiers, each separated by commas or whitespace.

Conditionals may be nested within other conditionals, provided that the inner conditional is completely enclosed by the outer conditional.

The %ifarch Conditional

If the build system's architecture is specified, the part of the spec file following the %ifarch, but before a %else or %endif will be used during the build.

%ifarch i386 sparc
        

See also: the Section called The %ifarch Conditional in Chapter 13.

The %ifnarch Conditional

If the build system's architecture is specified, the part of the spec file following the %ifarch but before a %else or %endif will not be used during the build.

%ifnarch i386 sparc
        

See also: the Section called The %ifnarch Conditional in Chapter 13.

The %ifos Conditional

If the build system is running one of the specified operating systems, the part of the spec file following the %ifos but before a %else or %endif will be used during the build.

%ifos linux
        

See also: the Section called The %ifos Conditional in Chapter 13.

The %ifnos Conditional

If the build system is running one of the specified operating systems, the part of the spec file following the %ifnos but before a %else or %endif will not be used during the build.

%ifnos linux
        

See also: the Section called The %ifnos Conditional in Chapter 13.

The %else Conditional

The %else conditional is placed between a %if conditional of some persuasion, and an %endif. It is used to create two blocks of spec file statements, only one of which will be used in any given case.

%ifarch alpha
make RPM_OPT_FLAGS="$RPM_OPT_FLAGS -I ."
%else
make RPM_OPT_FLAGS="$RPM_OPT_FLAGS"
%endif
        

See also: the Section called The %else Conditional in Chapter 13.

The %endif Conditional

An %endif is used to end a conditional block of spec file statements. The %endif is always needed after a conditional, otherwise, the build will fail.

%ifarch i386
make INTELFLAG=-DINTEL
%endif
        

See also: the Section called The %endif Conditional in Chapter 13.