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