1package Geo::GeoNames; 2use strict; 3use warnings; 4 5=encoding utf8 6 7=head1 The build file for Geo::GeoNames 8 9This build file is a modulino; it works as both a build script and 10a module. 11 12To build the distribution, run this file normally: 13 14 % perl Makefile.PL 15 16But, it's more interesting than that. You can load it with C<require> 17and call C<arguments> to get the data structure it passes to 18C<WriteMakefile>: 19 20 my $package = require '/path/to/Makefile.PL'; 21 my $arguments = $package->arguments; 22 23Note that C<require>-ing a file makes an entry in C<%INC> for exactly 24that name. If you try to C<require> another file with the same name, 25even from a different path, C<require> thinks it has already loaded 26the file. As such, I recommend you always require the full path to the 27file. 28 29The return value of the C<require> is a package name (in this case, 30the name of the main module. Use that to call the C<arguments> method. 31 32Even if this distribution needs a higher version of Perl, this bit 33only needs v5.8. You can play with the data structure with a primitive 34Perl. 35 36=cut 37 38use File::Spec::Functions qw(catfile); 39 40my $module = __PACKAGE__; 41( my $dist = $module ) =~ s/::/-/g; 42 43my $github = 'https://github.com/briandfoy/geo-geonames'; 44my $main_file = catfile( 'lib', split /::/, "$module.pm" ); 45 46my %WriteMakefile = ( 47 'MIN_PERL_VERSION' => '5.010', 48 49 'NAME' => $module, 50 'ABSTRACT_FROM' => $main_file, 51 'VERSION_FROM' => $main_file, 52 'AUTHOR' => 'Per Henrik Johansen <per.henrik.johansen@gmail.com>', 53 'LICENSE' => 'perl', 54 55 'CONFIGURE_REQUIRES' => { 56 'ExtUtils::MakeMaker' => '6.64', 57 'File::Spec::Functions' => '0', 58 }, 59 60 'BUILD_REQUIRES' => { 61 }, 62 63 'TEST_REQUIRES' => { 64 'Test::More' => '0.98', 65 }, 66 67 'PREREQ_PM' => { 68 'XML::Simple' => '2.13', 69 'Mojo::UserAgent' => '0', 70 'JSON' => '1.14', 71 }, 72 73 'META_MERGE' => { 74 'meta-spec' => { version => 2 }, 75 keywords => [ qw(geo geonames) ], 76 resources => { 77 repository => { 78 type => 'git', 79 url => "$github.git", 80 web => $github, 81 }, 82 bugtracker => { 83 web => "$github/issues", 84 }, 85 homepage => $github, 86 }, 87 }, 88 89 clean => { FILES => "$dist-*" }, 90 ); 91 92sub arguments { \%WriteMakefile } 93 94do_it() unless caller; 95sub do_it { 96 97 unless( exists $ENV{GEONAMES_USER} ) { 98 print <<"HERE"; 99 To test Geo::GeoNames, you need a a GeoNames account enabled at least 100 for free access. Start at http://www.geonames.org/login to create a 101 new account. Set GEONAMES_USER to run the tests. 102HERE 103 } 104 105 require File::Spec; 106 my $MM ='ExtUtils::MakeMaker'; 107 my $MM_version = 108 eval{ "$MM " . $WriteMakefile{'CONFIGURE_REQUIRES'}{'ExtUtils::MakeMaker'} } 109 || 110 "$MM 6.64"; 111 eval "use $MM_version; 1" or die "Could not load $MM_version: $@"; 112 eval "use Test::Manifest 1.21" 113 if -e File::Spec->catfile( qw(t test_manifest) ); 114 115 my $arguments = arguments(); 116 my $minimum_perl = $arguments->{MIN_PERL_VERSION} || '5.008'; 117 eval "require $minimum_perl;" or die $@; 118 119 WriteMakefile( %$arguments ); 120 } 121 122 123no warnings; 124__PACKAGE__; 125