use archive.org link for dylan paper as original has gone offline
[gitmo/Class-C3.git] / Makefile.PL
1 use strict;
2 use warnings FATAL => 'all';
3 use 5.006;
4
5 my %META = (
6   name => 'Class-C3',
7   license => 'perl_5',
8   prereqs => {
9     configure => { requires => {
10       'ExtUtils::MakeMaker'   => 0,
11       'ExtUtils::CBuilder'    => 0.27,
12     } },
13     build => { requires => {
14     } },
15     test => {
16       requires => {
17         'Test::More' => '0.47',
18       },
19     },
20     runtime => {
21       requires => {
22         'Algorithm::C3' => '0.07',
23         'Scalar::Util'  => '0',
24         'perl'          => 5.006,
25       },
26     },
27     develop   => {
28       requires => { map { $_ => 0 } qw(
29         indirect multidimensional bareword::filehandles
30         Moose Mouse namespace::clean namespace::autoclean
31         MooseX::Types::Common::Numeric
32         Type::Tiny
33       ) },
34     },
35   },
36   resources => {
37     repository => {
38       url => 'git://git.shadowcat.co.uk/gitmo/Class-C3.git',
39       web => 'http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo/Class-C3.git',
40       type => 'git',
41     },
42     bugtracker => {
43       web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=Class-C3',
44       mailto => 'bug-Class-C3@rt.cpan.org',
45     },
46     homepage => 'https://metacpan.org/release/Class-C3',
47     license => [ 'http://dev.perl.org/licenses/' ],
48   },
49   no_index => {
50     directory => [ 't', 'xt', 'opt' ]
51   },
52 );
53
54 my %MM_ARGS = (
55   TEST_REQUIRES => {
56     ( $] < 5.009_005 and is_smoker() )
57       ? ( 'Devel::Hide' => 0 ) : ()
58   },
59   PREREQ_PM => {
60     ( $] < 5.009_005 and can_xs() )
61       ? ( 'Class::C3::XS'  => '0.13' ) : ()
62   },
63 );
64
65 # Secondary compile testing via ExtUtils::CBuilder
66 sub can_xs {
67   # Do we have the configure_requires checker?
68   local $@;
69   eval "require ExtUtils::CBuilder;";
70   if ( $@ ) {
71     # They don't obey configure_requires, so it is
72     # someone old and delicate. Try to avoid hurting
73     # them by falling back to an older simpler test.
74     return can_cc();
75   }
76
77   return ExtUtils::CBuilder->new( quiet => 1 )->have_compiler;
78 }
79
80 # can we locate a (the) C compiler
81 sub can_cc {
82   my @chunks = split(/ /, $Config::Config{cc}) or return;
83
84   # $Config{cc} may contain args; try to find out the program part
85   while (@chunks) {
86     return can_run("@chunks") || (pop(@chunks), next);
87   }
88
89   return;
90 }
91
92 # check if we can run some command
93 sub can_run {
94   my ($cmd) = @_;
95
96   return $cmd if -x $cmd;
97   if (my $found_cmd = MM->maybe_command($cmd)) {
98     return $found_cmd;
99   }
100
101   for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
102     next if $dir eq '';
103     my $abs = File::Spec->catfile($dir, $cmd);
104     return $abs if (-x $abs or $abs = MM->maybe_command($abs));
105   }
106
107   return;
108 }
109
110 sub is_smoker {
111   return ( $ENV{AUTOMATED_TESTING} && ! $ENV{PERL5_CPANM_IS_RUNNING} && ! $ENV{RELEASE_TESTING} )
112 }
113
114 ## BOILERPLATE ###############################################################
115 require ExtUtils::MakeMaker;
116 (do 'maint/Makefile.PL.include' or die $@) unless -f 'META.yml';
117
118 # have to do this since old EUMM dev releases miss the eval $VERSION line
119 my $eumm_version  = eval $ExtUtils::MakeMaker::VERSION;
120 my $mymeta        = $eumm_version >= 6.57_02;
121 my $mymeta_broken = $mymeta && $eumm_version < 6.57_07;
122
123 ($MM_ARGS{NAME} = $META{name}) =~ s/-/::/g;
124 ($MM_ARGS{VERSION_FROM} = "lib/$MM_ARGS{NAME}.pm") =~ s{::}{/}g;
125 $META{license} = [ $META{license} ]
126   if $META{license} && !ref $META{license};
127 $MM_ARGS{LICENSE} = $META{license}[0]
128   if $META{license} && $eumm_version >= 6.30;
129 $MM_ARGS{NO_MYMETA} = 1
130   if $mymeta_broken;
131 $MM_ARGS{META_ADD} = { 'meta-spec' => { version => 2 }, %META }
132   unless -f 'META.yml';
133
134 for (qw(configure build test runtime)) {
135   my $key = $_ eq 'runtime' ? 'PREREQ_PM' : uc $_.'_REQUIRES';
136   my $r = $MM_ARGS{$key} = {
137     %{$META{prereqs}{$_}{requires} || {}},
138     %{delete $MM_ARGS{$key} || {}},
139   };
140   defined $r->{$_} or delete $r->{$_} for keys %$r;
141 }
142
143 $MM_ARGS{MIN_PERL_VERSION} = delete $MM_ARGS{PREREQ_PM}{perl} || 0;
144
145 delete $MM_ARGS{MIN_PERL_VERSION}
146   if $eumm_version < 6.47_01;
147 $MM_ARGS{BUILD_REQUIRES} = {%{$MM_ARGS{BUILD_REQUIRES}}, %{delete $MM_ARGS{TEST_REQUIRES}}}
148   if $eumm_version < 6.63_03;
149 $MM_ARGS{PREREQ_PM} = {%{$MM_ARGS{PREREQ_PM}}, %{delete $MM_ARGS{BUILD_REQUIRES}}}
150   if $eumm_version < 6.55_01;
151 delete $MM_ARGS{CONFIGURE_REQUIRES}
152   if $eumm_version < 6.51_03;
153
154 ExtUtils::MakeMaker::WriteMakefile(%MM_ARGS);
155 ## END BOILERPLATE ###########################################################