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