RPM-MACROFILE(5) File Formats Manual RPM-MACROFILE(5)

# [NAME](#NAME)

**rpm-macrofile** - rpm macro file format

# [SYNOPSIS](#SYNOPSIS)

%*NAME*\[(\[*OPTS*]) *BODY*

# [DESCRIPTION](#DESCRIPTION)

Rpm macro files are used to define [**rpm-macros**(7)](/man/os/rpm/rpm-macros.7) in the global macro context. The two primary uses of macros are assisting packaging work, and configuring rpm behavior. A pre-determined set of macro files is read upon **rpm** library initialization as described in [**rpm-config**(5)](/man/os/rpm/rpm-config.5) but they can also be loaded via the **%load** macro separately.

The format of a macro file is: the macro *NAME* prefixed with **%**, followed by whitespace and then the macro body, each new definition separated with a newline. The syntax is exactly the same as when using **%define**. See [**rpm-macros**(7)](/man/os/rpm/rpm-macros.7) for details on the macro syntax.

A trailing **\\** indicates line continuation, but can be omitted inside macro bodies wrapped in a **%{macro:...}** block.

Lines starting with **#** or consisting solely of whitespace are ignored.

Reading a macro file is always fully declarative: no macros are ever expanded when reading a macro file.

# [EXAMPLES](#EXAMPLES)

## [Example 1. Simple macro](#Example_1._Simple_macro)

```
%mytool	/usr/bin/mytool-with-annoying-name
```

## [Example 2. Multiline macro with a preceding comment](#Example_2._Multiline_macro_with_a_preceding_comment)

```
# Trailing %{nil} is handy for ensuring a newline at the end
%mycmd %{mytool} \


    --one \


    --with \


    --too \


    --many arguments \
%{nil}
```

## [Example 3. Multiline parametric Lua macro:](#Example_3._Multiline_parametric_Lua_macro:)

```
%myhelper() %{lua:


    function dostuff(arg)


        return 'do stuff to '..arg


    end


    print(dostuff(arg[1]))
}
```

# [SEE ALSO](#SEE_ALSO)

[**rpm-config**(5)](/man/os/rpm/rpm-config.5) [**rpmbuild-config**(5)](/man/os/rpm/rpmbuild-config.5) [**rpm-macros**(7)](/man/os/rpm/rpm-macros.7)

2026-10-04 RPM 6.1.0

---

Document: rpm-macrofile(5) from rpm 6.1.0-r2 (Chainguard OS)
Source: https://github.com/rpm-software-management/rpm
