调试未构建的目标的Makefile

Bja*_*sen 2 debugging makefile gnu-make

我需要一些帮助调试Makefile系统.我有一个相当庞大的Makefile依赖树,实际上是Android源码makefile系统.

在某些时候,构建失败,因为文件丢失:

/bin/bash: out/host/linux-x86/bin/mkfs.ubifs: No such file or directory
Run Code Online (Sandbox Code Playgroud)

该文件mkfs.ubifs应该在make过程中"构建",如果我这样做,它确实有效:

make out/host/linux-x86/bin/mkfs.ubifs
Run Code Online (Sandbox Code Playgroud)

mkfs.ubifs是构建和一切工作,直到我再次清洁的一切,从头开始构建.

这告诉我,某处缺少依赖.所以我的问题是,我该如何调试呢?如何准确发现缺少依赖项的目标?我可以为make提供哪些选项,这将为我提供有关错误位置的线索?

任何其他建议也将不胜感激.谢谢.:)

更新

使用make -d提供了相当多的输出.我究竟如何确定从哪个make目标(源文件和行)和错误发生?

Bja*_*sen 6

问题解决了.这似乎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.
Run Code Online (Sandbox Code Playgroud)

从该输出中可以相对容易地确定哪个目标失败,以及应该包括哪个依赖项.