Product SiteDocumentation Site

Using architecture-based conditionals

In addition to the general-purpose %if conditional directive, you can use special directives that test for processor architecture and operating system.
The %ifarch directive enables all the directives up to the %endif directive, if the processor architecture matches the values you pass to the %ifarch directive. For example:
%ifarch sparc
%define b5x 1
%undefine b6x
%endif
This block will only get executed if the processor architecture is SPARC.
Cross Reference
Chapter 20, Customizing RPM Behavior covers RPM architecture and operating system names.
You can pass more than one architecture name, separated by commas or spaces. For example:
%ifarch sparc alpha
%define b5x 1
%undefine b6x
%endif
This example tests if the processor architecture is SPARC or Alpha.
As with the %if directive, you can also use an %else, to cover all cases where the test is not true. For example:
%ifarch sparc alpha
%define b5x 1
%undefine b6x
%else
%define b6x 1
%undefine b5x
%endif
This example tests if the processor architecture is SPARC or Alpha. If so, the directives from the %ifarch to the %else are executed. If not, the directives from the %else to the %endif are executed.
The %ifnarch directive reverses the %ifarch test. That is, %ifnarch tests if the architecture is not one of the values listed. The following example tests if the processor architecture is not an i386 or an Alpha.
%ifnarch i386 alpha
%define b5x 1
%undefine b6x
%endif
The %ifos directive tests for the operating system. For example:
%ifos linux
%define b5x 1
%undefine b6x
%endif
This example tests if the operating system is Linux. You can reverse the test with the %ifnos directive. For example:
%ifnos irix
%define b5x 1
%undefine b6x
%endif
This example tests if the operating system is not Irix.