摘要:
啥也别说了,上例子: 输出为: foo1 foo2 foo1.bar foo2.bar 改变为: 输出为: foo1 foo2 foo1.bar foo2.bar foo2.bar foo1.bar foo2.bar 也就是说, 对 $+而言,就是将 前提条件中的内容原样输出 对 $^ 而言,前提条 阅读全文
摘要:
Rules undergo secondary expansion in makefile order, except that the rule with the recipe is always evaluated last. The variables `$$?' and `$$*' are not available and expand to the empty string. 二次扩展遵循 makefile中的自然顺序,除了 片段中... 阅读全文
摘要:
继续翻译Secondary Expansion of Explicit Rules ------------------------------------- During the secondary expansion of explicit rules, `$$@' and `$$%' evaluate, respectively, to the file name of the target and, when the target is an ar... 阅读全文
摘要:
继续翻译 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:... 阅读全文
摘要:
继续翻译 .SECONDEXPANSION: main_OBJS := main.o try.o test.o lib_OBJS := lib.o api.o main lib: $$($$@_OBJS) Here, after the initial expansion the p... 阅读全文
摘要:
继续翻译 This is marginally more exciting, but the true power of this feature only becomes apparent when you discover that secondary expansions always take place within the scope of the automatic variables for that target. This means that you can use variables such as `$@', `$*', etc. during the 阅读全文
摘要:
继续翻译 Obviously, this is not a very interesting case since the same result could more easily have been achieved simply by having both variables appear, unescaped, in the prerequisites list. One difference becomes apparent if the variables are reset; consider this example: .SECONDEXPANSION: ... 阅读全文
摘要:
看例子:.SECONDEXPANSION:ONE=onefileTWO=twofilemyfile: $(ONE) $$(TWO) echo "myfile"onefile: echo "onefile"twofile: echo "twofile"执行结果:onefiletwofilemyfile如果把 .SECONDEXPANSION: 一行去掉:#.SECONDEXPANSION:ONE=onefileTWO=twofilemyfile: $(ONE) $$(TWO) echo "myfile"onefile 阅读全文
摘要:
继续翻译 After the first expansion phase the prerequisites list of the 'myfile' target will be `onefile' and `$(TWOVAR)'; the first (unescaped) variable reference to ONEVAR is expanded, while the second (escaped) variable reference is simply unescaped, without being recognized as a varia 阅读全文
摘要:
继续翻译 If that special target is defined then in between the two phases mentioned above, right at the end of the read-in phase, all the prerequisites of the targets defined after the special target are expanded a _second time_. In most circumstances this secondary expansion will have no effect, ... 阅读全文
摘要:
继续翻译3.8 Secondary Expansion ======================= In the previous section we learned that GNU `make' works in two distinct phases: a read-in phase and a target-update phase (*note How `make' Reads a Makefile: Reading Makefiles.... 阅读全文
摘要:
继续翻译Rule Definition --------------- A rule is always expanded the same way, regardless of the form: IMMEDIATE : IMMEDIATE ; DEFERRED DEFERRED ... 阅读全文
摘要:
继续翻译Conditional Directives ---------------------- Conditional directives are parsed immediately. This means, for example, that automatic variables cannot be used in conditional directives, as automatic variables are not set until... 阅读全文
摘要:
继续翻译Variable Assignment ------------------- Variable definitions are parsed as follows: IMMEDIATE = DEFERRED IMMEDIATE ?= DEFERRED ... 阅读全文
摘要:
继续翻译 It's important to understand this two-phase approach because it has a direct impact on how variable and function expansion happens; this is often a source of some confusion when writing makefiles. Here we will present a summary of the phases in which expansion happens for different construc 阅读全文
摘要:
继续翻译3.7 How `make' Reads a Makefile =============================== GNU `make' does its work in two distinct phases. During the first phase it reads all the makefiles, included makefiles, etc. and internalizes all the variables a... 阅读全文
摘要:
继续翻译 The way this works is that the pattern rule has a pattern of just `%', so it matches any target whatever. The rule specifies a prerequisite `force', to guarantee that the recipe will be run even if the target file already exists. We give the `force' target an empty recipe to prevent 阅读全文
摘要:
继续翻译 For example, if you have a makefile called `Makefile' that says howto make the target `foo' (and other targets), you can write a makefile called `GNUmakefile' that contains: foo: frobnicate > foo ... 阅读全文
摘要:
在对makefile进行了部分学习后,感觉到还是多看看简短的例子比较好。发现下面这个网站讲得很好:http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/hellomake.c:#include int main() { // call a function in another file myPrintHelloMake(); return(0);}hellofunc.c:#include #include void myPrintHelloMake(void) { printf("Hello makefiles!\n 阅读全文