How do I override perl's compilation flags when building modules?
Asked Answered
G

2

7

When building a Perl module ExtUtils::MakeMaker uses the flags defined in Config.pm (see perldoc Config) for values such as ccflags and ldflags.

How do I override theses values (short of editing the Makefile.PL)?

perl Makefile.PL ldflags=<options> 

does not seem to work.

Context: I am trying to compile Term::Readline::Gnu on OS X 10.6. The default OS X perl is a universal binary and thus has ccflags like -arch i386 -arch ppc etc.
On the other hand my version of Gnu Readline (6.0) has been compiled from source for -arch i386 only. As such it does not contain the expected symbols for a module trying to link to it using -arch ppc.

Galbraith answered 20/10, 2009 at 1:49 Comment(1)
Try asking this question in EUMM mailing list: perlfoundation.org/perl5/index.cgi?extutils_makemakerPonder
N
2

In general, trying to override the settings in Config.pm is an exercise in futility. The more normal reason for wanting to change them is to change the compiler on a machine where Perl was compiled with a non-GNU compiler but you want to use GCC. This is so hard to do that it is by far simpler to rebuild Perl with your chosen compiler, install all the auxilliary modules, and then use build your chosen new module rather than try to fight 'the system'.

You can therefore do one of two things - build your GNU Readline library with the same options that Perl would use, or build your Perl with the options used to build GNU Readline. Trying to bend one to meet the other is not recommended if you value your machine and the hair on your head (please don't hit the machine that hard - it is the software you should be frustrated with, not the hardware; Mac's are nice!).

Of the two options, rebuilding GNU Readline is probably the easier - it is smaller and has fewer add-ons.

Nolte answered 20/10, 2009 at 2:53 Comment(1)
I guess I've completed the exercise successfully. It's apparently a bad solution for production, but for local development...Ultramundane
U
0

Information provided in the Hintsfile Support section of the docs might be relevant, although I have not tried it.

Us answered 20/10, 2009 at 2:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.