Commit | Line | Data |
fa84e425 |
1 | use strict; |
2 | use warnings; |
3 | use 5.008001; |
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.88', |
12 | ); |
13 | |
14 | my %RUN_DEPS = ( |
15 | 'Package::Stash' => '0.23', |
727a1a2f |
16 | 'B::Hooks::EndOfScope' => '0.12', |
fa84e425 |
17 | ); |
18 | |
727a1a2f |
19 | # these pieces are needed if using the debugger on the perl range |
20 | my %OPT_RUN_DEPS = ( $] > 5.008_008_9 and $] < 5.013_005_1 and can_xs() ) |
21 | # when changing versions, also change $sn_ver and $si_ver in namespace/clean.pm |
22 | ? ( 'Sub::Name' => '0.04', 'Sub::Identify' => '0.04' ) : () |
23 | ; |
4e908301 |
24 | |
fa84e425 |
25 | my %META_BITS = ( |
26 | resources => { |
27 | homepage => 'http://search.cpan.org/dist/namespace-clean', |
28 | |
29 | # EUMM not supporting nested meta :( |
30 | #repository => { |
31 | # type => 'git', |
842fcd09 |
32 | # url => 'git://git.shadowcat.co.uk/p5sagit/namespace-clean.git', |
fa84e425 |
33 | # web => 'http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit/namespace-clean.git', |
34 | #} |
35 | #bugtracker => { |
36 | # mailto => 'bug-namespace-clean@rt.cpan.org', |
37 | # web => 'http://rt.cpan.org/Public/Dist/Display.html?Name=namespace-clean', |
38 | #}, |
39 | |
842fcd09 |
40 | repository => 'git://git.shadowcat.co.uk/p5sagit/namespace-clean.git', |
fa84e425 |
41 | bugtracker => 'http://rt.cpan.org/Public/Dist/Display.html?Name=namespace-clean', |
42 | }, |
43 | ); |
44 | |
45 | my %WriteMakefileArgs = ( |
46 | 'NAME' => 'namespace::clean', |
47 | 'VERSION_FROM' => 'lib/namespace/clean.pm', |
48 | 'ABSTRACT' => 'Keep imports and functions out of your namespace', |
49 | 'AUTHOR' => 'Robert \'phaylon\' Sedlacek <rs@474.at>, Florian Ragwitz <rafl@debian.org>, Jesse Luehrs <doy@tozt.net>', |
727a1a2f |
50 | 'CONFIGURE_REQUIRES' => { 'ExtUtils::CBuilder' => 0.27 }, |
51 | 'PREREQ_PM' => { |
4e908301 |
52 | %RUN_DEPS, %OPT_RUN_DEPS, |
fa84e425 |
53 | $mymeta_works ? () : (%BUILD_DEPS), |
54 | }, |
55 | |
56 | $mymeta_works |
57 | ? ( # BUILD_REQUIRES makes MYMETA right, requires stops META being wrong |
58 | 'BUILD_REQUIRES' => \%BUILD_DEPS, |
59 | 'META_ADD' => { |
60 | %META_BITS, |
61 | requires => \%RUN_DEPS, |
62 | }, |
63 | ) |
64 | : ( # META_ADD both to get META right - only Makefile written |
65 | 'META_ADD' => { |
66 | %META_BITS, |
67 | requires => \%RUN_DEPS, |
68 | build_requires => \%BUILD_DEPS, |
69 | }, |
70 | ) |
71 | , |
72 | |
73 | ($mymeta and !$mymeta_works) ? ( 'NO_MYMETA' => 1 ) : (), |
74 | |
75 | 'LICENSE' => 'perl', |
76 | ); |
77 | |
78 | |
79 | unless ( eval { ExtUtils::MakeMaker->VERSION('6.56') } ) { |
80 | my $br = delete $WriteMakefileArgs{BUILD_REQUIRES}; |
81 | my $pp = $WriteMakefileArgs{PREREQ_PM}; |
82 | for my $mod ( keys %$br ) { |
83 | if ( exists $pp->{$mod} ) { |
84 | $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod}; |
85 | } |
86 | else { |
87 | $pp->{$mod} = $br->{$mod}; |
88 | } |
89 | } |
90 | } |
91 | |
92 | delete $WriteMakefileArgs{CONFIGURE_REQUIRES} |
93 | unless eval { ExtUtils::MakeMaker->VERSION('6.52') }; |
94 | |
95 | WriteMakefile(%WriteMakefileArgs); |
96 | |
727a1a2f |
97 | # Secondary compile testing via ExtUtils::CBuilder |
98 | sub can_xs { |
99 | # Do we have the configure_requires checker? |
100 | local $@; |
101 | eval "require ExtUtils::CBuilder;"; |
86aef219 |
102 | if ( $@ ) { |
727a1a2f |
103 | # They don't obey configure_requires, so it is |
104 | # someone old and delicate. Try to avoid hurting |
105 | # them by falling back to an older simpler test. |
106 | return can_cc(); |
107 | } |
108 | |
109 | return ExtUtils::CBuilder->new( quiet => 1 )->have_compiler; |
110 | } |
fa84e425 |
111 | |
112 | # can we locate a (the) C compiler |
113 | sub can_cc { |
114 | my @chunks = split(/ /, $Config::Config{cc}) or return; |
115 | |
116 | # $Config{cc} may contain args; try to find out the program part |
117 | while (@chunks) { |
118 | return can_run("@chunks") || (pop(@chunks), next); |
119 | } |
120 | |
121 | return; |
122 | } |
123 | |
124 | # check if we can run some command |
125 | sub can_run { |
126 | my ($cmd) = @_; |
127 | |
128 | return $cmd if -x $cmd; |
129 | if (my $found_cmd = MM->maybe_command($cmd)) { |
130 | return $found_cmd; |
131 | } |
132 | |
133 | for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') { |
134 | next if $dir eq ''; |
135 | my $abs = File::Spec->catfile($dir, $cmd); |
136 | return $abs if (-x $abs or $abs = MM->maybe_command($abs)); |
137 | } |
138 | |
139 | return; |
140 | } |