here are the rules for when elements of a makefile are expanded:
1) For variable assignments, the lefthand side of the assignment is always expanded immediately when make reads the line during its first phase.
2) The righthand side of = and ?= are deferred until they are used in the second phase.
3) The righthand side of := is expanded immediately.
4) The righthand side of += is expanded immediately if the lefthand side was originally defined as a simple variable. Otherwise, its evaluation is deferred.
5)For macro definitions (those using define), the macro variable name is immediately expanded and the body of the macro is deferred until used.
6) For rules, the targets and prerequisites are always immediately expanded while the commands are always deferred.
Definition Expansion of a Expansion of b
a = b Immediate Deferred
a ?= b Immediate Deferred
a := b Immediate Immediate
a += b Immediate Deferred or immediate
define a Immediate
b...
b...
b...
endef
阅读(1028) | 评论(0) | 转发(0) |