1use strict;
2
3unless (eval "use Module::Build 0.20; 1" ) {
4    print "This module requires Module::Build to install itself.\n";
5
6    require ExtUtils::MakeMaker;
7    my $yn = ExtUtils::MakeMaker::prompt
8        ('  Install Module::Build from CPAN?', 'y');
9
10    if ($yn =~ /^y/i) {
11        require Cwd;
12        require File::Spec;
13        require CPAN;
14
15        # Save this 'cause CPAN will chdir all over the place.
16        my $cwd = Cwd::cwd();
17        my $makefile = File::Spec->rel2abs($0);
18
19        CPAN::Shell->install('Module::Build::Compat');
20
21        chdir $cwd or die "Cannot chdir() back to $cwd: $!";
22        exec $^X, $makefile, @ARGV;  # Redo now that we have Module::Build
23    } else {
24        warn " *** Cannot install without Module::Build.  Exiting ...\n";
25        exit 1;
26    }
27}
28require Module::Build::Compat;
29Module::Build::Compat->run_build_pl(args => \@ARGV);
30Module::Build::Compat->write_makefile();
31