如何更改 MakeMaker 的默认 CFLAGS
如何让 Perl MakeMaker 更改插入 Makefile 的 CFLAGS 的默认值?基于这篇文章 ,我尝试了这个:
export CFLAGS=...
然后在 cpan 中,我确认了它,
! print $ENV{CFLAGS}
但它仍然使用 CFLAGS Perl 构建的任何内容。
我按照 这篇文章 但 CFLAGS 似乎没有在那里设置。
我有一个相关问题已得到解答:如何判断CPAN 关于 make 和 cc 的路径
我在 CPAN/Config.pm 中取得了一些进展,
'makepl_arg' => q[ CCFLAGS="-D_REENTRANT -O2 -m32 -I/opt/csw/bdb48/include -I/opt/csw/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -m32 -DVERSION=\"1.616\" -DXS_VERSION=\"1.616\" -fPIC -I/opt/csw/lib/perl/5.10.1/CORE"],
但这只会将值附加到 CFLAGS 中已有的值,而 gcc 无法理解这一点(例如“-x03”和“-KPIC”)。
How do I get Perl MakeMaker to change the default value for CFLAGS that it inserts into Makefiles? Based on this post, I tried this:
export CFLAGS=...
then inside cpan, I confirmed it with
! print $ENV{CFLAGS}
but it still uses whatever CFLAGS Perl was built with.
I looked in lib/perl/.../Config.pm as suggested by this post but CFLAGS doesn't appear to be set there.
I have a related question that got answered: How to tell CPAN about path to make and cc
I made a little headway in CPAN/Config.pm
'makepl_arg' => q[ CCFLAGS="-D_REENTRANT -O2 -m32 -I/opt/csw/bdb48/include -I/opt/csw/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -m32 -DVERSION=\"1.616\" -DXS_VERSION=\"1.616\" -fPIC -I/opt/csw/lib/perl/5.10.1/CORE"],
but this only appends the value to whatever was already in CFLAGS, which gcc doesn't understand (like "-x03" and "-KPIC").
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
听起来最初的问题实际上是关于使用一组工具(gcc)为使用另一组工具(无论 Solaris 使用什么)构建的 perl 编译新代码。像这样混合使用构建工具有时会导致奇怪的问题。
我的第一种方法是尝试使用与编译我想要使用的 perl 相同的工具。我的第二种方法是使用我想要使用的工具编译一个新的 perl。在一个系统上同时维护多个版本的 perl 是非常容易的。
一般来说,我会避免使用系统安装的 perl,但有时我可能想使用一些供应商库。
It sounds like the original problem is actually about compiling new code with one set of tools (gcc) for a perl built with a different set of tools (whatever Solaris uses). Mixing build tools like that sometimes leads to weird problems down the line.
My first approach would try to use the same tools that compiled the perl I want to use. My second approach would be to compile a new perl with the tools I want to use. It's very easy to maintain several version of perl on a system at the same time.
Generally I avoid the system-installed perl, but sometimes there are vendor libraries that I might want to use.
我已成功修改/opt/csw/lib/perl/5.10.1/Config_heavy.pl,以便MakeMaker可以生成可在OpenCSW下的solaris系统上运行的Makefile。
其他遇到类似问题的人可以在这里下载:https://gist.github.com/1569718
我我们也将其发布回 opencsw.org 的维护人员,以便他们有望更新 Perl 的 OpenCSW 版本。我在我的文章中指出,执行此操作的正确方法是使用属于 OpenCSW 发行版的工具完全重建 Perl,因为我相信在构建任何给定的 Perl 发行版时,其他脚本会自动生成此文件(尽管我还没有验证了它实际上是如何构建的)。这个修补过的文件只是一个权宜之计,以便我能够在截止日期前完成我的工作。
我非常希望通过修改 CPAN/Config.pm 中的设置来实现我的目标。这适用于设置 gcc 和 gmake 的正确路径,但不适用于将命令行标志更改为 gcc,因为 CPAN 会将这些标志附加到先前设置的参数字符串中。 gcc 在遇到这些标志后将退出,其中一些标志不兼容(例如“-xO3”和“-KPIC”)。
根据记录,CSWperl 5.10.1,REV=2011.01.15 是我从 OpenCSW 安装的 CSW Perl 的当前版本。
希望这可以帮助别人。
I have successfully modified /opt/csw/lib/perl/5.10.1/Config_heavy.pl so that MakeMaker can generate Makefiles that will work on a solaris system under OpenCSW.
Others who are having similar problems may download it here: https://gist.github.com/1569718
I have also posted this back to maintainers at opencsw.org so that they will hopefully update the OpenCSW release of Perl. I noted in my post that the right way to do this is to rebuild Perl entirely with tools belonging to the OpenCSW distro, because I believe that this file gets generated automatically by other scripts when any given Perl distro is built (although I haven't verified how it actually gets built). This patched file is merely an expedient so that I could get my work done, which is under a deadline.
I would have greatly preferred to accomplish my goal by modifying settings in CPAN/Config.pm. This worked for setting the correct paths to gcc and gmake, but not for changing the command-line flags to gcc, because CPAN would append these flags to the previously set argument string. gcc would quit after encountering those flags, some of which were incompatible (e.g. "-xO3" and "-KPIC").
For the record, CSWperl 5.10.1,REV=2011.01.15 is the current release of Perl from CSW that I have installed from OpenCSW.
Hope this may help someone else.
我在测试 Inline 模块时遇到了这个问题。
我发现我可以像这样更改优化标志(Perl v5.32.0):
'DATA'
之后的内容是我认为传递给 MakeMaker 的配置选项。所以我猜你可以做同样的参数OPTIMIZE =>;
。MakeMaker.PL
文件中的“-O3”I ran into this problem while testing the Inline module.
I found I could change the optimization flags like this (Perl v5.32.0):
Stuff after
’DATA’
are configuration options which I think are passed to MakeMaker. So I am guessing you can do the same argsOPTIMIZE => "-O3"
in yourMakeMaker.PL
file.