Packaging/RPM Macros

From openSUSE

Contents

Valid RPM Macros

SUSE_Package_Conventions/RPM_Macros contains a more verbose information about this theme

Here are the definitions for some common specfile macros as they are defined on openSUSE 11.2 alpha0 (rpm-4.4.2.3-36.1). For definitions of more macros, examine the output of "rpm --showrc". To see the expanded definition of a macro use the command "rpm --eval '%{macro}'". Note that neither command will take into account macros defined inside specfiles, but both will take into account macros defined in your ~/.rpmmacros file and macros defined on the command line.

Macros mimicking autoconf variables

%{_sysconfdir}        /etc
%{_initrddir}         %{_sysconfdir}/init.d
%{_prefix}            /usr
%{_exec_prefix}       %{_prefix}
%{_bindir}            %{_exec_prefix}/bin
%{_lib}               lib (lib64 on 64bit systems)
%{_libdir}            %{_exec_prefix}/%{_lib}
%{_libexecdir}        %{_libdir}
%{_sbindir}           %{_exec_prefix}/sbin
%{_sharedstatedir}    %{_prefix}/com
%{_datadir}           %{_prefix}/share
%{_includedir}        %{_prefix}/include
%{_oldincludedir}     /usr/include
%{_infodir}           %{_prefix}/share/info
%{_mandir}            %{_prefix}/share/man
%{_localstatedir}     /var

RPM directory macros

%{_topdir}            %{_usrsrc}/packages
%{_builddir}          %{_topdir}/BUILD
%{_rpmdir}            %{_topdir}/RPMS
%{_sourcedir}         %{_topdir}/SOURCES
%{_specdir}           %{_topdir}/SPECS
%{_srcrpmdir}         %{_topdir}/SRPMS

Build flags macros

# Note: fedora uses a %{_optflags}
%{optflags}          -O2 -g -m64 -fmessage-length=0 -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables

Other macros

%{_var}               /var
%{_tmppath}           %{_var}/tmp
%{_usr}               /usr
%{_usrsrc}            %{_usr}/src
# Note: Fedora uses a %{_docdir}
%{_defaultdocdir}     %{_usr}/share/doc/packages
*  RPM Macros for Java packages

Reference

Here are macros from other distributions to aid you in package conversion: