[Gnumake] Organizing my knowledge about 'gnumake'

Tools 2013.07.11 08:51

Commands in Rule is called after entire 'make' is parsed.

Ex.

A:=a
B:=a

define prv
    @echo $(1) : $(A) / $(B)
endef

a: b
	$(call prv,[a])

B:=b

b:
	$(call prv,[b])

B:=c


Above 'make' gives following results

[b] : a / c
[a] : a / c

That is, commands are executed after executing last 'make' statement 'B:=c'.


But, assignment in dependency phase is something special.

In this case, assigned value is effective only in that target and it's dependents in rule chain.

And, after checking all dependencies, command is executed.

Ex.


Above 'make' gives following results

A:=a
B:=a

define prv
    @echo $(1) : $(A) / $(B)
endef

a: d b e
	$(call prv,[a])

B:=b

b: B:=x
b: c
	$(call prv,[b])
b: B:=y

c:
	$(call prv,[c])

d:
	$(call prv,[d])

e:
	$(call prv,[e])

B:=c
Above 'make' gives following results
[d] : a / c
[c] : a / y
[b] : a / y
[e] : a / c
[a] : a / c

One interesting point here is, dependency is checked in order. So, for target 'a', dependency is checked  by 'd' -> 'b' -> 'e' order.

[ will be updated time to time. ]

신고
Trackback 0 : Comment 0

티스토리 툴바