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