在 Makefile.am 中 make 成功后打印一些内容
我是 autotools 的新手,并且已经成功创建了一个目前令人满意的configure.ac。 现在我想在某个地方(configure.ac、Makefile.am 或其他地方)指定在成功“make”后打印一条简短的注释。类似于“确保您在 LD_LIBRARY_PATH 中也包含了正确的路径”。
但是,当我在 Makefile.in 中指定它时,执行“automake”会覆盖该文件(如预期)。因此,我还没有找到如何在终止编译目标之一时扩展例如 Makefile.am 以包含“echo 确保您在 LD_LIBRARY_PATH 中也包含了正确的路径”。 ATM 我只有一个目标(bin_PROGRAMS = myprog)。除此之外,编译等工作正常。但作为可能“没有”经验的用户的信息,我真的很想打印出一些最终建议。
有办法实现这一点吗?
谢谢您并致以最诚挚的问候。
PS 我了解 cmake 但尚未使用它,目前我想使用 autotools 和 automake。
I am new to autotools and have managed to create a, for the moment, satisfying configure.ac.
Now I would like to specify somewhere (configure.ac, Makefile.am, or wherever) that after a successfull "make", a short note is printed. Something like "Make sure that you have also included the correct path in you LD_LIBRARY_PATH".
However, when I specify it in Makefile.in, executing "automake" overwrites this file (as expected). So I have not found how to extend e.g. Makefile.am to include an "echo Make sure that you have also included the correct path in you LD_LIBRARY_PATH" upon termination of compilation of one of the targets. ATM I only have one target (bin_PROGRAMS = myprog). Besides this, compiling etc. works fine. But as an information for the possibly "un"experienced user, I really would like to print out some final advice.
Is there a way to achieve this?
Thank you and best regards.
P.S. I know about cmake and have not yet used it and, for the moment, I want to work with autotools and automake.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
----编辑为 install-exec-hook 很有用,但这是 100% 的答案 ----
通过替换 Makefile.am 中的“install:”目标来扩展你的 Makefile
将以下内容添加到“Makefile.am”
为此,您必须首先在生成的 Makefile 中找到安装目标并将其复制到 Makefile.am。这可以确保您不会破坏 automake 的目标相互依赖的方式。
然后,您可以像添加任何 Makefile 一样在目标下添加命令。请注意,这是在 Makefile.am 中完成的,因此当 automake 构建 Makefile.in 和 Makefile 时,它将通过通常提供的默认值来获取目标。
这将使您的“警告”更接近非并行构建的结束。危险在于您必须确保您对“安装”目标的覆盖与 automake 的要求保持一致。
另外,如果他们运行“make install-exec”,您的警告将不会报告。如果您决定让它在“make install-exec”中报告,那么您应该
对于“make install”(以避免
双重报告)。
定制“make
install-exec”(报告库
添加警告)。
目标之前安装的数据
安装可执行文件。
删除安装自定义的示例
---- 原始帖子如下 ----
您的报告确实应该在安装时制作。 autotools 平台中有两个安装目标:install-data 和 install-exec。共享库正确地属于“exec”类别。
添加一个 install-exec-hook 到 makefile.am
基本上它看起来有点像:
install-data、install-exec、uninstall、dist 和 distcheck 都支持“-hook”扩展。
至于保证它在构建结束时运行,则有点困难。 Make / Automake 的构造是为了允许并行构建,这会干扰它在构建结束时运行的保证。
----Edited as install-exec-hook is useful, but here's the 100% answer ----
Extend your Makefile, by replacing the "install:" target in the Makefile.am
Add the following to "Makefile.am"
For this to work, you must first find the install target in the generated Makefile and copy it to the Makefile.am. This ensures that you don't break how automake's targets depend on each other.
Then you add commands under the target much as you would any Makefile. Note that this is done in Makefile.am, so when automake builds it's Makefile.in and Makefile, it will source your target over the defaults it normally provides.
This will get your "warning" closer to the end on non-parallel builds. The dangers are that you will have to ensure that your override of the "install" target remains consistent with automake's requirements.
Also, if they run "make install-exec" your warning will not report. If you decide to make it report in "make install-exec" then you should
for "make install" (to avoid
double-reporting).
customization for "make
install-exec" (to report the library
add warning).
target to install the data before
installing the executables.
Example with install customization removed
---- Original post follows ----
Your report really should be made at install time. There's two install targets in the autotools platform, install-data and install-exec. A shared-library properly goes under the "exec" category.
Add an install-exec-hook to the makefile.am
Basically it would look a bit like:
install-data, install-exec, uninstall, dist, and distcheck all support "-hook" extensions.
As far as guaranteeing it runs at the end of the build, it's a bit more difficult. Make / Automake is constructed to allow parallel builds, and that interferes with a guarantee it will run at the end of a build.
只需在顶层 Makefile.am 中添加本地钩子即可:
Just add a local hook in the top level Makefile.am: