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