remove extraneous garbage from tests
[gitmo/Class-C3.git] / Makefile.PL
CommitLineData
e861fe16 1use strict;
e3c0c9d3 2use warnings;
3use 5.006;
4
5use ExtUtils::MakeMaker;
6
7my $mymeta_works = eval { ExtUtils::MakeMaker->VERSION('6.5707'); 1 };
8my $mymeta = $mymeta_works || eval { ExtUtils::MakeMaker->VERSION('6.5702'); 1 };
9
10my %BUILD_DEPS = (
11 'Test::More' => '0.47',
12);
13my %OPT_BUILD_DEPS = ( $] < 5.009_005 and is_smoker() )
14 ? ( 'Devel::Hide' => 0 ) : ()
15;
56215427 16
e3c0c9d3 17my %RUN_DEPS = (
18 # needed by the PP version only, have them installed
19 # regardless of XS availability or perl version
20 # (for fatpacking and whatnot)
21 'Algorithm::C3' => '0.07',
22 'Scalar::Util' => '0',
23);
24my %OPT_RUN_DEPS = ( $] < 5.009_005 and can_xs() )
25 ? ( 'Class::C3::XS' => '0.13' ) : ()
26;
e861fe16 27
e3c0c9d3 28my %META_BITS = (
29 resources => {
30 homepage => 'http://search.cpan.org/dist/Class-C3',
31 repository => 'git://git.shadowcat.co.uk/gitmo/Class-C3.git',
32 bugtracker => 'http://rt.cpan.org/Public/Dist/Display.html?Name=Class-C3',
33 },
34);
56215427 35
e3c0c9d3 36my %WriteMakefileArgs = (
37 'NAME' => 'Class::C3',
38 'AUTHOR' => 'Stevan Little, <stevan@iinteractive.com>',
39 'VERSION_FROM' => 'lib/Class/C3.pm',
40 'ABSTRACT_FROM' => 'lib/Class/C3.pm',
41 'CONFIGURE_REQUIRES' => { 'ExtUtils::CBuilder' => 0.27 },
42 'PREREQ_PM' => {
43 %RUN_DEPS, %OPT_RUN_DEPS,
44 $mymeta_works ? () : (%BUILD_DEPS, %OPT_BUILD_DEPS),
45 },
56215427 46
e3c0c9d3 47 $mymeta_works
48 ? ( # BUILD_REQUIRES makes MYMETA right, requires stops META being wrong
49 'BUILD_REQUIRES' => { %BUILD_DEPS, %OPT_BUILD_DEPS },
50 'META_ADD' => {
51 %META_BITS,
52 requires => \%RUN_DEPS,
53 },
54 )
55 : ( # META_ADD both to get META right - only Makefile written
56 'META_ADD' => {
57 %META_BITS,
58 requires => \%RUN_DEPS,
59 build_requires => \%BUILD_DEPS,
60 },
61 )
62 ,
56215427 63
e3c0c9d3 64 ($mymeta and !$mymeta_works) ? ( 'NO_MYMETA' => 1 ) : (),
65
66 'LICENSE' => 'perl',
67);
68
69
70unless ( eval { ExtUtils::MakeMaker->VERSION('6.56') } ) {
71 my $br = delete $WriteMakefileArgs{BUILD_REQUIRES};
72 my $pp = $WriteMakefileArgs{PREREQ_PM};
73 for my $mod ( keys %$br ) {
74 if ( exists $pp->{$mod} ) {
75 $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod};
76 }
77 else {
78 $pp->{$mod} = $br->{$mod};
79 }
80 }
38a897e9 81}
e861fe16 82
e3c0c9d3 83delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
84 unless eval { ExtUtils::MakeMaker->VERSION('6.52') };
85
86system("pod2text lib/Class/C3.pm >README")
87 unless -f 'META.yml';
56215427 88
e3c0c9d3 89WriteMakefile(%WriteMakefileArgs);
90
91# Secondary compile testing via ExtUtils::CBuilder
92sub can_xs {
93 # Do we have the configure_requires checker?
94 local $@;
95 eval "require ExtUtils::CBuilder;";
4dcc1329 96 if ( $@ ) {
e3c0c9d3 97 # They don't obey configure_requires, so it is
98 # someone old and delicate. Try to avoid hurting
99 # them by falling back to an older simpler test.
100 return can_cc();
101 }
102
103 return ExtUtils::CBuilder->new( quiet => 1 )->have_compiler;
104}
105
106# can we locate a (the) C compiler
107sub can_cc {
108 my @chunks = split(/ /, $Config::Config{cc}) or return;
109
110 # $Config{cc} may contain args; try to find out the program part
111 while (@chunks) {
112 return can_run("@chunks") || (pop(@chunks), next);
113 }
114
115 return;
26626902 116}
117
e3c0c9d3 118# check if we can run some command
119sub can_run {
120 my ($cmd) = @_;
121
122 return $cmd if -x $cmd;
123 if (my $found_cmd = MM->maybe_command($cmd)) {
124 return $found_cmd;
125 }
126
127 for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
128 next if $dir eq '';
129 my $abs = File::Spec->catfile($dir, $cmd);
130 return $abs if (-x $abs or $abs = MM->maybe_command($abs));
131 }
e861fe16 132
e3c0c9d3 133 return;
e861fe16 134}
135
136sub is_smoker {
137 return ( $ENV{AUTOMATED_TESTING} && ! $ENV{PERL5_CPANM_IS_RUNNING} && ! $ENV{RELEASE_TESTING} )
138}