[Module-build-general] A better passthrough Makefile.PL
Status: Beta
Brought to you by:
kwilliams
From: Dave R. <au...@ur...> - 2002-10-03 23:54:22
|
I wanted to create a Makefile.PL that would pass all functionality through to Module::Build, _and_ that would make sure that Module::Build got installed if necessary. I also wanted to make sure that the user did not have to run "perl Makefile.PL" twice, once for installing Module::Build, and once to install the desired module. Having to do this basically makes the install fail with CPAN or CPANPLUS. Here's what I came up with: use Cwd; use File::Spec; unless (eval { require Module::Build::Compat; 1 }) { require ExtUtils::MakeMaker; print "This module required Module::Build to install itself.\n"; my $yn = ExtUtils::MakeMaker::prompt( ' Install Module::Build', 'y' ); if ($yn =~ /^y(es)?/i) { # save this cause CPAN will chdir all over the place. my $cwd = cwd(); my $makefile = File::Spec->rel2abs($0); require CPAN; CPAN->install('Module::Build'); chdir $cwd or die "Cannot chdir to $cwd: $!"; exec( $^X, $makefile, @ARGV ) } else { warn "Cannot install Thesaurus without Module::Build. Exiting ...\n"; exit 0; } } require Module::Build::Compat; Module::Build::Compat->run_build_pl( args => \@args ); Module::Build::Compat->write_makefile; |