help-make
[Top][All Lists]
Advanced

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

Re: Referencing awk field in rules put out by eval function


From: Paul Smith
Subject: Re: Referencing awk field in rules put out by eval function
Date: Wed, 06 Feb 2008 15:56:55 -0500

On Wed, 2008-02-06 at 12:47 -0800, Huan-Chih Tsai wrote:
> define TEST_RULE
> .PHONY: $(1)
> $(1):
>          awk '{if (NF > 1) {print $$1 " " $$2} }' < Makefile
> endef

Sorry, but you have to double-escape the "$" in the rule.

When you invoke "call", it will expand the value (it has to, to replace
the arguments like $(1)!) so that undoes one level of $ escaping.  Thus
when your rule is defined it will be:

        test:
                awk '{if (NF > 1) {print $1 " " $2} }' < Makefile

and when make expands it, the $1 and $2 will drop out.  You can use
"make -p" to see this.

You need:

        define TEST_RULE
        .PHONY: $(1)
        $(1):
                 awk '{if (NF > 1) {print $$$$1 " " $$$$2} }' < Makefile
        endef

-- 
-----------------------------------------------------------------------------
 Paul D. Smith <address@hidden>                 http://make.mad-scientist.us
 "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]