make:显示可能缺少的依赖项

问题描述

我正在开发一个具有复杂Makefile的程序:某些源文件是使用某些脚本生成的。

以下简化示例显示了我的问题:

myProgram: example1.o example2.o
    gcc -o $@ example1.o example2.o

%.o: %.c example.h
    gcc -c $< -o $@

%.o: %.cc
    gcc -c $< -o $@

%.c: %.in generator
    ./generator $< $@

generator: generator.o
    gcc -o $@ $<

尚未实现我程序的所有文件,并且make报告:

No rule to make target 'example1.o',needed by 'myProgram'.

在示例中,构建example1.o的可能性不同:

  • 来自example1.cc
  • 来自example1.cexample.h
  • 来自example1.ingeneratorexample.h
  • 来自example1.ingenerator.cexample.h
  • 来自example1.ingenerator.ccexample.h

不幸的是,很难保留项目的概述,因此我没有丢失哪些文件的概述。因此,我想获取缺少的依赖项列表-像这样:

<some_command> example1.o

"example1.o" can be built from:
    example1.c (missing)
    example.h (present)
or:
    example1.cc (missing)

<some_command> example1.c

"example1.c" can be built from:
    generator (missing)
    example1.in (present)

(该工具无需递归搜索依赖项;我可以手动进行此操作。)

问题:有可能这样做吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)