Description of Problem: The arch-specific macros files specify %optflags and then use it in the various build-related macros. Unfortunately this arrangement means it is impossible to override the %optflags without duplicating most of the contents of the arch-specific macros file. While I don't mind having to know about what's in those files, I would rather not have to do this, as it means I need to rebuild my .rpmmacros-%{_target} every time there is a minor change in e.g. the %configure macro ... and all I want to do is override the compile flags (to add -W -Wall to my personal builds, as it happens, but I assume there are other applications :o) I can fix this (sort of) by changing the %optflags definitions in the macros files to include another macro and define that in my personal rpmmacros ... but there's still a "what order do I include these files in" problem. So it's not really a solution. Is it possible to have some of the expansion done later, or perhaps change some of the macro definitions to "unless this is already defined ..." ?
How about defining the macro on the command line: --define 'optflags %{expand:%%global optflags %{optflags} -W -Wall}' This will append "-W -Wall" to the current value on 1st expansion of %optflags. And, to eliminate unnecssary typing, you can add your own rpmbuild extension to rpm by adding to /etc/popt rpmb alias --Wall <glop above> rpmbuild alias --Wall <glop above> (Note: two entries to guarantee match on argv[0]) to be used as rpmbuild -ba --Wall <specfile> HTH (untested, reopen this bug if the above doesn't work)
Thanks, I'll try that when I get home. One question though: you said "first expansion" ... optflags is expanded multiple times and then redefined (once in rpmrc, once in macros, once in %{arch}-redhat-linux/macros).
The 1st expansion will redefine the "%optflags" object being expanded on the fly.
The other piece that may be missing is that CLI macros are always added after everything else, 1st expansion appends -W -Wall, and away we go.
Won't that mean it's added after e.g. %configure etc. get expanded (with the value of optargs from the macros file)? I'll go try it anyway. On my way home now.
OK, that works -- thanks. Apologies for questioning you; I spent a while experimenting last night and it looked as though expansion was being done fairly early on in the process. A couple of things that didn't work were: defining %optflags in .rpmmacros defining %optflags in .rpmmacros-%{target} and modifying .rpmrc to look at that The only thing that worked was to define %optflags and then paste the rest of /usr/lib/rpm/%{target}/macros in after it, hence my assumption that expansion was always immediate. Interestingly so did putting "optflags: i386 -W -Wall -O2 -march=i386 -mcpu=686" in .rpmrc, as long as I put it *after* the "include: /usr/lib/rpm/rpmrc" (I'd tried something similar earlier and it failed because I'd put it at the start of .rpmrc, before the include). However the header and region stuff sounds even more hairy than the macro and command line stuff, so I'll leave you to it. Thanks for your help.
Yeah %optflags is broke ATM, only the side effect of the optflags: yadda yadda in the ageless and decrepit rpmrc line works. One of these years I'll succeed in eliminating rpmrc configuration, sigh.
What might work (but would probably break any kind of backward compatability) would be to process the command line first, then the target-specific macro file, then the general one, *then* rpmrc; and make the *first* definition stick, not the last one. Kinda like ssh config file works. (I know it's not going to happen, just speculating).