调试 GNU make
make
中是否有命令行方式来找出目标的哪些先决条件未更新?
Is there a command line way in make
to find out which of the prerequisites of a target is not updated?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
应该为您提供更多足够的信息来调试您的 makefile。
请注意:分析输出需要一些时间和精力,但将输出加载到您最喜欢的编辑器中并进行搜索将有很大帮助。
如果指定您感兴趣的特定目标,则可以大大减少调试输出量。因此,如果您只对
dodgy
目标感兴趣,而不仅仅是make -d< /code> 可能会产生一百种不同的东西,尝试一下:(
当然假设你有一个
clean
目标)。make --debug
与make -d
相同,但您也可以指定:其中标志可以是:
a
用于所有调试(与make -d
和make --debug
)。b
用于基本调试。v
用于稍微更详细的基本调试。i
用于隐式规则。j
用于调用信息。m
获取 makefile 重制期间的信息。看起来
make --debug=b
是满足您需求的最佳选择,如以下记录所示:should give you more than enough information to debug your makefile.
Be warned: it will take some time and effort to analyze the output but loading the output into your favorite editor and doing searches will assist a lot.
You can greatly reduce the amount of debugging output if you specify the specific target you're interested in. So if you're only interested in the
dodgy
target, instead of justmake -d
which may make a hundred different things, try:(assuming you have a
clean
target of course).The
make --debug
is identical tomake -d
but you can also specify:where flags can be:
a
for all debugging (same asmake -d
andmake --debug
).b
for basic debugging.v
for slightly more verbose basic debugging.i
for implicit rules.j
for invocation information.m
for information during makefile remakes.It looks like
make --debug=b
is the best option for what you need, as shown in the following transcript:您在寻找 Make 的“演练”吗?它会打印出 make 正在做什么,但实际上并不这样做,让您可以看到发生了什么。
该标志是
-n
,像make -n
一样使用它。Are you looking for Make's "dry run"? It will print out what make is doing without actually doing so, allowing you to see what happens.
The flag is
-n
, use it likemake -n
.我通常做的不是像之前的回答者所说的那样使用 -d 。
我要么:
下面是我的一些代码用于打印值:
What I usually do is not go using -d as previous answerers said.
I either:
Below is some code I'm using for printing out values:
还有带有调试器和更好的跟踪/错误输出的 GNU make:Remake
这两个虽然仍然相关,但有点旧了。
There's also GNU make with a debugger and better trace/error output: Remake
Both of these, while still relevant, are a bit old.
你的问题有点不清楚。如果你想查看哪些必备文件最近没有被修改,可以使用 ls -l 查看它们的修改时间。如果你想看看 make 正在做什么,试试这个:
Your question is a little unclear. If you want to see which prerequisite files have not been modified recently, use ls -l to see their modification time. If you want to see what make is doing, try this:
有几次我也使用过这个(旧但仍然有效)交互约翰·格雷厄姆·卡明 (John Graham-Cumming) 制作调试器
Few times I've also used this (old but still working) interactive make debugger by John Graham-Cumming
我正在使用 make gnu make 模板来定义每个目标的 make 规则;
模板就像编写规则的宏,这里对其进行了解释 https:// /www.gnu.org/software/make/manual/html_node/Eval-Function.html
当您的 make 系统包含一个核心 makefile 来生成每个项目类型的所有规则时,此功能非常有用;如果它说要做一个共享库,那么它会编写编译共享库的规则;对于其他类型的目标等。
在此示例中:如果将 SHOW_RULES=1 添加到 make 命令行,它还会显示由 PROGRAM_target_setup_template 生成的规则文本;以及生成规则本身(使用 eval)。
有关我的 make 文件的更多信息: http://mosermichael.github.io/cstuff/all/projects/2011/06/17/make-system.html
i am using make gnu make templates to define the make rules per target;
Templates are like macros that write rules, they are explained here https://www.gnu.org/software/make/manual/html_node/Eval-Function.html
this feature is useful when you have a make system that includes a core makefile to generate all rules per project type; if it says to do a shared library then it writes the rules to compile a shared library; etc. for other types of targets.
in this example: if you add SHOW_RULES=1 to the make command line it also shows the text of the rules that are generated by the PROGRAM_target_setup_template ; along with generating the rules themselves (with eval).
More about my make files here: http://mosermichael.github.io/cstuff/all/projects/2011/06/17/make-system.html