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', |
16 | can_cc() ? ( |
17 | 'B::Hooks::EndOfScope' => '0.07', # when changing, also change version in namespace/clean.pm |
18 | is_smoker() ? ( 'Devel::Hide' => 0 ) : (), # make sure we smoke the pure-perl version |
19 | ) : (), |
20 | ); |
21 | |
22 | my %META_BITS = ( |
23 | resources => { |
24 | homepage => 'http://search.cpan.org/dist/namespace-clean', |
25 | |
26 | # EUMM not supporting nested meta :( |
27 | #repository => { |
28 | # type => 'git', |
842fcd09 |
29 | # url => 'git://git.shadowcat.co.uk/p5sagit/namespace-clean.git', |
fa84e425 |
30 | # web => 'http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit/namespace-clean.git', |
31 | #} |
32 | #bugtracker => { |
33 | # mailto => 'bug-namespace-clean@rt.cpan.org', |
34 | # web => 'http://rt.cpan.org/Public/Dist/Display.html?Name=namespace-clean', |
35 | #}, |
36 | |
842fcd09 |
37 | repository => 'git://git.shadowcat.co.uk/p5sagit/namespace-clean.git', |
fa84e425 |
38 | bugtracker => 'http://rt.cpan.org/Public/Dist/Display.html?Name=namespace-clean', |
39 | }, |
40 | ); |
41 | |
42 | my %WriteMakefileArgs = ( |
43 | 'NAME' => 'namespace::clean', |
44 | 'VERSION_FROM' => 'lib/namespace/clean.pm', |
45 | 'ABSTRACT' => 'Keep imports and functions out of your namespace', |
46 | 'AUTHOR' => 'Robert \'phaylon\' Sedlacek <rs@474.at>, Florian Ragwitz <rafl@debian.org>, Jesse Luehrs <doy@tozt.net>', |
47 | |
48 | 'PREREQ_PM' => { |
49 | %RUN_DEPS, |
50 | $mymeta_works ? () : (%BUILD_DEPS), |
51 | }, |
52 | |
53 | $mymeta_works |
54 | ? ( # BUILD_REQUIRES makes MYMETA right, requires stops META being wrong |
55 | 'BUILD_REQUIRES' => \%BUILD_DEPS, |
56 | 'META_ADD' => { |
57 | %META_BITS, |
58 | requires => \%RUN_DEPS, |
59 | }, |
60 | ) |
61 | : ( # META_ADD both to get META right - only Makefile written |
62 | 'META_ADD' => { |
63 | %META_BITS, |
64 | requires => \%RUN_DEPS, |
65 | build_requires => \%BUILD_DEPS, |
66 | }, |
67 | ) |
68 | , |
69 | |
70 | ($mymeta and !$mymeta_works) ? ( 'NO_MYMETA' => 1 ) : (), |
71 | |
72 | 'LICENSE' => 'perl', |
73 | ); |
74 | |
75 | |
76 | unless ( eval { ExtUtils::MakeMaker->VERSION('6.56') } ) { |
77 | my $br = delete $WriteMakefileArgs{BUILD_REQUIRES}; |
78 | my $pp = $WriteMakefileArgs{PREREQ_PM}; |
79 | for my $mod ( keys %$br ) { |
80 | if ( exists $pp->{$mod} ) { |
81 | $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod}; |
82 | } |
83 | else { |
84 | $pp->{$mod} = $br->{$mod}; |
85 | } |
86 | } |
87 | } |
88 | |
89 | delete $WriteMakefileArgs{CONFIGURE_REQUIRES} |
90 | unless eval { ExtUtils::MakeMaker->VERSION('6.52') }; |
91 | |
92 | WriteMakefile(%WriteMakefileArgs); |
93 | |
94 | |
95 | # can we locate a (the) C compiler |
96 | sub can_cc { |
97 | my @chunks = split(/ /, $Config::Config{cc}) or return; |
98 | |
99 | # $Config{cc} may contain args; try to find out the program part |
100 | while (@chunks) { |
101 | return can_run("@chunks") || (pop(@chunks), next); |
102 | } |
103 | |
104 | return; |
105 | } |
106 | |
107 | # check if we can run some command |
108 | sub can_run { |
109 | my ($cmd) = @_; |
110 | |
111 | return $cmd if -x $cmd; |
112 | if (my $found_cmd = MM->maybe_command($cmd)) { |
113 | return $found_cmd; |
114 | } |
115 | |
116 | for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') { |
117 | next if $dir eq ''; |
118 | my $abs = File::Spec->catfile($dir, $cmd); |
119 | return $abs if (-x $abs or $abs = MM->maybe_command($abs)); |
120 | } |
121 | |
122 | return; |
123 | } |
124 | |
125 | sub is_smoker { |
126 | return ( $ENV{AUTOMATED_TESTING} && ! $ENV{PERL5_CPANM_IS_RUNNING} && ! $ENV{RELEASE_TESTING} ) |
127 | } |