Fix the use 5.8.1 line to work with 5.10 via use 5.008001;. Thanks to Mark
[p5sagit/local-lib.git] / Makefile.PL
CommitLineData
391107e5 1use strict;
2use warnings;
86f54d7f 3use vars qw($bootstrapping);
4
5BEGIN {
c2447f35 6 if (my ($x) = grep { /^--bootstrap(?:=.*)?$/ } @ARGV) {
7 @ARGV = grep { !/^--bootstrap(?:=.*)?$/ } @ARGV;
86f54d7f 8 $bootstrapping = 1;
c2447f35 9 $x =~ /^--bootstrap(?:=(.*))?$/;
86f54d7f 10 my @args = (defined $1 ? ($1) : ());
11
715c31a0 12 $ENV{PERL_MM_USE_DEFAULT} = 1;
86f54d7f 13 {
14 local @INC = @INC;
15 unshift(@INC, 'lib');
16 require local::lib;
17 }
18
19 local::lib->import(@args);
20
21 push(@ARGV,$ENV{PERL_MM_OPT});
22
23 system($^X, '-MExtUtils::MakeMaker 6.31', '-e1');
b57052ce 24 my $eumm = $? >> 8;
25
26 system($^X, '-MCPAN 1.80', '-e1');
27 my $cpan = $? >> 8;
28 my $cpan_command = '';
86f54d7f 29
715c31a0 30 system($^X, '-MCPAN', '-e',
31 'CPAN::Config->load;
32 unless (-w $CPAN::Config->{keep_source_where}) {
33 $ENV{PERL_MM_USE_DEFAULT} = 0;
34 my $save = $CPAN::Config->{urllist};
35 delete @{$CPAN::Config}{keys %$CPAN::Config};
36 $CPAN::Config->{urllist} = $save;
37 CPAN::Config->init;
38 }'
39 );
40
86f54d7f 41 # XXX - remove the force on EUMM once its test suite survive PERL_MM_OPT
42
b57052ce 43 if ($eumm) { # non-zero exit
44 $cpan_command .= 'force("install","ExtUtils::MakeMaker"); ';
45 }
46 if ($cpan) {
c2447f35 47 $cpan_command .= 'force("install","CPAN"); ';
b57052ce 48 }
49 if(length $cpan_command) {
50 system($^X, '-MCPAN', '-e', $cpan_command);
86f54d7f 51 }
715c31a0 52 if ($cpan) {
53 system($^X, '-MCPAN', '-e', 'CPAN::Config->load; CPAN::Config->commit;');
54 }
86f54d7f 55 }
56}
57
391107e5 58use inc::Module::Install;
59
60name 'local-lib';
61all_from 'lib/local/lib.pm';
62
63requires 'ExtUtils::MakeMaker' => '6.31'; # version INSTALL_BASE was added
86f54d7f 64requires 'ExtUtils::CBuilder'; # this and ParseXS are needed for MB C_support
65requires 'ExtUtils::ParseXS';
391107e5 66requires 'Module::Build' => '0.28'; # lib -> lib/perl5 change
86f54d7f 67requires 'CPAN' => '1.80'; # sudo support
68
10fcef9b 69# No, really. See
70# https://rt.cpan.org/Public/Bug/Display.html?id=23735
71# for why CPAN now sets the CPANPLUS env var.
72# trouble is this means we can't auto_install(_now) CPAN itself
73# without this beautiful hack
74
75my $no_cpanplus_env = !exists $ENV{PERL5_CPANPLUS_IS_RUNNING};
76require CPAN;
77delete $ENV{PERL5_CPANPLUS_IS_RUNNING} if $no_cpanplus_env;
78
86f54d7f 79if ($bootstrapping) {
80 auto_install_now;
81} else {
82 auto_install;
83}
391107e5 84
85WriteAll;