调试未构建的目标的 Makefile
我需要一些调试 Makefile 系统的帮助。我有一个相当大的 Makefile 依赖树,实际上是 Android 源 makefile 系统。
在某些时候,构建会失败,因为缺少文件:
/bin/bash: out/host/linux-x86/bin/mkfs.ubifs: No such file or directory
文件 mkfs.ubifs
应该在 make 过程中“构建”,如果我这样做,它确实可以工作
make out/host/linux-x86/bin/mkfs.ubifs
: ubifs 已构建,一切正常,直到我再次清理所有内容并从头开始构建。
这向我表明,某个地方缺少依赖项。所以我的问题是,我该如何调试这个?如何准确发现哪个目标缺少依赖项?我可以为 make 提供哪些选项来提供有关错误所在的线索?
任何其他建议也将不胜感激。谢谢。 :)
更新
使用make -d
提供了相当多的输出。如何准确确定哪个 make 目标(源文件和行)发生了错误?
I need some help debugging a Makefile system. I have a rather huge Makefile dependency tree, actually the Android source makefile system.
At some point the build fails because a file is missing:
/bin/bash: out/host/linux-x86/bin/mkfs.ubifs: No such file or directory
The file mkfs.ubifs
is supposed to be "build" during the make process, and indeed it works if I do:
make out/host/linux-x86/bin/mkfs.ubifs
The mkfs.ubifs
is build, and everything is working, until I again clean everything and build from the beginning.
This indicates to me, that there is a missing dependency somewhere. So my question is, how do I go about debugging this? How do I discover exactly which target is missing a dependency? What options can I provide for make which will give me clues as to where the error is?
Any other suggestions will also be appreciated. Thanks. :)
Update
Using make -d
provides quite a lot of output. How exactly do I determine from which make target (sourcefile and line) and error occurred?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
目标的先决条件与其命令之间存在差异,即未为目标指定依赖项。我认为您无法使用
make
进行调试,因为make
无法告诉您缺少依赖项。但是,您可以尝试使用
-d
开关调用make
。这将告诉您当它遇到丢失的文件时它会尝试构建哪个目标。下一步是在 makefile 中查找该目标的规则并添加缺少的依赖项。There is a discrepancy between target's prerequisites and its commands, that is, a dependency is not specified for a target. I don't think you can debug that using
make
means becausemake
can't tell you that a dependency is missing.However, you can try invoking
make
with-d
switch. That is going to tell you which target it tries to build when it hits the missing file. The next step would be to find the rule for that target in the makefile and add the missing dependency.问题解决了。看起来 make -p 是调试此问题的最有用方法:
从该输出可以相对容易地确定哪个目标失败以及应包含哪些依赖项。
Problem solved. It seems
make -p
was the most useful way to debug this problem:From that output it is relatively easy to determine which target was failing, and what dependency that should be included.