GNU Autotools:如何在“make dist”中包含源文件位于根源目录之上的 tarball?

发布于 2024-08-13 05:41:00 字数 372 浏览 11 评论 0原文

我有一个 Subversion 项目,它使用 Gnu Autotools(即 automake、autoconf 和 libtool)来管理子文件夹(称为“子包”)内的源代码。子包引用位于子包根源目录之上的源文件,并且这些文件是其他子包所共有的。不幸的是,当运行“make dist”来创建发行版 tarball 时,公共源文件不会包含在发行版中。

有没有办法在分发源代码之前使用 autoconf/automake 将这些公共源文件移动到子包的子目录中,并让 makefile 自行调整以正确指向重新定位的源文件?显然,可以让 makefile 在编译之前移动这些源文件,但是对于在 Subversion 存储库中工作,这会导致问题,因为这些移动的文件是受修订控制的,并且很容易意外编辑移动的文件而不是原始文件。

I've got a Subversion project that uses Gnu Autotools (i.e., automake, autoconf, and libtool) to manage source code within a subfolder (called 'subpackage'). The subpackage references source files that are above the subpackage's root source directory, and are common to other subpackages. Unfortunately, when running 'make dist' to create the distribution tarball, the common source files do not get included in the distribution.

Is there a way to use autoconf/automake to move these common source files into a subdirectory of the subpackage before distributing the source, and to have the makefile adjust itself to correctly point to the relocated source files? Clearly, it would be possible to have the makefile move these source files over before compiling, but for working within the Subversion repository, this causes problems because these moved files are revision controlled, and its easy to accidentally edit the moved file instead of the original.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

深陷 2024-08-20 05:41:00

您可以在子包中有一个空目录,称为“common”,其中包含复制外部文件的 makefile。然后您可以使用 dist-hook 目标将文件直接移动到“common”目录的版本中它将被压缩到 tarball 中。这样您就不必担心它们被随意放置和被编辑。您还可以在复制时覆盖“common”中的 Makefile.am、Makefile.in 和 Makefile。

subpackage/common/Makefile.am 中的示例(未经测试):

dist-hook:
    cp -p $(top_srcdir)/../common/Makefile* $(top_srcdir)/../common/*.[ch] $(distdir)

我不能 100% 确定这会起作用。它可能会破坏包的其余部分,具体取决于其他所有内容期望在哪里找到这些源文件;如果您解压缩 tarball 并尝试从那里创建 dist,它可能会中断。你应该知道,这种诡计是令人不齿的。但我希望我已经给了你足够的想法来尝试。

You could have an empty directory in subpackage, called, say, "common", with a makefile that copies the external files in. Then you could use the dist-hook target to move the files directly into the version of the "common" directory that will get zipped up into the tarball. That way you don't have to worry about them lying around and being edited. You would also overwrite the Makefile.am, Makefile.in and Makefile in "common" as you copied.

Example in subpackage/common/Makefile.am (untested):

dist-hook:
    cp -p $(top_srcdir)/../common/Makefile* $(top_srcdir)/../common/*.[ch] $(distdir)

I'm not 100% sure this will work though. It might break the rest of your package, depending on where everything else expects to find those source files; it probably will break making dist if you unpack the tarball and try to make dist from there. You should know that this sort of trickery is frowned upon. But I hope I've given you enough ideas to play around with.

抱着落日 2024-08-20 05:41:00

为什么不使用符号链接,而不是四处移动文件(这对我来说总是听起来很可疑)?您可以让子包仅引用本地文件,并使用 Makefile 规则来表示“如果本地文件不在这里,则创建指向父文件的符号链接”。在make dist期间,符号链接将自动转换为普通文件。

Instead of moving files around (which always sounds fishy to me), Why not use symbolic links? You could have your subpackage reference only local files, and a Makefile rule that says "if the local files is not here, create a symbolic link to the parent's file". During make dist, the symbolic link will be converted into a plain file automatically.

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