~~end~~
Make的第一遍会收集所有需要make的目标,
当以下Makefile中include的文件不存在时,则直接跳过;
收集完目标后,进行make动作,更新目标,在更新过程中产生了被include的文件depend,
但此时depend的内容不会被放入make的目标,可以理解为第一遍收集已经完毕。
只有当再次运行make时,depend的内容才会起作用。
$ touch a.c
$ touch a.h // now a.h is newer than a.c
$ ls
a.c a.h Makefile
$ cat Makefile
all: dep
@echo ‘all:dep’
.PHONY : dep
dep : a.c
echo -e "a.c:a.hnt @echo ttt" > depend
ifneq ($(wildcard depend),)
include depend
endif
$ make –debug
…
Reading makefiles…
Updating goal targets….
File all' does not exist.<br />File
dep’ does not exist.
Must remake target dep'.<br />echo -e "a.c:a.hnt @echo ttt" > depend<br />Successfully remade target file
dep’.
Must remake target all'.<br />all:dep<br />Successfully remade target file
all’.
$ make –debug // make second time
Reading makefiles…
Updating goal targets….
File all' does not exist.<br />File
dep’ does not exist.
Prerequisite a.h' is newer than target
a.c’.
Must remake target a.c'.<br />ttt<br />Successfully remade target file
a.c’.
Must remake target dep'.<br />echo -e "a.c:a.hnt @echo ttt" > depend<br />Successfully remade target file
dep’.
Must remake target all'.<br />all:dep<br />Successfully remade target file
all’.
$ cat depend
a.c:a.h
@echo ttt