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