makefile - 如何在自动工具中强制最终目标

标签 makefile target autotools

我有一个自动工具项目。在其目录之一中,我想在 make 过程完成后运行一个脚本。换句话说,我希望有一个选项可以选择最后执行的“虚假”目标。或者,我可以使用专用的 m4 宏(我只知道是哪个......)。 有什么想法吗?

谢谢

最佳答案

我假设通过“autotools”,您正在使用 Automake 以及 Autoconf。我可以看到两种方法。

您可以在 Makefile.am 中创建 -hook 规则。但是,这只能针对某些默认目标完成:install-datainstall-execuninstalldist > 和 distcheck。因此,要制定一个在 install-exec 之后立即运行的规则,请将其命名为 install-exec-hook。然后只需运行该规则的配方中的脚本即可。

但是,根据您问题的措辞,您似乎想在构建后运行脚本。如果是这种情况,您可以使用 all-local 目标自定义 all 目标,然后运行该目标配方中的脚本。请注意,根据 Automake 文档,

With the '-local' targets, there is no particular guarantee of execution order; typically, they are run early, but with parallel make, there is no way to be sure of that.

但是,由于 all 目标是虚假的,因此在构建所有内容之前它不应该运行。不过,如果你可以在安装后运行脚本,我会推荐这种方式,因为执行顺序是有保证的。

关于makefile - 如何在自动工具中强制最终目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17726683/

相关文章:

关闭文件上的 Python 套接字 Makefile 错误 I/O 操作

c - 对 SDL_Freesurface 的 undefined reference

c - 可加载内核模块错误 make : nothing to be done for all?

ios - 检测运行目标是App Extension还是iOS App

c - header 的宏定义,放在哪里?

unix - 由于zip退出状态为12,因此中止了

java - 如何配置 Maven 构建两个版本的 Artifact ,每个版本用于不同的目标 JRE

javascript - 如何在没有 href 但使用内容和 url 属性的情况下在新窗口中打开 url

c++ - 使用 cygwin 在 Windows 上安装 GMP

linux - 如何为 ARM 交叉编译 autotools 项目?