简体   繁体   English

以文本形式获取makefile命令评估

[英]Get makefile command evaluation as text

I have a following problem. 我有以下问题。 Basically I have a really long Makefile which calls many complex commands. 基本上,我有一个很长的Makefile,它会调用许多复杂的命令。 It uses environment variables, methods included from other Makefiles, really hard to read bash magic. 它使用环境变量,其他Makefile文件中包含的方法,真的很难阅读bash魔术。 So for example I have a command (cannot put the real one here, sorry) like this: 例如,我有一个命令(不能在此处输入真实的命令),例如:

foo ${bar} (sort ...) [...]

I am analysing this Makefile and I want to know what exactly gets executed when I run it. 我正在分析此Makefile,我想知道运行它时究竟执行了什么。 The thing I want to achieve is this command in a text representation, so all the stuff gets evaluated and I can actually see what exactly is being executed like gcc something -Isomethingmore (so the command foo ${bar} (sort ...) [...] actually means gcc something -Isomethingmore ) etc. Is there a way to do that? 我要实现的是该命令以文本表示形式,因此所有内容都经过评估,我可以实际看到确切执行的内容,例如gcc something -Isomethingmore (因此命令foo ${bar} (sort ...) [...]实际上是gcc something -Isomethingmore意思gcc something -Isomethingmore )等。有没有办法做到这一点? So I can for example echo it and see what am I dealing with? 因此,例如,我可以回显它,看看我在处理什么?

By default make prints the recipes it executes. 默认情况下,make打印执行的配方。 So you should see the exact command in the standard output. 因此,您应该在标准输出中看到确切的命令。 Use grep maybe to isolate the one you are interested in. If make does not print the recipes it may be: 使用grep可能会分离出您感兴趣的一种。如果make无法打印配方,则可能是:

  1. because the recipe is prefixed by @ , which tells make to be silent for this recipe, 因为该食谱以@开头,这表明make对此食谱保持沉默,
  2. because the Makefile contains the .SILENT special target that silences all recipes. 因为Makefile包含使所有配方.SILENT特殊目标

Remove one or the other and you should see the recipe when it is executed. 删除其中一个,执行该配方后,您应该会看到该配方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM