USE macros in rpm packages

Published in the Fedora mailing list proposal to standardize macros in RPM spec files, allowing you to add to RPM packages the ability to select compilation flags and additional dependencies at the build stage.

Example of use:

%if %{use ssl}
BuildRequires: openssl-devel
%endif

% prep
%configure %{use_enable ssl openssl}

% check
make test %{?_use_ssl:-DSSL}

In this example, when specifying the USE macro ssl in the spec file, an additional dependency on the openssl-devel package will be added, a configuration step will be executed with the --enable-openssl option enabled, and the corresponding tests will be executed during the build.

It is assumed that the build option will be specified by the binary macro %_use_ with additional wrappers like:

  • %{use } – takes values ​​0 or 1,
  • %{use_enable [ [ ]]} – expands to β€”disable- or --enable- .

Adding options of this type to spec files will allow you to compile different versions of the distribution from the same sources.

For example, to minimize the build dependency tree, you can use the global parameter %{use docs}, which disables the build of documentation.

You can set the appropriate set of options by configuring the build environment. Moreover, options can be set both globally and by redefining them separately for each package.

The proposal has not yet been accepted and is under discussion.

Source: linux.org.ru

Add a comment