Looking for documentation on rpm macros and some suggestions

Ritesh Sood baralachala at gmail.com
Fri Mar 13 10:00:38 UTC 2009

Hi all,

I'm not a regular rpm builder, but have the need to build some at the  
moment. I've been successful in building the few rpm's  that I need  
and now want to fine tune the process.

Please take a look at my .rpmmacros below. In particular, the addition  
to the %configure macro in the last line (which is more like what I  
want to do, am not sure of the syntax):

----------- start .rpmmacros ------------------------
%packager	Ritesh Sood <riteshsood at gmail.com>
%vendor       	Dept. of ECE, UC Davis (Internal Use)

%_topdir       	%(echo $HOME)/ECESysAdmin/Syslog-ng/RPM-Build

%configure \
   CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; \
   CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \
   ./configure --host=%{_host} --build=%{_build} \\\
         ... (original code from /usr/lib/rpm/macros) ...
----------- end .rpmmacros ------------------------

The idea being that if I want to build the package ``pcre-ece" which  
requires configure time flags, the spec file would be something like

----------- start pcre-ece.spec ------------------------
%define name 		pcre-ece
%define orig_name	pcre
%define version 	7.8
%define release 	1

%define _prefix 	/usr/local
%define _docdir 	%{_datadir}/doc/%{orig_name}
%define pkg_config_flags       --enable-unicode-properties --enable- 
pcregrep-libz --enable-pcregrep-libbz2

Summary: 	Perl-compatible regular expression library
Name: 		%{name}
Version: 	%{version}
Release: 	%{release}
Source: 	%{orig_name}-%{version}.tar.bz2
URL: 		http://www.pcre.org/
License: 	BSD
Group: 		System Environment/Libraries
BuildRoot: 	%{_builddir}/%{orig_name}-root
Prereq: 	/sbin/ldconfig
BuildPrereq: 	sed
----------- end pcre-ece.spec ------------------------

Coming back to ``%{?pkg_config_flags}" in .rpmmacros above, the idea  
being that if the spec file defines ``pkg_config_flags", then it would  
be appended to the default expansion of the ``configure" macro; if  
not, nothing would be appended. The ``?" in the above is a conjectured  
syntax to achieve what i've stated above.

I'm not able to find good documentation on the syntax and rules of  
these macros (i'm familiar with those of ``make"). Neither at
nor in the books
Any help in finding documentation is much appreciated.

Secondly, it would be good to have the facility to append per-package  
flags to other macros. I found the following in one of Suse linux's  
RPM spec file
----------- start code ------------------------
%{expand: %%define optflags %{optflags} -fPIC}
----------- end code ------------------------
So just to add the ``-fPIC" flag, poor guy has to write all that code.  
How about something like the following appearing in the ``configure"  
macro instead:
----------- start code ------------------------
CFLAGS="${CFLAGS:-%optflags:-%{?pkg_cflags}}" ; export CFLAGS ; \
CXXFLAGS="${CXXFLAGS:-%optflags:-%{?pkg_cxxflags}}" ; export  
----------- end code ------------------------
and while we're at it, might as well add
----------- start code ------------------------
LDFLAGS="${LDFLAGS:-%{?pkg_ldflags}}" ; export LDFLAGS ; \
----------- end code ------------------------
Again, the syntax is my guess as to what it might look like, but you  
get the idea.

Looking forward to feedback on the above suggestions.


More information about the Rpm-list mailing list