gpt4 book ai didi

automake - 如何延迟 Makefile.am 中 "include"指令的效果直到 make (避免 Automake 看到 "include")?

转载 作者:行者123 更新时间:2023-12-04 18:16:05 31 4
gpt4 key购买 nike

我的 Makefile.am包括一个文件(带有各种定义的变量),例如:

include make.config

...

问题是该文件又是由工具(即 config.generator.sh )基于某些输入文件(即 input.dat )生成的。直截了当 错了想法是添加一条规则来生成 make.config :
make.config : input.dat
config.generator.sh input.dat > make.config

include make.config

...

尽管此内容在没有 automake 的情况下可以单独使用 makefile ,这个想法注定了 automake . make.config文件包含在 automake 中在我有机会执行 make 之前(并且由于尚未生成文件而失败):
automake: cannot open < make.config: No such file or directory

有没有办法推迟include的效果指令直到 make运行(可能通过使用另一个指令)?

可能有一种方法可以在生成任何 makefile 之前简单地运行任意命令(即 AC_CONFIG_COMMANDS* )。但问题更复杂,因为 config.generator.sh应该使用在同一构建过程中又生成的可执行文件(因此存在逻辑上必须由来自同一项目的 makefile 管理的依赖链)。 The documentation simply confirms the logic without providing alternatives .

最佳答案

解决方案在 this email 中描述。 Automake 的邮件列表。

这个想法是使用 include小型常规“包装器”中的指令makefile并包括 Automake 生成的 Makefile进入它(注意大写 M )。因为makefile不是 Automake 模板,include按预期工作,触发不存在文件的构建。

注意:

  • 默认 make实用程序将搜索 makefile首先(不适用于 Makefile )使这种方法无缝工作。
  • 还是建议指定Makefile.am里面的所有规则并保留“包装”makefile简单的。不存在文件的规则自然会来自生成的Makefile反正。
  • 关于automake - 如何延迟 Makefile.am 中 "include"指令的效果直到 make (避免 Automake 看到 "include")?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11691687/

    31 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com