我可以使用基于 ExtUtils::MakeMaker 的构建系统“从树中”构建 Perl 模块吗?

发布于 2024-11-28 22:42:25 字数 491 浏览 6 评论 0原文

我不想在解压 Perl 模块源的目录中添加或修改文件,而是想在单独的目录中构建所有内容。通过使用 ExtUtils::MakeMaker 的相当标准的 Makefile.PL 可以轻松实现这一点吗? (简单地说,我的意思是一个或几个命令行参数之类的东西。)如果没有,其他构建系统是否支持这一点?

更新/原因: Perl 模块绑定到构建系统为 autoconf/automake/libtool 的库-基于。 Perl 模块与该库一起提供,并且在顶级目录中调用 make 最终也会构建 Perl 库。我有兴趣在单独的构建树中构建整个项目。目前,我做了类似于 runrig 建议的事情,仅使用符号链接。 (cp -sru $(srcdir)/.$(builddir)/.)。到目前为止,这已经有效,但如果有更优雅的解决方案,我想阅读一下。

Instead of adding or modifying files in the directory where the sources of a Perl module are unpacked, I would like to build everything in a separate directory. Is this easily achievable with a fairly standard Makefile.PL that uses ExtUtils::MakeMaker? (By easy, I mean something like one or a few command line parameters.) If no, does any of the other build systems support this?

Update / Reason: The Perl module is a binding to a library whose build system is autoconf/automake/libtool-based. The Perl module is shipped together with this library and calling make in the top directory eventually also builds the Perl library. I am interested in building the entire project in a separate build tree. At the moment I do something similar to what runrig suggested, only using symlinks. (cp -sru $(srcdir)/. $(builddir)/.). This has worked so far, but if there is a more elegant solution, I'd like to read about it.

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

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

发布评论

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

评论(3

友谊不毕业 2024-12-05 22:42:25

MakeMaker 已经复制了源代码并将它们构建在一个单独的目录中(这就是 blib/ 所在的目录)。您可以使用 WriteMakefile()INST_* 参数集控制构建位置。此示例将位置从 blib/ 更改为 foo/

INST_ARCHLIB        => "foo/arch",
INST_LIB            => "foo/lib",
INST_BIN            => "foo/bin",
INST_SCRIPT         => "foo/script",
INST_MAN1DIR        => 'foo/man1',
INST_MAN3DIR        => 'foo/man3',

此外,您还必须告诉 MakeMaker 清理新的构建目录。

clean       => {
    FILES           => 'foo'
},

请参阅 “确定 Perl 库和安装位置”。 ="http://search.cpan.org/perldoc?ExtUtils%3a%3aMakeMaker" rel="nofollow">ExtUtils::MakeMaker 文档以获取更多信息。

MakeMaker already copies the sources and builds them in a separate directory (that's what blib/ is). You can control the build location with the INST_* set of arguments to WriteMakefile(). This example changes the location from blib/ to foo/.

INST_ARCHLIB        => "foo/arch",
INST_LIB            => "foo/lib",
INST_BIN            => "foo/bin",
INST_SCRIPT         => "foo/script",
INST_MAN1DIR        => 'foo/man1',
INST_MAN3DIR        => 'foo/man3',

In addition you have to tell MakeMaker to cleanup the new build directory.

clean       => {
    FILES           => 'foo'
},

See "Determination of Perl Library and Installation Locations" in the ExtUtils::MakeMaker docs for more info.

沩ん囻菔务 2024-12-05 22:42:25
cp -R Module-Directory-0.01 Module-Directory-0.01.copy
cd Module-Directory-0.01.copy
perl Makefile.PL
make
make test
...etc.
cp -R Module-Directory-0.01 Module-Directory-0.01.copy
cd Module-Directory-0.01.copy
perl Makefile.PL
make
make test
...etc.
鯉魚旗 2024-12-05 22:42:25

我最终使用了符号链接:

Perl 模块提供绑定的库使用
基于 autoconf/automake/libtool 的构建系统。 Makefile.PL
通过 configureMakefile.PL.in 生成。 Makefile.PL
生成 Makefile-plMakefile 已被
autoconf/automake)。

这是 Makefile.am 的相关部分:

all: Makefile-pl src_deps
    $(MAKE) -f Makefile-pl

Makefile-pl: Makefile.PL
    perl Makefile.PL INSTALLDIRS=$(INSTALLDIRS) PREFIX=$(prefix)

我将第二个目标更改为:

Makefile-pl: Makefile.PL
    -[ $(srcdir) != $(builddir) ] && cp -rsu $(abs_srcdir)/. $(builddir)/.
    perl Makefile.PL INSTALLDIRS=$(INSTALLDIRS) PREFIX=$(prefix)

只要构建或安装 Perl 模块,它就应该有效
不会导致任何文件被就地修改。

I ended up using symlinks:

The library to which the Perl module provides bindings uses an
autoconf/automake/libtool-based build system. Makefile.PL is
generated from Makefile.PL.in by configure. Makefile.PL
generates Makefile-pl (Makefile has already been taken by
autoconf/automake).

This is the relevant part of Makefile.am:

all: Makefile-pl src_deps
    $(MAKE) -f Makefile-pl

Makefile-pl: Makefile.PL
    perl Makefile.PL INSTALLDIRS=$(INSTALLDIRS) PREFIX=$(prefix)

I changed the second target to:

Makefile-pl: Makefile.PL
    -[ $(srcdir) != $(builddir) ] && cp -rsu $(abs_srcdir)/. $(builddir)/.
    perl Makefile.PL INSTALLDIRS=$(INSTALLDIRS) PREFIX=$(prefix)

This should work as long as building or installing the Perl module
does not result in any files being modified in-place.

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