include ExtUtils::HasCompiler in dist as intended
[gitmo/Class-C3.git] / Makefile.PL
1 use strict;
2 use warnings FATAL => 'all';
3 use 5.006;
4 use lib 'inc';
5 use ExtUtils::HasCompiler qw(can_compile_loadable_object);
6
7 my %META = (
8   name => 'Class-C3',
9   license => 'perl_5',
10   prereqs => {
11     configure => { requires => {
12       'ExtUtils::MakeMaker'   => 0,
13     } },
14     build => { requires => {
15     } },
16     test => {
17       requires => {
18         'Test::More' => '0.47',
19       },
20     },
21     runtime => {
22       requires => {
23         'Algorithm::C3' => '0.07',
24         'Scalar::Util'  => '0',
25         'perl'          => 5.006,
26       },
27     },
28     develop   => {
29       requires => { map { $_ => 0 } qw(
30         indirect multidimensional bareword::filehandles
31         Moose Mouse namespace::clean namespace::autoclean
32         MooseX::Types::Common::Numeric
33         Type::Tiny
34       ) },
35     },
36   },
37   resources => {
38     repository => {
39       url => 'git://git.shadowcat.co.uk/gitmo/Class-C3.git',
40       web => 'http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo/Class-C3.git',
41       type => 'git',
42     },
43     bugtracker => {
44       web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=Class-C3',
45       mailto => 'bug-Class-C3@rt.cpan.org',
46     },
47     homepage => 'https://metacpan.org/release/Class-C3',
48     license => [ 'http://dev.perl.org/licenses/' ],
49   },
50   no_index => {
51     directory => [ 't', 'xt', 'opt', 'inc' ]
52   },
53 );
54
55 my %MM_ARGS = (
56   TEST_REQUIRES => {
57     ( $] < 5.009_005 and is_smoker() )
58       ? ( 'Devel::Hide' => 0 ) : ()
59   },
60   PREREQ_PM => {
61     ( $] < 5.009_005 and can_compile_loadable_object(quiet => 1) )
62       ? ( 'Class::C3::XS'  => '0.13' ) : ()
63   },
64 );
65
66 sub is_smoker {
67   return ( $ENV{AUTOMATED_TESTING} && ! $ENV{PERL5_CPANM_IS_RUNNING} && ! $ENV{RELEASE_TESTING} )
68 }
69
70 ## BOILERPLATE ###############################################################
71 require ExtUtils::MakeMaker;
72 (do 'maint/Makefile.PL.include' or die $@) unless -f 'META.yml';
73
74 # have to do this since old EUMM dev releases miss the eval $VERSION line
75 my $eumm_version  = eval $ExtUtils::MakeMaker::VERSION;
76 my $mymeta        = $eumm_version >= 6.57_02;
77 my $mymeta_broken = $mymeta && $eumm_version < 6.57_07;
78
79 ($MM_ARGS{NAME} = $META{name}) =~ s/-/::/g;
80 ($MM_ARGS{VERSION_FROM} = "lib/$MM_ARGS{NAME}.pm") =~ s{::}{/}g;
81 $META{license} = [ $META{license} ]
82   if $META{license} && !ref $META{license};
83 $MM_ARGS{LICENSE} = $META{license}[0]
84   if $META{license} && $eumm_version >= 6.30;
85 $MM_ARGS{NO_MYMETA} = 1
86   if $mymeta_broken;
87 $MM_ARGS{META_ADD} = { 'meta-spec' => { version => 2 }, %META }
88   unless -f 'META.yml';
89
90 for (qw(configure build test runtime)) {
91   my $key = $_ eq 'runtime' ? 'PREREQ_PM' : uc $_.'_REQUIRES';
92   my $r = $MM_ARGS{$key} = {
93     %{$META{prereqs}{$_}{requires} || {}},
94     %{delete $MM_ARGS{$key} || {}},
95   };
96   defined $r->{$_} or delete $r->{$_} for keys %$r;
97 }
98
99 $MM_ARGS{MIN_PERL_VERSION} = delete $MM_ARGS{PREREQ_PM}{perl} || 0;
100
101 delete $MM_ARGS{MIN_PERL_VERSION}
102   if $eumm_version < 6.47_01;
103 $MM_ARGS{BUILD_REQUIRES} = {%{$MM_ARGS{BUILD_REQUIRES}}, %{delete $MM_ARGS{TEST_REQUIRES}}}
104   if $eumm_version < 6.63_03;
105 $MM_ARGS{PREREQ_PM} = {%{$MM_ARGS{PREREQ_PM}}, %{delete $MM_ARGS{BUILD_REQUIRES}}}
106   if $eumm_version < 6.55_01;
107 delete $MM_ARGS{CONFIGURE_REQUIRES}
108   if $eumm_version < 6.51_03;
109
110 ExtUtils::MakeMaker::WriteMakefile(%MM_ARGS);
111 ## END BOILERPLATE ###########################################################