[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Target-specific Variable Values
From: |
Sam Ravnborg |
Subject: |
Re: Target-specific Variable Values |
Date: |
Sat, 11 Dec 2010 15:29:06 +0100 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
On Sat, Dec 11, 2010 at 05:16:34PM +0330, ali hagigat wrote:
> Dear Eli,
> Thank you. It worked. Another question is about the extract of make manual:
> --------------------------------------
> 5.1 Recipe Syntax
> A variable definition in a “rule context” which is indented by a tab
> as the first character on the line, will be considered part of a
> recipe, not a make variable definition, and passed
> to the shell.
> --------------------------------------
> I have the following makefile:
> all: file1
> file1:
> var1=wwwww;echo $var1
> @echo lllllll
>
> The result was:
> var1=wwwww;echo ar1
> ar1
> lllllll
>
> Why var1 can not be printed correctly? Does make considers two
> different shells for (var1=wwwww) and (echo $var1)?
> How can i have a variable assignment for each command of a recipe?
If you read the manual you will lear thet make expand variables.
So your receipe could also be written as:
var1=wwwww; echo $(v)ar1
Notice that make evaluate the variable and it is empty.
Please try to experiment with the different ways to
reference a variable to get an understanding.
As you seems to want to pass "$" to the shell then you need to escape it.
So your receipe should be written as:
var1=wwwww; echo $$var1
Next time you ask a new question then please:
1) spend some time to try out different alternatives
2) start a new thread for a new question (if 1) did not give you enough insight)
Sam