| 1 |
package Business::ISBN::Data; |
| 2 |
use strict; |
| 3 |
use warnings; |
| 4 |
|
| 5 |
=encoding utf8 |
| 6 |
|
| 7 |
=head1 The build file for Business::ISBN::Data |
| 8 |
|
| 9 |
This build file is a modulino; it works as both a build script and |
| 10 |
a module. |
| 11 |
|
| 12 |
To build the distribution, run this file normally: |
| 13 |
|
| 14 |
% perl Makefile.PL |
| 15 |
|
| 16 |
But, it's more interesting than that. You can load it with C<require> |
| 17 |
and call C<arguments> to get the data structure it passes to |
| 18 |
C<WriteMakefile>: |
| 19 |
|
| 20 |
my $package = require '/path/to/Makefile.PL'; |
| 21 |
my $arguments = $package->arguments; |
| 22 |
|
| 23 |
Note that C<require>-ing a file makes an entry in C<%INC> for exactly |
| 24 |
that name. If you try to C<require> another file with the same name, |
| 25 |
even from a different path, C<require> thinks it has already loaded |
| 26 |
the file. As such, I recommend you always require the full path to the |
| 27 |
file. |
| 28 |
|
| 29 |
The return value of the C<require> is a package name, which in this case |
| 30 |
is the name of the main module. Use that to call the C<arguments> method. |
| 31 |
|
| 32 |
Even if this distribution needs a higher version of Perl, this bit |
| 33 |
only needs v5.8. You can play with the data structure with a primitive |
| 34 |
Perl. |
| 35 |
|
| 36 |
=cut |
| 37 |
|
| 38 |
BEGIN { |
| 39 |
use ExtUtils::MM_Any; |
| 40 |
no warnings qw(redefine); |
| 41 |
|
| 42 |
# get rid of the warning about README.pod, because I'm using it. |
| 43 |
# It's also in INSTALL.SKIP |
| 44 |
sub ExtUtils::MM_Any::libscan { |
| 45 |
my($self,$path) = @_; |
| 46 |
|
| 47 |
my($dirs,$file) = ($self->splitpath($path))[1,2]; |
| 48 |
return '' if grep /^(?:RCS|CVS|SCCS|\.svn|_darcs)$/, |
| 49 |
$self->splitdir($dirs), $file; |
| 50 |
|
| 51 |
return $path; |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
use File::Spec::Functions qw(catfile); |
| 56 |
|
| 57 |
my $module = __PACKAGE__; |
| 58 |
( my $dist = $module ) =~ s/::/-/g; |
| 59 |
|
| 60 |
my $github = 'https://github.com/briandfoy/business-isbn-data'; |
| 61 |
my $main_file = catfile( 'lib', split /::/, "$module.pm" ); |
| 62 |
|
| 63 |
my %WriteMakefile = ( |
| 64 |
'MIN_PERL_VERSION' => '5.008', |
| 65 |
|
| 66 |
'NAME' => $module, |
| 67 |
'ABSTRACT_FROM' => $main_file, |
| 68 |
'VERSION_FROM' => $main_file, |
| 69 |
'LICENSE' => 'artistic_2', |
| 70 |
'AUTHOR' => 'brian d foy <[email protected]>', |
| 71 |
|
| 72 |
'CONFIGURE_REQUIRES' => { |
| 73 |
'ExtUtils::MakeMaker' => '6.64', |
| 74 |
'File::Spec::Functions' => '0', |
| 75 |
}, |
| 76 |
|
| 77 |
'TEST_REQUIRES' => { |
| 78 |
'Test::More' => '1', |
| 79 |
'version' => '0.86', |
| 80 |
}, |
| 81 |
|
| 82 |
'BUILD_REQUIRES' => { |
| 83 |
}, |
| 84 |
|
| 85 |
'PREREQ_PM' => { |
| 86 |
'Carp' => '0', |
| 87 |
'File::Basename' => '0', |
| 88 |
'File::Spec::Functions' => '0', |
| 89 |
}, |
| 90 |
|
| 91 |
'META_MERGE' => { |
| 92 |
'meta-spec' => { version => 2 }, |
| 93 |
resources => { |
| 94 |
repository => { |
| 95 |
type => 'git', |
| 96 |
url => $github, |
| 97 |
web => $github, |
| 98 |
}, |
| 99 |
bugtracker => { |
| 100 |
web => "$github/issues", |
| 101 |
}, |
| 102 |
homepage => $github, |
| 103 |
}, |
| 104 |
}, |
| 105 |
|
| 106 |
clean => { FILES => "$dist-*" }, |
| 107 |
); |
| 108 |
|
| 109 |
sub arguments { \%WriteMakefile } |
| 110 |
|
| 111 |
do_it() unless caller; |
| 112 |
sub do_it { |
| 113 |
require File::Spec; |
| 114 |
my $MM ='ExtUtils::MakeMaker'; |
| 115 |
my $MM_version = |
| 116 |
eval{ "$MM " . $WriteMakefile{'CONFIGURE_REQUIRES'}{'ExtUtils::MakeMaker'} } |
| 117 |
|| |
| 118 |
"$MM 6.64"; |
| 119 |
eval "use $MM_version; 1" or die "Could not load $MM_version: $@"; |
| 120 |
eval "use Test::Manifest 1.21" |
| 121 |
if -e File::Spec->catfile( qw(t test_manifest) ); |
| 122 |
|
| 123 |
my $arguments = arguments(); |
| 124 |
my $minimum_perl = $arguments->{MIN_PERL_VERSION} || '5.008'; |
| 125 |
eval "require $minimum_perl;" or die $@; |
| 126 |
|
| 127 |
WriteMakefile( %$arguments ); |
| 128 |
} |
| 129 |
|
| 130 |
|
| 131 |
no warnings; |
| 132 |
__PACKAGE__; |