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