automake:我如何将文件复制到构建目录?(automake: How do I copy files to the build directory?)

编程入门 行业动态 更新时间:2024-10-25 12:28:29
automake:我如何将文件复制到构建目录?(automake: How do I copy files to the build directory?)

我正在自动化一个库项目,这个项目有一些示例程序。 我希望示例程序在dist中分发,但未安装。

目前演示程序的组织方式如下:

src/*.cpp (library source) include/*.h (library headers) demos/demo.cpp (example program) demos/RunDemo (script to run demo)

RunDemo在构建软件之后可以运行,而不需要“安装”步骤,这一点很重要。

到目前为止,我已经能够使用noinst_PROGRAMS目标构建noinst_PROGRAMS的“演示”。 但是,在构建VPATH之后,可以使用以下内容:

build/src/.libs/libxxx.so (etc..) build/demos/demo

如您所见,执行“demo”所需的RunDemo脚本不会被复制到$(builddir)。 我已经尝试了一些东西,例如,将RunDemo添加到dist_noinst_SCRIPTS ,以及添加我自己的复制目标并尝试挂接all ..不管我尝试什么,我总是得到输出,

$ make RunDemo make: Nothing to be done for `../../../projects/demo/RunDemo'.

我似乎无法在builddir中创建一个指示“如果此文件不在builddir中,则从srcdir复制它”的目标。

这可能与automake?

I am autotoolizing a library project, and this project has some example programs. I want the example programs to be distributed in the dist, but not installed.

Currently the demo programs are organized like thus:

src/*.cpp (library source) include/*.h (library headers) demos/demo.cpp (example program) demos/RunDemo (script to run demo)

It is important that RunDemo be runnable after building the software, without requiring the "install" step.

So far I have been able to build the "demo" exectuable using a noinst_PROGRAMS target. However, after make in a VPATH build, the following is available:

build/src/.libs/libxxx.so (etc..) build/demos/demo

As you can see, the RunDemo script needed to execute "demo" is not copied to the $(builddir). I have tried a few things, e.g., adding RunDemo to dist_noinst_SCRIPTS, as well as adding my own copy targets and trying to hook all.. no matter what I try, I always get the output,

$ make RunDemo make: Nothing to be done for `../../../projects/demo/RunDemo'.

I seem to be unable to create a target in the builddir that says "if this file is not in the builddir, copy it from the srcdir."

Is this possible with automake?

最满意答案

您可以在./configure步骤之后使用configure.ac脚本中的AC_CONFIG_LINKS宏(随autoconf提供)在构建树中使文件可访问。 如果可能的话,它将创建一个符号链接,否则它将复制该文件。

在你的情况下,它看起来像

AC_CONFIG_LINKS([demos/RunDemo:demos/RunDemo])

从autoconf手册 :

宏:AC_CONFIG_LINKS(dest:source ...,[cmds],[init-cmds])

使AC_OUTPUT将每个现有文件链接到相应的链接名称dest 。 如果可能的话,做一个符号链接,否则如果可能的话,建立一个硬链接,否则做一个副本。 dest名称应该是相对于顶级源或构建目录

使用dist_noinst_SCRIPTS仍然需要分发文件。

You can make files accessible in the build tree after the ./configure step using the AC_CONFIG_LINKS macro (provided with autoconf) in your configure.ac script. It will create a symbolic link if possible, otherwise it will copy the file.

In your case it would look like

AC_CONFIG_LINKS([demos/RunDemo:demos/RunDemo])

From the autoconf manual:

Macro: AC_CONFIG_LINKS (dest:source..., [cmds], [init-cmds])

Make AC_OUTPUT link each of the existing files source to the corresponding link name dest. Makes a symbolic link if possible, otherwise a hard link if possible, otherwise a copy. The dest and source names should be relative to the top level source or build directory

Using dist_noinst_SCRIPTS is still necessary for the file to be distributed.

更多推荐

本文发布于:2023-08-01 16:06:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1361567.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   文件   目录   automake   directory

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!