Switch to GH url in meta for metacpan's sake
[p5sagit/namespace-clean.git] / Makefile.PL
CommitLineData
fa84e425 1use strict;
2use warnings;
3use 5.008001;
4
18377f5b 5my %META = (
e5233d43 6 name => 'namespace-clean',
18377f5b 7 license => 'perl_5',
8
9 abstract => 'Keep imports and functions out of your namespace',
10 author => [
11 'Robert \'phaylon\' Sedlacek <rs@474.at>',
12 'Florian Ragwitz <rafl@debian.org>',
13 'Jesse Luehrs <doy@tozt.net>',
14 'Peter Rabbitson <ribasushi@cpan.org>',
15 'Father Chrysostomos <sprout@cpan.org>',
16 ],
17
18 prereqs => {
19 configure => {
20 requires => {
21 'ExtUtils::MakeMaker' => 0,
22 'ExtUtils::CBuilder' => 0.27,
23 }
24 },
25 runtime => {
26 requires => {
27 'Package::Stash' => '0.23',
28 'B::Hooks::EndOfScope' => '0.12',
29 'perl' => '5.008001',
30 },
31 },
32 test => {
33 requires => {
39bc2d6e 34 'Test::More' => '0.47',
18377f5b 35 }
36 },
37 },
fa84e425 38
18377f5b 39 resources => {
40 x_IRC => 'irc://irc.perl.org/#toolchain',
41 homepage => 'http://search.cpan.org/dist/namespace-clean',
42 repository => {
43 type => 'git',
44 url => 'git://git.shadowcat.co.uk/p5sagit/namespace-clean.git',
dba82a0e 45 web => 'https://github.com/p5sagit/namespace-clean',
18377f5b 46 },
47 bugtracker => {
48 mailto => 'bug-namespace-clean@rt.cpan.org',
49 web => 'http://rt.cpan.org/Public/Dist/Display.html?Name=namespace-clean',
50 },
51 },
fa84e425 52);
53
18377f5b 54my %MM_ARGS = ( (
55 # a sub-namer is needed if using the debugger on some perls
df4cbc4e 56 require 'lib/namespace/clean/_Util.pm'
57 and
58 namespace::clean::_Util::DEBUGGER_NEEDS_CV_RENAME()
59 and
60 namespace::clean::_Util::_namer_load_error()
61 and
62 can_xs()
63)
64 # when changing version, also change $sn_ver in namespace/clean/_Util.pm
18377f5b 65 ? ( PREREQ_PM => { 'Sub::Name' => '0.04' } )
df4cbc4e 66 : ()
67);
4e908301 68
fa84e425 69
18377f5b 70## BOILERPLATE ###############################################################
71require ExtUtils::MakeMaker;
72
73# have to do this since old EUMM dev releases miss the eval $VERSION line
74my $eumm_version = eval $ExtUtils::MakeMaker::VERSION;
75my $mymeta = $eumm_version >= 6.57_02;
76my $mymeta_broken = $mymeta && $eumm_version < 6.57_07;
77
78($MM_ARGS{NAME} = $META{name}) =~ s/-/::/g;
79($MM_ARGS{VERSION_FROM} = "lib/$MM_ARGS{NAME}.pm") =~ s{::}{/}g;
80$META{license} = [ $META{license} ]
81 if $META{license} && !ref $META{license};
82$MM_ARGS{LICENSE} = $META{license}[0]
83 if $META{license} && $eumm_version >= 6.30;
84$MM_ARGS{NO_MYMETA} = 1
85 if $mymeta_broken;
86$MM_ARGS{META_ADD} = { 'meta-spec' => { version => 2 }, %META }
87 unless -f 'META.yml';
88
89for (qw(configure build test runtime)) {
90 my $key = $_ eq 'runtime' ? 'PREREQ_PM' : uc $_.'_REQUIRES';
91 my $r = $MM_ARGS{$key} = {
92 %{$META{prereqs}{$_}{requires} || {}},
93 %{delete $MM_ARGS{$key} || {}},
94 };
95 defined $r->{$_} or delete $r->{$_} for keys %$r;
fa84e425 96}
97
18377f5b 98$MM_ARGS{MIN_PERL_VERSION} = delete $MM_ARGS{PREREQ_PM}{perl} || 0;
fa84e425 99
18377f5b 100delete $MM_ARGS{MIN_PERL_VERSION}
101 if $eumm_version < 6.47_01;
102$MM_ARGS{BUILD_REQUIRES} = {%{$MM_ARGS{BUILD_REQUIRES}}, %{delete $MM_ARGS{TEST_REQUIRES}}}
103 if $eumm_version < 6.63_03;
104$MM_ARGS{PREREQ_PM} = {%{$MM_ARGS{PREREQ_PM}}, %{delete $MM_ARGS{BUILD_REQUIRES}}}
105 if $eumm_version < 6.55_01;
106delete $MM_ARGS{CONFIGURE_REQUIRES}
107 if $eumm_version < 6.51_03;
fa84e425 108
18377f5b 109ExtUtils::MakeMaker::WriteMakefile(%MM_ARGS);
110## END BOILERPLATE ###########################################################
727a1a2f 111
fa84e425 112
18377f5b 113# FIXME
114# Need to replace with EU::HC, but too many changes for this release already
115###########################################
fa84e425 116# can we locate a (the) C compiler
117sub can_cc {
118 my @chunks = split(/ /, $Config::Config{cc}) or return;
119
120 # $Config{cc} may contain args; try to find out the program part
121 while (@chunks) {
122 return can_run("@chunks") || (pop(@chunks), next);
123 }
124
125 return;
126}
127
128# check if we can run some command
129sub can_run {
130 my ($cmd) = @_;
131
132 return $cmd if -x $cmd;
133 if (my $found_cmd = MM->maybe_command($cmd)) {
134 return $found_cmd;
135 }
136
18377f5b 137 require File::Spec;
fa84e425 138 for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
139 next if $dir eq '';
140 my $abs = File::Spec->catfile($dir, $cmd);
141 return $abs if (-x $abs or $abs = MM->maybe_command($abs));
142 }
143
144 return;
145}
18377f5b 146
147# Can our C compiler environment build XS files
148sub can_xs {
149 # Do we have the configure_requires checker?
150 local $@;
151 eval "require ExtUtils::CBuilder; ExtUtils::CBuilder->VERSION(0.27)";
152 if ( $@ ) {
153 # They don't obey configure_requires, so it is
154 # someone old and delicate. Try to avoid hurting
155 # them by falling back to an older simpler test.
156 return can_cc();
157 }
158
159 # Do we have a working C compiler
160 my $builder = ExtUtils::CBuilder->new(
161 quiet => 1,
162 );
163 unless ( $builder->have_compiler ) {
164 # No working C compiler
165 return 0;
166 }
167
168 # Write a C file representative of what XS becomes
169 require File::Temp;
170 my ( $FH, $tmpfile ) = File::Temp::tempfile(
171 "compilexs-XXXXX",
172 SUFFIX => '.c',
173 );
174 binmode $FH;
175 print $FH <<'END_C';
176#include "EXTERN.h"
177#include "perl.h"
178#include "XSUB.h"
179
180int main(int argc, char **argv) {
181 return 0;
182}
183
184int boot_sanexs() {
185 return 1;
186}
187
188END_C
189 close $FH;
190
191 # Can the C compiler access the same headers XS does
192 my @libs = ();
193 my $object = undef;
194 eval {
195 local $^W = 0;
196 $object = $builder->compile(
197 source => $tmpfile,
198 );
199 @libs = $builder->link(
200 objects => $object,
201 module_name => 'sanexs',
202 );
203 };
204 my $result = $@ ? 0 : 1;
205
206 # Clean up all the build files
207 foreach ( $tmpfile, $object, @libs ) {
208 next unless defined $_;
209 1 while unlink;
210 }
211
212 return $result;
213}