调试未构建的目标的 Makefile

发布于 2024-12-04 18:05:25 字数 614 浏览 1 评论 0原文

我需要一些调试 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

扎心 2024-12-11 18:05:26

目标的先决条件与其命令之间存在差异,即未为目标指定依赖项。我认为您无法使用 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 because make 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.

二货你真萌 2024-12-11 18:05:25

问题解决了。看起来 make -p 是调试此问题的最有用方法:

-p, --print-data-base
    Print  the data base (rules and variable values) that results from
    reading the makefiles; then execute as usual or as otherwise spec-
    ified.   This  also prints the version information given by the -v
    switch (see below).  To print the  data  base  without  trying  to
    remake any files, use make -p -f/dev/null.

从该输出可以相对容易地确定哪个目标失败以及应包含哪些依赖项。

Problem solved. It seems make -p was the most useful way to debug this problem:

-p, --print-data-base
    Print  the data base (rules and variable values) that results from
    reading the makefiles; then execute as usual or as otherwise spec-
    ified.   This  also prints the version information given by the -v
    switch (see below).  To print the  data  base  without  trying  to
    remake any files, use make -p -f/dev/null.

From that output it is relatively easy to determine which target was failing, and what dependency that should be included.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文