fix Makefile.PL boilerplate bug
[p5sagit/strictures.git] / Makefile.PL
CommitLineData
eae006ee 1use strict;
2use warnings FATAL => 'all';
2c87c763 3use 5.006;
394c3a46 4
2c87c763 5my $have_compiler
6 = ! parse_args()->{PUREPERL_ONLY}
7 && eval { require ExtUtils::CBuilder; 1 }
8 && ExtUtils::CBuilder->new->have_compiler;
eae006ee 9
27826cd1 10my %extra_prereqs = (
11 indirect => 0,
12 multidimensional => 0,
13 'bareword::filehandles' => 0,
14);
ae3262c9 15
2c87c763 16my %META = (
17 name => 'strictures',
18 license => 'perl_5',
19 prereqs => {
20 configure => { requires => { } },
21 build => { requires => { } },
22 test => { requires => {
23 'Test::More' => 0,
24 } },
25 runtime => {
26 requires => { },
27 recommends => {
28 %extra_prereqs,
b3ee5181 29 perl => '5.006',
2c87c763 30 },
31 },
32 develop => { requires => {
33 %extra_prereqs,
34 } },
35 },
36 resources => {
37 # r/w: p5sagit@git.shadowcat.co.uk:strictures.git
38 repository => {
39 url => 'git://git.shadowcat.co.uk/p5sagit/strictures.git',
40 web => 'http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit/strictures.git',
41 type => 'git',
42 },
43 bugtracker => {
44 mailto => 'bug-strictures@rt.cpan.org',
45 web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=strictures',
46 },
47 license => [ 'http://dev.perl.org/licenses/' ],
48 },
49 no_index => {
50 directory => [ 't', 'xt' ]
51 },
52);
53
54my %MM_ARGS = (
55 PREREQ_PM => {
56 ($] >= 5.008004 && $have_compiler ? %extra_prereqs : () )
57 },
c4a93abc 58 realclean => { FILES => [ 'Distar/', 'MANIFEST*' ] },
2c87c763 59);
60
ae3262c9 61sub parse_args {
62 # copied from EUMM
2c87c763 63 require ExtUtils::MakeMaker;
64 require Text::ParseWords;
ae3262c9 65 ExtUtils::MakeMaker::parse_args(
66 my $tmp = {},
67 Text::ParseWords::shellwords($ENV{PERL_MM_OPT} || ''),
68 @ARGV,
69 );
70 return $tmp->{ARGS} || {};
71}
72
2c87c763 73##############################################################################
74require ExtUtils::MakeMaker;
75(do 'maint/Makefile.PL.include' or die $@) unless -f 'META.yml';
27826cd1 76
2c87c763 77# have to do this since old EUMM dev releases miss the eval $VERSION line
78my $eumm_version = eval $ExtUtils::MakeMaker::VERSION;
79my $mymeta = $eumm_version >= 6.57_02;
80my $mymeta_broken = $mymeta && $eumm_version < 6.57_07;
de111885 81
2c87c763 82($MM_ARGS{NAME} = $META{name}) =~ s/-/::/g;
83($MM_ARGS{VERSION_FROM} = "lib/$MM_ARGS{NAME}.pm") =~ s{::}{/}g;
84$MM_ARGS{LICENSE} = $META{license}
85 if $eumm_version >= 6.30;
86$MM_ARGS{NO_MYMETA} = 1
87 if $mymeta_broken;
88$MM_ARGS{META_ADD} = { 'meta-spec' => { version => 2 }, %META }
89 unless -f 'META.yml';
77f9ff76 90
2c87c763 91for (qw(configure build test runtime)) {
92 my $key = $_ eq 'runtime' ? 'PREREQ_PM' : uc $_.'_REQUIRES';
93 my $r = $MM_ARGS{$key} = {
2ef98edd 94 %{$META{prereqs}{$_}{requires} || {}},
2c87c763 95 %{delete $MM_ARGS{$key} || {}},
96 };
97 defined $r->{$_} or delete $r->{$_} for keys %$r;
98}
dfdfcbae 99
2c87c763 100$MM_ARGS{MIN_PERL_VERSION} = delete $MM_ARGS{PREREQ_PM}{perl} || 0;
5468e090 101
2c87c763 102delete $MM_ARGS{MIN_PERL_VERSION}
103 if $eumm_version < 6.47_01;
104$MM_ARGS{BUILD_REQUIRES} = {%{$MM_ARGS{BUILD_REQUIRES}}, %{delete $MM_ARGS{TEST_REQUIRES}}}
105 if $eumm_version < 6.63_03;
106$MM_ARGS{PREREQ_PM} = {%{$MM_ARGS{PREREQ_PM}}, %{delete $MM_ARGS{BUILD_REQUIRES}}}
107 if $eumm_version < 6.55_01;
108delete $MM_ARGS{CONFIGURE_REQUIRES}
109 if $eumm_version < 6.51_03;
110
111ExtUtils::MakeMaker::WriteMakefile(%MM_ARGS);