[Rpm-maint] Fwd: Looking for documentation on rpm macros and some suggestions

Mark Hatle mark.hatle at windriver.com
Sat Mar 14 14:15:15 UTC 2009


Why don't you just use:

%build
%configure --enable-unicode-properties --enable-pcregrep-libz 
--enable-pcregrep-libbz2 --disable-pcretest-libreadline

The thing you need to remember about rpm "macros" is that they're really a cross 
between macros and defines.  In most caseses they are simply defines, it's a 
simple search/replace type operation when the shell scripts are generated for 
building.

The only time they really operate like macros are when there are certain 
semantics like %(...), or %{?...}, or %{eval:...}

This looks to me like you are trying to come up with a solution to make your 
packages look more uniform, while adding complexing and incompatibility to the 
macros.  I've done this before, and it was one of the greatest mistakes you can 
make when working with RPM.

Use the macros your distribution provides, when you deviate or make changes from 
that then maintenance becomes a huge burden.  While it might save you 10 minutes 
today, it'll cost you an hour when you upgrade.

--Mark

Ritesh Sood wrote:
> I had sent the following mail to rpm-list at lists.rpm.org 
> <mailto:rpm-list at lists.rpm.org>, but haven't received a response. 
> Perhaps rpm-maint is a more appropriate forum for my queries. 
> 
>> 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, but I'm not sure of the syntax):
>>
>> ----------- start .rpmmacros ------------------------
>> %packager Ritesh Sood <riteshsood at gmail.com <mailto: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) ...
>> %{?pkg_config_flags}
>> ----------- 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
>> --disable-pcretest-libreadline
>>
>> 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, 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
>>     http://rpm.org/wiki/Docs#PackagerDocumentation
>> nor in the books
>> http://www.rpm.org/max-rpm-snapshot/
>> http://docs.fedoraproject.org/drafts/rpm-guide-en/
>> 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 ------------------------
>> %build
>> %{expand: %%define optflags %{optflags} -fPIC}
>> ----------- end code ------------------------
>> So just to add the ``-fPIC" flag, poor guy has to jump through all 
>> those hoops. 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 CXXFLAGS ; \
>> ----------- 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.
>>
>> Ritesh
>>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Rpm-maint mailing list
> Rpm-maint at lists.rpm.org
> http://lists.rpm.org/mailman/listinfo/rpm-maint



More information about the Rpm-maint mailing list