在 Makefile.am 中 make 成功后打印一些内容

发布于 2024-10-17 03:09:00 字数 475 浏览 3 评论 0原文

我是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

殤城〤 2024-10-24 03:09:00

----编辑为 install-exec-hook 很有用,但这是 100% 的答案 ----

通过替换 Makefile.am 中的“install:”目标来扩展你的 Makefile

将以下内容添加到“Makefile.am”

install: install-am
        echo "Don't forget to set your LD_LIBRARY_PATH"

为此,您必须首先在生成的 Makefile 中找到安装目标并将其复制到 Makefile.am。这可以确保您不会破坏 automake 的目标相互依赖的方式。

然后,您可以像添加任何 Makefile 一样在目标下添加命令。请注意,这是在 Makefile.am 中完成的,因此当 automake 构建 Makefile.in 和 Makefile 时,它​​将通过通常提供的默认值来获取目标。

这将使您的“警告”更接近非并行构建的结束。危险在于您必须确保您对“安装”目标的覆盖与 automake 的要求保持一致。

另外,如果他们运行“make install-exec”,您的警告将不会报告。如果您决定让它在“make install-exec”中报告,那么您应该

  1. 删除报告自定义
    对于“make install”(以避免
    双重报告)。
  2. 添加报告
    定制“make
    install-exec”(报告库
    添加警告)。
  3. 自定义安装-am
    目标之前安装的数据
    安装可执行文件。

删除安装自定义的示例

// note the lack of install: override int Makefile.am
install-exec: install-exec-am
        echo "Be sure to update your LD_LIBRARY_PATH"

install-am: all-am
    @${MAKE} $(AM_MAKEFLAGS) install-data install-exec

---- 原始帖子如下 ----

您的报告确实应该在安装时制作。 autotools 平台中有两个安装目标:install-data 和 install-exec。共享库正确地属于“exec”类别。

添加一个 install-exec-hook 到 makefile.am

基本上它看起来有点像:

install-exec-hook:
        echo "Be sure to set your LD_LIBRARY_PATH!"

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"

install: install-am
        echo "Don't forget to set your LD_LIBRARY_PATH"

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

  1. Remove the reporting customization
    for "make install" (to avoid
    double-reporting).
  2. Add the reporting
    customization for "make
    install-exec" (to report the library
    add warning).
  3. Customize install-am
    target to install the data before
    installing the executables.

Example with install customization removed

// note the lack of install: override int Makefile.am
install-exec: install-exec-am
        echo "Be sure to update your LD_LIBRARY_PATH"

install-am: all-am
    @${MAKE} $(AM_MAKEFLAGS) install-data install-exec

---- 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-exec-hook:
        echo "Be sure to set your LD_LIBRARY_PATH!"

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.

简单爱 2024-10-24 03:09:00

只需在顶层 Makefile.am 中添加本地钩子即可:

all-local:
        @echo 'Make sure...'

Just add a local hook in the top level Makefile.am:

all-local:
        @echo 'Make sure...'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文