help-make
[Top][All Lists]
Advanced

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

Re: Making rules print $


From: Paul Smith
Subject: Re: Making rules print $
Date: Wed, 15 Aug 2007 00:18:29 -0400

On Tue, 2007-08-14 at 22:59 -0500, David A. Greene wrote:
> define some_func
> 
> target: $$($(1))
>         echo '$$' > $$@
> endef
> 
> my_func = $(eval $(call some_func,$(1)))

You have to deal with escaping "$".  First, the call will evaluate
some_func, so that will remove one "level" of escaping, leaving you
with:

        target: $(xxxx)
                echo '$' > $@

Then when the command script itself is evaluated it will treat $' as a
variable reference and expand it, which causes the problem you've seen.
You need to escape the "$" here both for the call AND for the command
script eval, which means you need a double-escape, which means you need
four "$"'s:

        define some_func
        
        target: $$($(1))
                echo '$$$$' > $$@
        endef
        
        my_func = $(eval $(call some_func,$(1)))

Now after the call you have:

        target: $(xxxx)
                echo '$$' > $@

which is what you want.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

[Prev in Thread] Current Thread [Next in Thread]