explicitly set this meta variable
[p5sagit/strictures.git] / Makefile.PL
1 use strict;
2 use warnings FATAL => 'all';
3 use 5.006;
4 use lib 'inc';
5 use ExtUtils::HasCompiler 'can_compile_loadable_object';
6
7 my $have_compiler
8   = ! parse_args()->{PUREPERL_ONLY}
9   && can_compile_loadable_object(quiet => 1);
10
11 my %extra_prereqs = (
12   indirect => 0,
13   multidimensional => 0,
14   'bareword::filehandles' => 0,
15 );
16
17 my %META = (
18   name => 'strictures',
19   license => 'perl_5',
20   dynamic_config => 1,
21   prereqs => {
22     configure => { requires => { } },
23     build => { requires => { } },
24     test => { requires => {
25       'Test::More' => 0,
26     } },
27     runtime => {
28       requires => {
29         perl => '5.006',
30       },
31       suggests => {
32         %extra_prereqs,
33       },
34     },
35     develop => { requires => {
36       'Test::Pod' => 0,
37       'Test::Pod::Coverage' => 0,
38       'Pod::Coverage::CountParents' => 0,
39       %extra_prereqs,
40     } },
41   },
42   resources => {
43     # GitHub mirrors from Shadowcat. We list it so we can get pull requests.
44     # The canonical repo is:
45     # r/o: git://git.shadowcat.co.uk/p5sagit/strictures.git
46     # r/w: p5sagit@git.shadowcat.co.uk:strictures.git
47     # web: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit/strictures.git
48     repository => {
49       url => 'https://github.com/p5sagit/strictures.git',
50       web => 'https://github.com/p5sagit/strictures',
51       type => 'git',
52     },
53     bugtracker => {
54       mailto => 'bug-strictures@rt.cpan.org',
55       web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=strictures',
56     },
57     license => [ 'http://dev.perl.org/licenses/' ],
58   },
59   no_index => {
60     directory => [ 't', 'xt', 'inc' ]
61   },
62   x_authority => 'cpan:MSTROUT',
63 );
64
65 my %MM_ARGS = (
66   PREREQ_PM => {
67     ("$]" >= 5.008004 && $have_compiler ? %extra_prereqs : () )
68   },
69 );
70
71 sub parse_args {
72   # copied from EUMM
73   require ExtUtils::MakeMaker;
74   require Text::ParseWords;
75   ExtUtils::MakeMaker::parse_args(
76     my $tmp = {},
77     Text::ParseWords::shellwords($ENV{PERL_MM_OPT} || ''),
78     @ARGV,
79   );
80   return $tmp->{ARGS} || {};
81 }
82
83 ## BOILERPLATE ###############################################################
84 require ExtUtils::MakeMaker;
85 (do './maint/Makefile.PL.include' or die $@) unless -f 'META.yml';
86
87 # have to do this since old EUMM dev releases miss the eval $VERSION line
88 my $eumm_version  = eval $ExtUtils::MakeMaker::VERSION;
89 my $mymeta        = $eumm_version >= 6.57_02;
90 my $mymeta_broken = $mymeta && $eumm_version < 6.57_07;
91
92 ($MM_ARGS{NAME} = $META{name}) =~ s/-/::/g;
93 ($MM_ARGS{VERSION_FROM} = "lib/$MM_ARGS{NAME}.pm") =~ s{::}{/}g;
94 $META{license} = [ $META{license} ]
95   if $META{license} && !ref $META{license};
96 $MM_ARGS{LICENSE} = $META{license}[0]
97   if $META{license} && $eumm_version >= 6.30;
98 $MM_ARGS{NO_MYMETA} = 1
99   if $mymeta_broken;
100 $MM_ARGS{META_ADD} = { 'meta-spec' => { version => 2 }, %META }
101   unless -f 'META.yml';
102
103 for (qw(configure build test runtime)) {
104   my $key = $_ eq 'runtime' ? 'PREREQ_PM' : uc $_.'_REQUIRES';
105   my $r = $MM_ARGS{$key} = {
106     %{$META{prereqs}{$_}{requires} || {}},
107     %{delete $MM_ARGS{$key} || {}},
108   };
109   defined $r->{$_} or delete $r->{$_} for keys %$r;
110 }
111
112 $MM_ARGS{MIN_PERL_VERSION} = delete $MM_ARGS{PREREQ_PM}{perl} || 0;
113
114 delete $MM_ARGS{MIN_PERL_VERSION}
115   if $eumm_version < 6.47_01;
116 $MM_ARGS{BUILD_REQUIRES} = {%{$MM_ARGS{BUILD_REQUIRES}}, %{delete $MM_ARGS{TEST_REQUIRES}}}
117   if $eumm_version < 6.63_03;
118 $MM_ARGS{PREREQ_PM} = {%{$MM_ARGS{PREREQ_PM}}, %{delete $MM_ARGS{BUILD_REQUIRES}}}
119   if $eumm_version < 6.55_01;
120 delete $MM_ARGS{CONFIGURE_REQUIRES}
121   if $eumm_version < 6.51_03;
122
123 ExtUtils::MakeMaker::WriteMakefile(%MM_ARGS);
124 ## END BOILERPLATE ###########################################################