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