2008-03-02

读书笔记: 跟我一起写 Makefile

跟我一起写 Makefile
作者:陈皓
来源:http://blog.csdn.net/haoel
http://blog.csdn.net/haoel/archive/2004/02/24/2886.aspx
...
http://blog.csdn.net/haoel/archive/2004/02/24/2899.aspx

html: http://bbs.chinaunix.net/viewthread.php?tid=408225
pdf: http://www.ccrun.com/view.asp?id=123


Notes & Errata for the pdf version:
(manual below refers to GNU make manual)

pp.9 "lable" 应为 "label". (两处)

pp.16 "和其他版本 make 兼容的相关命令是 sinclude", see also manual-3.3 "For compatibility with some other make implementations, sinclude is another name for -include"

pp.17 "如果生成" 应为 "如何生成", see also manual-4.1 "How to update the file foo.o"

pp.18 "通符" 应为 "通配符"

pp.23 关于静态模式的表述, see also manual-4.12.1, "Each target specified must match the target pattern; a warning is issued for each target that does not."

pp.23 "过滤 $filter 集", see also manual-4.12.1 "you can use the filter function to remove nonmatching file names", 以及 manual-8.2 "do match any of the pattern words"

pp.25 "set -e": exist immediately if a simple command exists with non-zero status (error), see also manual-4.14

pp.25 "sed .." 的作用: a.o -> a.o a.d; 这里$*是makefile里的变量, 即filename.c中的filename

pp.26 关于命令执行, see also manual-5.3 "The commands are executed by invoking a new subshell for each command line."

pp.27 关于 shell 的搜索, see also manual-5.3.1

pp.30 "第一个命令是运行 Yacc 程序", see also manual-5.8 "The first command in this example runs Yacc on the first prerequisite of whichever rule uses the canned sequence"

pp.31 引用变量时, 除非变量名仅含一个字符, 否则必须带括号 $(var) or ${var}, 参见 manual-6.1 "A dollar sign followed by a character other than a dollar sign, open-parenthesis or open-brace treats that single character as the variable name."

pp.31 输入"$"字符需用"$$"代替, "\$"是不work的;单引号、双引号并不影响makefile的变量扩展

pp.34 "变量高级用法" 第一小节, see also manual-6.3.1 "Substitution References", 这里介绍的两种"变量替换"都是函数 patsubst 的简写, 并不是"静态模式"

pp.39 关于环境变量的影响, see also manual-6.9

pp.39 "不用" 应为 "不同"

pp.39 "我样" 应为 "我们"

pp.43 "注释符 # 同样也是安全的", see also manual-7.2 "A comment starting with `#' may appear at the end of the line."

pp.45 "% 表示任意长度的字串", see also manual-8.2 "Here pattern may contain a `%' which acts as a wildcard, matching any number of any characters within a word."

pp.45 "有些类似", see also manual-8.2 "Substitution references are a simpler way to get the effect of the patsubst function"

pp.45 "相当于" 应为 "等价于", see also manual-8.2 "is equivalent to" (两处)

pp.45 关于 patsubst 的描述, see also manual-8.2 "The second shorthand simplifies one of the most common uses of patsubst: replacing the suffix at the end of file names."

pp.46 关于 filter 和 filter-out 的描述, see also manual-8.2

pp.48 "反斜线" 应为 "斜线", ie. slash not backslash (三处, 48-2, 49-1)

pp.49 suffix 和 basename 中关于 "前缀" 和 "后缀" 的描述, see also manual-8.3 "If the file name contains a period, the suffix is everything starting with the last period. Periods in the directory part are ignored."

pp.49 关于 addsuffix 和 addprefix 的描述, see also manual-8.3 "The argument names is regarded as a series of names, separated by whitespace; suffix is used as a unit."

pp.51 "参数的次序是可以自定义的", see also manual-8.6 "any reference to $(1) in the value of variable will resolve to the first param in the invocation of call"

pp.53 "它和反引号是相同的功能", see also manual-8.11 "The shell function performs the same function that backquotes perform in most shells."

pp.53 "error 函数不会在一被使用就会产生错误信息", see also manual-8.12 "Note that the error is generated whenever this function is evaluated."

pp.55 "命令行是" 应为 "命令行上"

pp.57 "-v": --version, Print the version of the make program plus a copyright, a list of authors, and a notice that there is no warranty; then exit. see also manual-9.7

pp.58 "——debug" 应为 "--debug"

pp.58 "所以的隐含规则" 应为 "所有隐含规则"

pp.62 "默认后缀列表"不全, see also manual-10.2

pp.63 C++这里缺少.cpp

pp.68 "有一点需要注意的是,"%"的展开发生在变量和函数的展开之后,变量和函数的展开发生在make载入Makefile时,而模式规则中的"%"则发生在运行时", see also manual-10.5, "Note that expansion using `%' in pattern rules occurs after any variable or function expansions, which take place when the makefile is read."

pp.69 "%c" 应为 "%.c"

pp.69 "这条规则告诉make把所有的[.y]文件都以"bison -d .y"执行,然后生成".tab.c"和".tab.h"文件。", see also manual-10.5.2 "This tells make that the command `bison -d x.y' will make both x.tab.c and x.tab.h."

pp.70 "仅当目标是函数库文件中,表示规则中的目标成员名。", see also manual-10.5.3 "The target member name, when the target is an archive member."

pp.72 "茎", see also manual-10.5.4 "stem"

pp.74 "清楚" 应为 "清除"

pp.74 "3、如果在模式规则列表中有匹配所有文件的模式,如"%",那么从列表中移除其它的模式。", see also manual-10.8 "If any rule in that list is not a match-anything rule, then remove all nonterminal match-anything rules from the list." (confusion)

pp.74 "第一个" 应为 "每一个", see also manual-10.8 (两处)

pp.74 "斜框" 应为 "斜线", 即 "slash", see also manual-10.8

pp.74 "理当存在", see also manual-10.8 "ought to exist"

pp.75 "7、如果没有隐含规则可以使用,查看".DEFAULT"规则,如果有,采用,把".DEFAULT"的命令给T使用。", see also manual-10.8 "If no implicit rule applies, the rule for .DEFAULT, if any, applies. In that case, give t the same commands that .DEFAULT has. Otherwise, there are no commands for t.“

pp.75 "shell的文件通配符", see also manual-11.1 "shell-style wildcards"

pp.78 "我都欢" 应为 "我都喜欢" ^_^

No comments: