Makefile始终运行目标
问题描述:
我可能会错过这个Makefile非常明显的东西:
I may miss something very obvious with this Makefile:
convert: devel/bar
touch convert
init: devel/foo
echo 'init'
devel/foo:
mkdir -p devel
touch devel/foo
devel/bar: init
touch devel/bar
当我运行它时,总是会调用devel/bar
目标.我希望它调用convert
,检查文件devel/bar
,并且仅在找不到该文件的情况下才调用该目标.如果删除对init
的依赖,一切都会按预期进行.我在做什么错了?
When I run it, the devel/bar
target always gets called. I'd expect it to call convert
, check the file devel/bar
, and call that target only if that file is not found. If I remove its dependency on init
, everything works as I would expect. What am I doing wrong?
答
您没有创建名为init
的文件,因此init
总是过时的.因此,所有依赖它的东西总是过时的.
You're not creating a file called init
, so init
is always out-of-date. Therefore everything that depends on it is always out-of-date.