distar-ify
[gitmo/Class-C3.git] / Makefile.PL
CommitLineData
e861fe16 1use strict;
9ab3d5c3 2use warnings FATAL => 'all';
e3c0c9d3 3use 5.006;
4
9ab3d5c3 5my %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 },
e3c0c9d3 36 resources => {
9ab3d5c3 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' ]
e3c0c9d3 51 },
52);
56215427 53
9ab3d5c3 54my %MM_ARGS = (
55 TEST_REQUIRES => {
56 ( $] < 5.009_005 and is_smoker() )
57 ? ( 'Devel::Hide' => 0 ) : ()
e3c0c9d3 58 },
9ab3d5c3 59 PREREQ_PM => {
60 ( $] < 5.009_005 and can_xs() )
61 ? ( 'Class::C3::XS' => '0.13' ) : ()
62 },
63);
56215427 64
9ab3d5c3 65##############################################################################
66require ExtUtils::MakeMaker;
67(do 'maint/Makefile.PL.include' or die $@) unless -f 'META.yml';
e3c0c9d3 68
9ab3d5c3 69# have to do this since old EUMM dev releases miss the eval $VERSION line
70my $eumm_version = eval $ExtUtils::MakeMaker::VERSION;
71my $mymeta = $eumm_version >= 6.57_02;
72my $mymeta_broken = $mymeta && $eumm_version < 6.57_07;
e3c0c9d3 73
9ab3d5c3 74($MM_ARGS{NAME} = $META{name}) =~ s/-/::/g;
75($MM_ARGS{VERSION_FROM} = "lib/$MM_ARGS{NAME}.pm") =~ s{::}{/}g;
76$MM_ARGS{LICENSE} = $META{license}
77 if $eumm_version >= 6.30;
78$MM_ARGS{NO_MYMETA} = 1
79 if $mymeta_broken;
80$MM_ARGS{META_ADD} = { 'meta-spec' => { version => 2 }, %META }
81 unless -f 'META.yml';
e3c0c9d3 82
9ab3d5c3 83for (qw(configure build test runtime)) {
84 my $key = $_ eq 'runtime' ? 'PREREQ_PM' : uc $_.'_REQUIRES';
85 my $r = $MM_ARGS{$key} = {
86 %{$META{prereqs}{$_}{requires} || {}},
87 %{delete $MM_ARGS{$key} || {}},
88 };
89 defined $r->{$_} or delete $r->{$_} for keys %$r;
38a897e9 90}
e861fe16 91
9ab3d5c3 92$MM_ARGS{MIN_PERL_VERSION} = delete $MM_ARGS{PREREQ_PM}{perl} || 0;
e3c0c9d3 93
9ab3d5c3 94delete $MM_ARGS{MIN_PERL_VERSION}
95 if $eumm_version < 6.47_01;
96$MM_ARGS{BUILD_REQUIRES} = {%{$MM_ARGS{BUILD_REQUIRES}}, %{delete $MM_ARGS{TEST_REQUIRES}}}
97 if $eumm_version < 6.63_03;
98$MM_ARGS{PREREQ_PM} = {%{$MM_ARGS{PREREQ_PM}}, %{delete $MM_ARGS{BUILD_REQUIRES}}}
99 if $eumm_version < 6.55_01;
100delete $MM_ARGS{CONFIGURE_REQUIRES}
101 if $eumm_version < 6.51_03;
56215427 102
9ab3d5c3 103ExtUtils::MakeMaker::WriteMakefile(%MM_ARGS);
104##############################################################################
e3c0c9d3 105
106# Secondary compile testing via ExtUtils::CBuilder
107sub can_xs {
108 # Do we have the configure_requires checker?
109 local $@;
110 eval "require ExtUtils::CBuilder;";
4dcc1329 111 if ( $@ ) {
e3c0c9d3 112 # They don't obey configure_requires, so it is
113 # someone old and delicate. Try to avoid hurting
114 # them by falling back to an older simpler test.
115 return can_cc();
116 }
117
118 return ExtUtils::CBuilder->new( quiet => 1 )->have_compiler;
119}
120
121# can we locate a (the) C compiler
122sub can_cc {
123 my @chunks = split(/ /, $Config::Config{cc}) or return;
124
125 # $Config{cc} may contain args; try to find out the program part
126 while (@chunks) {
127 return can_run("@chunks") || (pop(@chunks), next);
128 }
129
130 return;
26626902 131}
132
e3c0c9d3 133# check if we can run some command
134sub can_run {
135 my ($cmd) = @_;
136
137 return $cmd if -x $cmd;
138 if (my $found_cmd = MM->maybe_command($cmd)) {
139 return $found_cmd;
140 }
141
142 for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
143 next if $dir eq '';
144 my $abs = File::Spec->catfile($dir, $cmd);
145 return $abs if (-x $abs or $abs = MM->maybe_command($abs));
146 }
e861fe16 147
e3c0c9d3 148 return;
e861fe16 149}
150
151sub is_smoker {
152 return ( $ENV{AUTOMATED_TESTING} && ! $ENV{PERL5_CPANM_IS_RUNNING} && ! $ENV{RELEASE_TESTING} )
153}