Product SiteDocumentation Site


You can define macros in your spec files to help control how the package gets built. The following section describes these macros.

Variable definition macros

The %define macro allows you to define new macros from within your spec file. A common usage is to define top-level directories with %define macros at the top of a spec file and then reference these directories throughout the file. For example:
This allows you to change the setting in one place, which is very handy for directory paths used throughout your spec files.
Cross Reference
See the section on Defining Macros in Spec Files in Chapter 22, Spec File Syntax for more on this subject.
You can use this syntax for other things that may commonly change, such as version numbers. For example:
%define major 2
%define minor 2
%define patchlevel 7
Version: %{major}.%{minor}.%{patchlevel}
Table B-1 lists more special macros used within spec files.
Table B-1 Special spec file macros
Prints out macro values
Prints message to stderr
Prints message to stderr and returns BADSPEC
Like eval, expands expression
Expands file_exp to a file name
%global name value
Defines a global macro
Expands patch_exp to a patch file name
Expands source_exp to a source file name
Toggles the printing of debugging information
Tests if file filename is compressed. If so, uncompresses and includes in the given context. If not compressed, calls cat to include file in given context.
%undefine macro
Undefines the given macro
Prints message to stderr