摘要: 上例子:all:gao @echo "final".DEFAULT: @echo "In default" 由于 gao 是一个前提条件,但是 makefile中没有一个名字为 gao的目的。所以符合 .DEFAULT 目的的执行条件。故执行结果为:In defaultfinal完毕 阅读全文
posted @ 2012-09-20 17:36 健哥的数据花园 阅读(3740) 评论(0) 推荐(0) 编辑
摘要: 继续翻译4.9 Special Built-in Target Names=================================Certain names have special meanings if they appear as targets.`.PHONY' The prerequisites of the special target `.PHONY' are considered to be phony targets. When it is time to consider such a target, `make' will run it. 阅读全文
posted @ 2012-09-20 17:08 健哥的数据花园 阅读(290) 评论(0) 推荐(0) 编辑
摘要: 看例子:LIBS=gao.oall: $(LIBS) @echo "final".c.o: gcc -o $@ $< echo "in .c.o rule"执行 结果:gcc -o gao.o gao.cin .c.o rulefinal注意其中的 .c.o ,其实是 和 %o:%c 等价。是一个旧格式。所以 $@ 对应了 gao.o ,$< 对应了 gao.c ,不要弄反了。 阅读全文
posted @ 2012-09-20 17:01 健哥的数据花园 阅读(7476) 评论(0) 推荐(0) 编辑
摘要: 继续翻译4.8 Empty Target Files to Record Events=======================================The "empty target" is a variant of the phony target; it is used to holdrecipes for an action that you request explicitly from time to time.Unlike a phony target, this target file can really exist; but the fil 阅读全文
posted @ 2012-09-20 16:05 健哥的数据花园 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 继续翻译4.7 Rules without Recipes or Prerequisites==========================================If a rule has no prerequisites or recipe, and the target of the rule isa nonexistent file, then `make' imagines this target to have beenupdated whenever its rule is run. This implies that all targetsdepending 阅读全文
posted @ 2012-09-20 15:44 健哥的数据花园 阅读(240) 评论(0) 推荐(0) 编辑
摘要: 继续翻译Now you can say just `make' to remake all three programs, or specify asarguments the ones to remake (as in `make prog1 prog3'). Phoniness isnot inherited: the prerequisites of a phony target are not themselvesphony, unless explicitly declared to be so. When one phony target is a prerequi 阅读全文
posted @ 2012-09-20 15:29 健哥的数据花园 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 继续翻译 A phony target should not be a prerequisite of a real target file;if it is, its recipe will be run every time `make' goes to update that file. As long as a phony target is never a prerequisite of a real target, the phony target recipe will be executed only when the phony target is a specifi 阅读全文
posted @ 2012-09-20 15:13 健哥的数据花园 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 继续翻译 By declaring the subdirectories as phony targets (you must do this asthe subdirectory obviously always exists; otherwise it won't be built)you can remove these problems: SUBDIRS = foo bar baz .PHONY: subdirs $(SUBDIRS) subdirs: $(SUBDIRS) $(SUBDIRS): $(MAKE) -C $@ ... 阅读全文
posted @ 2012-09-20 14:38 健哥的数据花园 阅读(248) 评论(0) 推荐(0) 编辑
摘要: 上例子主 Makefile内容:SUBDIRS=foo bar bazsubdirs: for dir in $(SUBDIRS); do\ $(MAKE) -C $$dir; \ done当前目录下各个子目录的Makfile内容:./foo/Makefile:foo: @echo "foo..."./bar/Makefile:bar: @echo "bar..."./baz/Makefile:baz: @echo "baz..."执行结果:for dir in foo bar baz;do\ make -C $dir; \donem 阅读全文
posted @ 2012-09-20 14:24 健哥的数据花园 阅读(8607) 评论(0) 推荐(0) 编辑
摘要: 上例子SUBDIRS=foo bar bazsubdir: for dir in $(SUBDIRS); do \ @echo $$dir; \ done执行结果:for dir in foo bar baz ; do @echo $dir;donefoobarbaz 阅读全文
posted @ 2012-09-20 13:55 健哥的数据花园 阅读(2391) 评论(0) 推荐(0) 编辑
摘要: 返回:Linux/Unix 索引页 上例子 for i in f1 f2 f3; do @echo $i; done 执行结果: f1 f2 f3 但是,请注意:如果是在makefile 中写,要写成这个样子: all: for i in f1 f2 f3; do\ @echo $$i; \ don 阅读全文
posted @ 2012-09-20 13:40 健哥的数据花园 阅读(491) 评论(0) 推荐(0) 编辑
摘要: 继续翻译 Thus, you first write the line that states that `clean' is a phony target, then you write the rule, like this: .PHONY: clean clean: rm *.o temp Another example of the usefulness of phony targets is in conjunction with recursive invocations of `make' (for more information... 阅读全文
posted @ 2012-09-20 13:24 健哥的数据花园 阅读(360) 评论(0) 推荐(0) 编辑
摘要: 继续翻译 The phony target will cease to work if anything ever does create afile named `clean' in this directory. Since it has no prerequisites,the file `clean' would inevitably be considered up to date, and itsrecipe would not be executed. To avoid this problem, you can explicitlydeclare the tar 阅读全文
posted @ 2012-09-20 10:02 健哥的数据花园 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 继续翻译4.6 Phony Targets================= A phony target is one that is not really the name of a file; rather it is just a name for a recipe to be executed when you make an explicit request. There are two reasons to use a phony target: to avoid a conflict with a file of the same name, and to improve... 阅读全文
posted @ 2012-09-20 09:46 健哥的数据花园 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 继续翻译 Although the default set of files to be searched for is `libNAME.so'and `libNAME.a', this is customizable via the `.LIBPATTERNS' variable.Each word in the value of this variable is a pattern string. When aprerequisite like `-lNAME' is seen, `make' will replace the percent in 阅读全文
posted @ 2012-09-20 09:26 健哥的数据花园 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 继续翻译4.5.6 Directory Search for Link Libraries ----------------------------------------- Directory search applies in a special way to libraries used with the linker. This special feature comes into play when you write a prerequisi... 阅读全文
posted @ 2012-09-20 08:58 健哥的数据花园 阅读(306) 评论(0) 推荐(0) 编辑
摘要: 继续翻译4.5.5 Directory Search and Implicit Rules-----------------------------------------The search through the directories specified in `VPATH' or with `vpath' also happens during consideration of implicit rules (*note Using Implicit Rules: Implicit Rules.). For example, when a file `foo.o' 阅读全文
posted @ 2012-09-20 08:26 健哥的数据花园 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 继续翻译4.5.4 Writing Recipes with Directory Search-------------------------------------------When a prerequisite is found in another directory through directorysearch, this cannot change the recipe of the rule; they will execute aswritten. Therefore, you must write the recipe with care so that itwill . 阅读全文
posted @ 2012-09-20 07:58 健哥的数据花园 阅读(260) 评论(0) 推荐(0) 编辑