drop Package::Stash dependency
[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,
18377f5b 22 }
23 },
24 runtime => {
25 requires => {
18377f5b 26 'B::Hooks::EndOfScope' => '0.12',
27 'perl' => '5.008001',
28 },
29 },
30 test => {
31 requires => {
39bc2d6e 32 'Test::More' => '0.47',
18377f5b 33 }
34 },
35 },
fa84e425 36
18377f5b 37 resources => {
38 x_IRC => 'irc://irc.perl.org/#toolchain',
39 homepage => 'http://search.cpan.org/dist/namespace-clean',
40 repository => {
41 type => 'git',
42 url => 'git://git.shadowcat.co.uk/p5sagit/namespace-clean.git',
dba82a0e 43 web => 'https://github.com/p5sagit/namespace-clean',
18377f5b 44 },
45 bugtracker => {
46 mailto => 'bug-namespace-clean@rt.cpan.org',
47 web => 'http://rt.cpan.org/Public/Dist/Display.html?Name=namespace-clean',
48 },
49 },
fa84e425 50);
51
18377f5b 52my %MM_ARGS = ( (
53 # a sub-namer is needed if using the debugger on some perls
c81fe1da 54 do {
55 # sigh... so much unmitigated stupidity on #p5p these days...
56 local @INC = ('lib', @INC);
57 require namespace::clean::_Util;
58 }
df4cbc4e 59 and
60 namespace::clean::_Util::DEBUGGER_NEEDS_CV_RENAME()
61 and
62 namespace::clean::_Util::_namer_load_error()
63 and
58cd9d45 64 usable_compiler_present()
df4cbc4e 65)
66 # when changing version, also change $sn_ver in namespace/clean/_Util.pm
18377f5b 67 ? ( PREREQ_PM => { 'Sub::Name' => '0.04' } )
df4cbc4e 68 : ()
69);
4e908301 70
58cd9d45 71## XS-checking BOILERPLATE ###################################################
72sub usable_compiler_present {
73 return 0 if parse_args()->{PUREPERL_ONLY};
74
75 my $ucp;
76
77 local $@;
78 eval {
79 # poor man's inc::latest
80 my $euhc_fn = 'ExtUtils/HasCompiler.pm';
81 my $euhc_found_in_INC_dir;
82
83 ( ($euhc_found_in_INC_dir) = grep {
84 not length ref $_
85 and
86 -f "$_/$euhc_fn"
87 and
88 -r "$_/$euhc_fn"
89 } @INC )
90 and
91 (
92 MM->parse_version("$euhc_found_in_INC_dir/$euhc_fn")
93 >
94 MM->parse_version("inc/$euhc_fn")
95 )
96 and
97 eval { require ExtUtils::HasCompiler };
98
99 unless ( $INC{'ExtUtils/HasCompiler.pm'} ) {
100 local @INC = ( "inc", @INC );
101 require ExtUtils::HasCompiler;
102 }
103
104 $ucp = ExtUtils::HasCompiler::can_compile_loadable_object(quiet => 1)
105 ? 1
106 : 0
107 ;
108
109 1;
110 };
111
112 if( my $used_fn = $INC{'ExtUtils/HasCompiler.pm'} ) {
113 printf
114 "ExtUtils::HasCompiler::can_compile_loadable_object() v%s (loaded from %s) returned: %s\n",
115 ExtUtils::HasCompiler->VERSION,
116 $used_fn,
117 ( defined($ucp) ? $ucp : "UNKNOWN" ),
118 ;
119 }
120 else {
121 print "Something went wrong when trying to load/use ExtUtils::HasCompiler:\n$@\n\n";
122 }
123
124 $ucp;
125}
126
127
128# FIXME - this has been cargo-culted from
129# https://metacpan.org/source/HAARG/strictures-2.000002/Makefile.PL
130# There likely will be better ways to handle %ENV and @ARGV directly within
131# EU::HC in the future
132sub parse_args {
133 # copied from EUMM
134 require ExtUtils::MakeMaker;
135 require Text::ParseWords;
136 ExtUtils::MakeMaker::parse_args(
137 my $tmp = {},
138 Text::ParseWords::shellwords($ENV{PERL_MM_OPT} || ''),
139 @ARGV,
140 );
141 return $tmp->{ARGS} || {};
142}
143## END XS-checking BOILERPLATE ###############################################
144
fa84e425 145
18377f5b 146## BOILERPLATE ###############################################################
147require ExtUtils::MakeMaker;
148
149# have to do this since old EUMM dev releases miss the eval $VERSION line
150my $eumm_version = eval $ExtUtils::MakeMaker::VERSION;
151my $mymeta = $eumm_version >= 6.57_02;
152my $mymeta_broken = $mymeta && $eumm_version < 6.57_07;
153
154($MM_ARGS{NAME} = $META{name}) =~ s/-/::/g;
155($MM_ARGS{VERSION_FROM} = "lib/$MM_ARGS{NAME}.pm") =~ s{::}{/}g;
156$META{license} = [ $META{license} ]
157 if $META{license} && !ref $META{license};
158$MM_ARGS{LICENSE} = $META{license}[0]
159 if $META{license} && $eumm_version >= 6.30;
160$MM_ARGS{NO_MYMETA} = 1
161 if $mymeta_broken;
162$MM_ARGS{META_ADD} = { 'meta-spec' => { version => 2 }, %META }
163 unless -f 'META.yml';
164
165for (qw(configure build test runtime)) {
166 my $key = $_ eq 'runtime' ? 'PREREQ_PM' : uc $_.'_REQUIRES';
167 my $r = $MM_ARGS{$key} = {
168 %{$META{prereqs}{$_}{requires} || {}},
169 %{delete $MM_ARGS{$key} || {}},
170 };
171 defined $r->{$_} or delete $r->{$_} for keys %$r;
fa84e425 172}
173
18377f5b 174$MM_ARGS{MIN_PERL_VERSION} = delete $MM_ARGS{PREREQ_PM}{perl} || 0;
fa84e425 175
18377f5b 176delete $MM_ARGS{MIN_PERL_VERSION}
177 if $eumm_version < 6.47_01;
178$MM_ARGS{BUILD_REQUIRES} = {%{$MM_ARGS{BUILD_REQUIRES}}, %{delete $MM_ARGS{TEST_REQUIRES}}}
179 if $eumm_version < 6.63_03;
180$MM_ARGS{PREREQ_PM} = {%{$MM_ARGS{PREREQ_PM}}, %{delete $MM_ARGS{BUILD_REQUIRES}}}
181 if $eumm_version < 6.55_01;
182delete $MM_ARGS{CONFIGURE_REQUIRES}
183 if $eumm_version < 6.51_03;
fa84e425 184
18377f5b 185ExtUtils::MakeMaker::WriteMakefile(%MM_ARGS);
186## END BOILERPLATE ###########################################################