为什么makefile目标始终运行? [英] Why a makefile target is always run?

查看:100
本文介绍了为什么makefile目标始终运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Makefile:

OUTPUT_ILA = "path/file"

OUTPUT_ILA = "path/file"

all: syn ila opt ...

$(OUTPUT_SYN): $(INPUT_SYN)
   @echo "syn"
   ...

$(OUTPUT_ILA): $(OUTPUT_SYN)
   @echo "ila"
   ...

$(OUTPUT_OPT): $(INPUT_OPT)
   @echo "opt"
   ...

syn: $(OUTPUT_SYN)
ila: $(OUTPUT_ILA)
opt: $(OUTPUT_OPT)
...

不了解为什么总是执行步骤ila.当$(OUTPUT_SYN)不变并且ila之前运行时,make仍会运行ila步骤.
预期的行为是仅在第一步更改$(OUTPUT_SYN)时才运行.如果$(OUTPUT_SYN)不变,则应跳过ila并运行opt.
如何调试和解决此问题?

Don't understand why step ila is always run. When $(OUTPUT_SYN) is unchanged and ila run before, make still runs ila step.
The expected behavior is ila to only run when, in the first step, $(OUTPUT_SYN) is changed. If $(OUTPUT_SYN) is unchanged, it shall skip ila and run opt.
How to debug and fix this?

推荐答案

由于您没有提供有关变量的值或配方的作用的任何信息,因此我们几乎无法告诉您原因.

Since you don't provide any information about what the value of the variables are, or the what the recipes do, there's little we can tell you about why.

但是,请注意,如果配方的目标不存在,则该配方将始终运行(必须这样做,因为make无法确定其是否过时).因此,如果您的$(OUTPUT_ILA)目标配方没有创建由变量OUTPUT_ILA命名的文件(无论扩展为什么),那么该配方将始终运行.

However, note that if the target of a recipe does not exist then the recipe is always run (it has to be, since make cannot determine if it's out of date or not). So, if your recipe for the $(OUTPUT_ILA) target does not create the file named by the variable OUTPUT_ILA (whatever that expands to) then this recipe will always be run.

使用另一种方法,如果您希望它能正常工作,则应确保该食谱更新了由自动变量$@指定的文件.

Put another way, you should make sure that the recipe updates the file specified by the automatic variable $@, if you want it to work properly.

这篇关于为什么makefile目标始终运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆