继续翻译
复制代码
You can also mix in functions here, as long as they are properly escaped:
main_SRCS := main.c try.c test.c
lib_SRCS := lib.c api.c
.SECONDEXPANSION:
main lib: $$(patsubst %.c,%.o,$$($$@_SRCS))
This version allows users to specify source files rather than object files, but gives the same resulting prerequisites list as the previous example.
Evaluation of automatic variables during the secondary expansion phase, especially of the target name variable `$$@', behaves similarly to evaluation within recipes. However, there are some subtle differences and "corner cases" which come into play for the different types of rule definitions that `make' understands. The subtleties of using the different automatic variables are described below.
复制代码
你也可以把函数混合在此:
main_SRCS := main.c try.c test.c
lib_SRCS := lib.c api.c
.SECONDEXPANSION:
main lib: $$(patsubst %.c,%.o,$$($$@_SRCS))
复制代码
我加段注解:
main_SRCS := main.c try.c test.c
lib_SRCS := lib.c api.c
.SECONDEXPANSION:
main lib: $$(patsubst %.c,%.o,$$($$@_SRCS))
main lib: $$(patsubst %.c, %.o, $$($$@_SRCS))转化为:
->
main lib: $(patsubst %.c, %.o, $($@_SRCS))
即:
->
main: $(patsubst %.c, %.o, $(main_SRCS))
和
lib: $(patsubst %.c, %.o, $(lib_SRCS))
也就是:
main: main.o try.o test.o
和
lib: lib.o api.o
复制代码
Evaluation of automatic variables during the secondary expansion
phase, especially of the target name variable `$$@', behaves similarly
to evaluation within recipes. However, there are some subtle
differences and "corner cases" which come into play for the different
types of rule definitions that `make' understands. The subtleties of
using the different automatic variables are described below.
在二次扩展期间,对自动变量的求值,特别是 目的名变量 $$@,和在片段中的求值是一样的。
然而,这里有一些微妙的查别,还有一些特例为不同类型的规则定义来进行了特殊处理。
此种使用不同的自动变量的细微之处,将在如下描述。
后文待续
本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/archive/2012/09/17/2688603.html,如需转载请自行联系原作者