[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Macros get expanded in comments..



In regard to: Macros get expanded in comments.., Mike A. Harris said (at...:

>I have a spec file which I have a construct like:
>
>%define this	that
>#%define this    somethingelse
>
>After a bit of hair pulling I found that the commented out macro
>definition is acting as if not commented out after all.  Is this
>a bug or a feature?  If the latter, how can I get the desired
>operation?

It's not a bug.  See past discussion on this list regarding this issue.
%define is context free, unlike what you may be used to with cpp et. al.
Jeff Johnson (RPM grand-poobah) has stated that when more pressing issues
with RPM are resolved, he plans to spend some more time on the macro system.

It's not what you expected, and you're not alone in this regard.  :-)
Jeff has it on his "to look at" list.  I think his motto is "quality
patches graciously accepted".   ;-)

>In english, what I'm _really_ wanting to do is:
>
>if( build_os <= Red Hat 6.2 )
>	%define this	that
>else
>	%define this	somethingelse
>fi

You don't say what version of RPM you're using, but I'll assume 3.0.4 or
later.  Is this package one where you want to be able to distribute
the source RPMs too, so that anyone can build your package from the SRPMs,
or is this mainly for in-house builds on different versions of the OS?

If it's just in-house, you could stick the

	%define this that

in a separate macros file that would be sourced at build time.  Then
it just becomes a matter of keeping different in-house macro files for
your different build machines.

If you want to not depend on external files (which other sites wouldn't
have, so they would be unable to trivially build RPMs from your SRPMs)
you need to read up on the rpm-3.0.N/doc/manual/macros, specifically
the part about shell expansion.  If you can determine if it is RH 6.2 or
less through one (possibly complex) line of shell code, you can %define
"this" via the shell expansion.

I'm not an RPM 3.x (or 4.x) expert, so I'm being a little vague (and I
may have already generated incorrect information despite staying away
from specifics -- if so, sorry).  There is a way to do what you want, though.
Hopefully you have enough info to proceed.

Tim
-- 
Tim Mooney                              mooney@dogbert.cc.ndsu.NoDak.edu
Information Technology Services         (701) 231-1076 (Voice)
Room 242-J1, IACC Building              (701) 231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []