version 1.174, 2010/06/06 17:28:48 |
version 1.175, 2010/06/09 16:58:22 |
|
|
.\" |
.\" |
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 |
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 |
.\" |
.\" |
.Dd June 6, 2010 |
.Dd June 9, 2010 |
.Dt MAKE 1 |
.Dt MAKE 1 |
.Os |
.Os |
.Sh NAME |
.Sh NAME |
Line 536 If the result of expanding a variable co |
|
Line 536 If the result of expanding a variable co |
|
.Pq Ql \&$ |
.Pq Ql \&$ |
the string is expanded again. |
the string is expanded again. |
.Pp |
.Pp |
Variable substitution occurs at two distinct times, depending on where |
Variable substitution occurs at three distinct times, depending on where |
the variable is being used. |
the variable is being used. |
|
.Bl -enum |
|
.It |
Variables in dependency lines are expanded as the line is read. |
Variables in dependency lines are expanded as the line is read. |
|
.It |
Variables in shell commands are expanded when the shell command is |
Variables in shell commands are expanded when the shell command is |
executed. |
executed. |
|
.It |
|
.Dq .for |
|
loop index variables are expanded on each loop iteration. |
|
Note that other variables are not expanded inside loops so |
|
the following example code: |
|
.Bd -literal -offset indent |
|
|
|
.Dv .for i in 1 2 3 |
|
a+= ${i} |
|
j= ${i} |
|
b+= ${j} |
|
.Dv .endfor |
|
|
|
all: |
|
@echo ${a} |
|
@echo ${b} |
|
|
|
.Ed |
|
will print: |
|
.Bd -literal -offset indent |
|
1 2 3 |
|
3 3 3 |
|
|
|
.Ed |
|
Because while ${a} contains |
|
.Dq 1 2 3 |
|
after the loop is executed, ${b} |
|
contains |
|
.Dq ${j} ${j} ${j} |
|
which expands to |
|
.Dq 3 3 3 |
|
since after the loop completes ${j} contains |
|
.Dq 3 . |
|
.El |
.Ss Variable classes |
.Ss Variable classes |
The four different classes of variables (in order of increasing precedence) |
The four different classes of variables (in order of increasing precedence) |
are: |
are: |