[Omake] The % variable

Jason Hickey jyh at cs.caltech.edu
Wed Dec 5 10:02:09 PST 2007


On Dec 5, 2007, at 9:23 AM, Aleksey Nogin wrote:

> On 04.12.2007 10:30, Alain Frisch wrote:
>
>> ComputeCFLAGS(file) =
>>  TAGS = $(filter %.tag, $(dependencies $(file)))
>>  echo TAGS for $(file) "///" $(TAGS) "///" %
>>  value $(CFLAGS)
>> %$(EXT_OBJ): %.c :scanner: scan-c-%.c
>>    $(CC) $(ComputeCFLAGS $@) $(PREFIXED_INCLUDES) -c $(CCOUT)$@ $<
> [...]
>> The code above does not work because the % symbol in the call to  
>> filter
>> is bound by the implicit rule. Is it the intended behavior?
>
> Alain,
>
> I'll leave it to Jason to answer your "Is it the intended behavior"  
> questions (IMHO this behavior is wrong, but I may be missing  
> something). For a workaround, you should be able to quote the %  
> symbol - e.g. $'%.tag'

It is intended, but it may or may not be wrong.  The % is really a  
variable, and it acts like one too.

    # Have to use setvar for syntactical reasons
    osh> setvar($'%', Hello)
    - : "Hello" : Sequence
    osh> echo %World
    HelloWorld

The confusing part is that it doesn't look like one.  One thing that  
might be sensible is to keep the current behavior in rule bodies, but  
require a dollar anywhere else.  So, if you really wanted it in  
ComputeCFLAGS, you could get it, but you would have to write $%.

Jason

--
Jason Hickey                  http://www.cs.caltech.edu/~jyh
Caltech Computer Science      Tel: 626-395-6568 FAX: 626-792-4257





More information about the Omake mailing list