From Fedora Project Wiki

mNo edit summary
Line 3: Line 3:
= Valid RPM Macros =
= Valid RPM Macros =


Here are the definitions for some common specfile macros as they are defined on Fedora Core 3 (rpm-4.3.2-21). For definitions of more macros, examine the output of "<code>rpm --showrc</code>". To see the expanded definition of a macro use the command "<code>rpm --eval '</code>'''%{macro}'''<code>'</code>".  Note that neither command will take into account macros defined inside specfiles, but both will take into account macros defined in your <code>~/.rpmmacros</code> file and macros defined on the command line.
Here are the definitions for some common specfile macros as they are defined on Fedora Core 11 (rpm-4.7.0-1.fc11). For definitions of more macros, examine the output of "<code>rpm --showrc</code>". To see the expanded definition of a macro use the command "<code>rpm --eval '</code>'''%{macro}'''<code>'</code>".  Note that neither command will take into account macros defined inside specfiles, but both will take into account macros defined in your <code>~/.rpmmacros</code> file and macros defined on the command line.


Keep in mind that some of these macros may evaluate differently on older Fedora or EPEL releases.


=== Macros mimicking autoconf variables ===
=== Macros mimicking autoconf variables ===
<pre>
<pre>
%{_sysconfdir}        /etc
%{_sysconfdir}        /etc
%{_initddir}          %{_sysconfdir}/rc.d/init.d
%{_prefix}            /usr
%{_prefix}            /usr
%{_exec_prefix}      %{_prefix}
%{_exec_prefix}      %{_prefix}
Line 17: Line 17:
%{_libexecdir}        %{_exec_prefix}/libexec
%{_libexecdir}        %{_exec_prefix}/libexec
%{_sbindir}          %{_exec_prefix}/sbin
%{_sbindir}          %{_exec_prefix}/sbin
%{_sharedstatedir}    %{_prefix}/com
%{_sharedstatedir}    /var/lib
%{_datadir}          %{_prefix}/share
%{_datadir}          %{_prefix}/share
%{_includedir}        %{_prefix}/include
%{_includedir}        %{_prefix}/include
Line 24: Line 24:
%{_mandir}            /usr/share/man
%{_mandir}            /usr/share/man
%{_localstatedir}    /var
%{_localstatedir}    /var
%{_initddir}          %{_sysconfdir}/rc.d/init.d
</pre>
</pre>
Note: On releases older than Fedora 10 (and EPEL), <code>%{_initddir}</code> does not exist. Instead, you should use the deprecated <code>%{_initrddir}</code> macro.


=== RPM directory macros ===
=== RPM directory macros ===
<pre>
<pre>
%{_topdir}            %{_usrsrc}/redhat
%{_topdir}            %{getenv:HOME}/rpmbuild
%{_builddir}          %{_topdir}/BUILD
%{_builddir}          %{_topdir}/BUILD
%{_rpmdir}            %{_topdir}/RPMS
%{_rpmdir}            %{_topdir}/RPMS
Line 34: Line 36:
%{_specdir}          %{_topdir}/SPECS
%{_specdir}          %{_topdir}/SPECS
%{_srcrpmdir}        %{_topdir}/SRPMS
%{_srcrpmdir}        %{_topdir}/SRPMS
%{_buildrootdir}      %{_topdir}/BUILDROOT
</pre>
</pre>
Note: On releases older than Fedora 10 (and EPEL), <code>%{_buildrootdir}</code> does not exist.


=== Build flags macros ===
=== Build flags macros ===
Line 57: Line 61:
* [[Extras/ReferenceMandrakeRPMMacros| Mandrake RPM Macros]]  
* [[Extras/ReferenceMandrakeRPMMacros| Mandrake RPM Macros]]  
----
----
[[Category:Extras]]

Revision as of 14:06, 20 May 2009

Valid RPM Macros

Here are the definitions for some common specfile macros as they are defined on Fedora Core 11 (rpm-4.7.0-1.fc11). 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.

Keep in mind that some of these macros may evaluate differently on older Fedora or EPEL releases.

Macros mimicking autoconf variables

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

Note: On releases older than Fedora 10 (and EPEL), %{_initddir} does not exist. Instead, you should use the deprecated %{_initrddir} macro.

RPM directory macros

%{_topdir}            %{getenv:HOME}/rpmbuild
%{_builddir}          %{_topdir}/BUILD
%{_rpmdir}            %{_topdir}/RPMS
%{_sourcedir}         %{_topdir}/SOURCES
%{_specdir}           %{_topdir}/SPECS
%{_srcrpmdir}         %{_topdir}/SRPMS
%{_buildrootdir}      %{_topdir}/BUILDROOT

Note: On releases older than Fedora 10 (and EPEL), %{_buildrootdir} does not exist.

Build flags macros

%{_global_cflags}     -O2 -g -pipe
%{_optflags}          %{__global_cflags} -m32 -march=i386 -mtune=pentium4 # if redhat-rpm-config is installed

Other macros

%{_var}               /var
%{_tmppath}           %{_var}/tmp
%{_usr}               /usr
%{_usrsrc}            %{_usr}/src
%{_docdir}            %{_datadir}/doc

Reference

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