Overriding RPM macros

Jos Vos jos at xos.nl
Sun May 2 13:01:44 UTC 2010

On Sun, May 02, 2010 at 06:13:51PM +0530, Shakthi Kannan wrote:

> I tried to set the following in ~/.rpmmacros:
>   %__cc         /path/to/compiler-gcc
> and when I did rpmbuild -bc hello.spec, it shows:
>   $ rpmbuild --showrc | grep cc
>       rpmlib(ConcurrentAccess) = 4.1-1
>   -14: __cc        /path/to/compiler-gcc
>   -14: __cpp     gcc -E
> But, when I use rpmbuild -bc hello.spec, the configure script still
> takes cc as /usr/bin/gcc from /usr/lib/rpm/macros. Why is it so?
> Only when I do something like, CC=/path/to/compiler-gcc rpmbuild -bc
> hello.spec, does the new CC used for building the package. Why isn't
> ~/.rpmmacros overriding the default macros?
> Appreciate any inputs,

Why do you think the configure script uses the %__cc macro?
Look how %configure is defined (with macros substitued):

   rpm --eval '%configure'

If your path is not listed there, it will not be used, as the
configure script internally will only refer to environment

Changing the spec file so that you set

   export CC=/path/to/compiler-gcc

at the beginning of %build might do what you want.

--    Jos Vos <jos at xos.nl>
--    X/OS Experts in Open Systems BV   |   Phone: +31 20 6938364
--    Amsterdam, The Netherlands        |     Fax: +31 20 6948204

More information about the devel mailing list