Module::Build::Compat - Compatibility with ExtUtils::MakeMaker
Here's a Makefile.PL that passes all functionality through to Module::Build:
Module::Build
use Module::Build::Compat; Module::Build::Compat->run_build_pl(args => \@ARGV); Module::Build::Compat->write_makefile();
Or, here's one that's more careful about sensing whether Module::Build is already installed, and will offer to install it if it's missing:
unless (eval "use Module::Build::Compat 0.02; 1" ) { print "This module requires Module::Build to install itself.\n"; require ExtUtils::MakeMaker; my $yn = ExtUtils::MakeMaker::prompt (' Install Module::Build from CPAN?', 'y'); if ($yn =~ /^y/i) { require Cwd; require File::Spec; require CPAN; # Save this 'cause CPAN will chdir all over the place. my $cwd = Cwd::cwd(); my $makefile = File::Spec->rel2abs($0); CPAN::Shell->install('Module::Build::Compat'); chdir $cwd or die "Cannot chdir() back to $cwd: $!"; exec $^X, $makefile, @ARGV; # Redo now that we have Module::Build } else { warn " *** Cannot install without Module::Build. Exiting ...\n"; exit 1; } } Module::Build::Compat->run_build_pl(args => \@ARGV); Module::Build::Compat->write_makefile();
This module helps you build a Makefile.PL that passes all functionality through to Module::Build.
There are (at least) two good ways to distribute a module that can be installed using either perl Build.PL; Build; ... or perl Makefile.PL; make; .... For each way, you include both a Makefile.PL and a Build.PL script with your distribution. The difference is in whether the Makefile.PL is a pass-through to Module::Build actions, or a normal ExtUtils::MakeMaker-using script. If it's the latter, you don't need this module - but you'll have to maintain both the Build.PL and Makefile.PL scripts, and things like the prerequisite lists and any other customization duplicated in the scripts will probably become a pain in the ass.
perl Build.PL; Build; ...
perl Makefile.PL; make; ...
For this reason, you might require that the user have Module::Build installed, and then the make commands just pass through to the corresponding Module::Build actions. That's what this module lets you do.
make
A typical Makefile.PL is shown above in SYNOPSIS.
So, some common scenarios are:
This method runs the Build.PL script, passing it any arguments the user may have supplied to the perl Makefile.PL command. Because ExtUtils::MakeMaker and Module::Build accept different arguments, this method also performs some translation between the two.
perl Makefile.PL
run_build_pl() accepts the following named parameters:
run_build_pl()
The args parameter specifies the parameters that would usually appear on the command line of the perl Makefile.PL command - typically you'll just pass a reference to @ARGV.
args
@ARGV
This is the filename of the script to run - it defaults to Build.PL.
Build.PL
This method writes a 'dummy' Makefile that will pass all commands through to the corresponding Module::Build actions.
write_makefile() accepts the following named parameters:
write_makefile()
The name of the file to write - defaults to the string Makefile.
Makefile
Ken Williams, ken@mathforum.org
Module::Build(3), ExtUtils::MakeMaker(3)
To install Module::Build, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Module::Build
CPAN shell
perl -MCPAN -e shell install Module::Build
For more information on module installation, please visit the detailed CPAN module installation guide.