cpanm --makepl_args ?

As a follow-up to one of issues I raised in Installing Deviant OpenSSL XS Modules, I sought out to determine how difficult it would be pass makepl_args (arguments for Makefile.PL) to cpanminus.

Here is what I came up with.

--- bin/cpanm.orig	2010-07-08 11:33:53.000000000 -0500
+++ bin/cpanm	2010-07-08 12:24:27.000000000 -0500
@@ -357,6 +357,7 @@
           configure_timeout => 60,
           try_lwp => 1,
           uninstall_shadows => 1,
+          makepl_args => undef,
           @_,
       }, $class;
   }
@@ -400,6 +401,7 @@
           'self-upgrade' => sub { $self->{cmd} = 'install'; $self->{skip_installed} = 1; push @ARGV, 'App::cpanminus' },
           'uninst-shadows!'  => \$self->{uninstall_shadows},
           'lwp!'    => \$self->{try_lwp},
+          'makepl_args=s' => \$self->{makepl_args},
       );
   
       $self->{argv} = \@ARGV;
@@ -547,6 +549,7 @@
     --prompt                  Prompt when configure/build/test fails
     -l,--local-lib            Specify the install base to install modules
     -L,--local-lib-contained  Specify the install base to install all non-core modules
+    --makepl_args             Specify arguments to be given to Makefile.PL
   
   Commands:
     --self-upgrade            upgrades itself
@@ -1326,14 +1329,24 @@
   
       my $try_eumm = sub {
           if (-e 'Makefile.PL') {
-              $self->chat("Running Makefile.PL\n");
+              $self->{makepl_args} ? 
+                  $self->chat("Running Makefile.PL " . $self->{makepl_args} . "\n") : 
+                  $self->chat("Running Makefile.PL\n");
+
               local $ENV{X_MYMETA} = 'YAML';
   
               # NOTE: according to Devel::CheckLib, most XS modules exit
               # with 0 even if header files are missing, to avoid receiving
               # tons of FAIL reports in such cases. So exit code can't be
               # trusted if it went well.
-              if ($self->configure([ $self->{perl}, @switches, "Makefile.PL" ])) {
+              if ($self->configure([ 
+                      $self->{perl}, 
+                      @switches, 
+                      "Makefile.PL", 
+                      $self->{makepl_args} ? 
+                          split /\s+/, $self->{makepl_args} : 
+                          undef 
+              ])) {
                   $state->{configured_ok} = -e 'Makefile';
               }
               $state->{configured}++;

It's a blunt approach, since it will apply the makepl_args for all dependencies, which may or may not be what the user intends. Also, I didn't test how this would impact Module::Build modules.

I submitted the patch to miyagawa to see what he thinks of the idea.

2 Comments

I'm in exactly the same boat, trying to install the dependencies for Google::SAML::Response. I see the ticket was closed without much comment. Did you come up with any scriptable way to do it that doesn't require a patch?

Leave a comment

About Jesse Thompson

user-pic I blog about Perl.