now always require Cpanel::JSON::XS, as long as a compiler is available
[p5sagit/JSON-MaybeXS.git] / Makefile.PL
CommitLineData
44459f01 1use strict;
2use warnings FATAL => 'all';
23db00ab 3use 5.006;
4use lib 'inc';
5use ExtUtils::HasCompiler qw(can_compile_loadable_object);
44459f01 6use ExtUtils::MakeMaker;
bd6b85ee 7
23db00ab 8my %META = (
9 name => 'JSON-MaybeXS',
10 license => 'perl_5',
11 dynamic_config => 1,
12 prereqs => {
13 configure => {
14 requires => {
15 'ExtUtils::MakeMaker' => '0',
bd6b85ee 16 },
17 },
23db00ab 18 runtime => {
19 requires => {
20 'Scalar::Util' => '0',
21 'Carp' => '0',
22 'JSON::PP' => '2.27300',
23 # we may also add a runtime prereq for Cpanel::JSON::XS, on the
24 # installer's machine
25 perl => '5.006',
037386f7 26 },
23db00ab 27 recommends => { 'Cpanel::JSON::XS' => '2.3310' },
28 },
29 test => {
30 requires => {
31 'Test::More' => '0.88',
037386f7 32 },
33 },
8b945fac 34 },
23db00ab 35 resources => {
36 # GitHub mirrors from Shadowcat. We list it so we can get pull requests.
37 # The canonical repo is:
38 # r/o: git://git.shadowcat.co.uk/p5sagit/JSON-MaybeXS.git
39 # r/w: p5sagit@git.shadowcat.co.uk:JSON-MaybeXS.git
40 # web: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit/JSON-MaybeXS.git
41 repository => {
42 url => 'https://github.com/p5sagit/JSON-MaybeXS.git',
43 web => 'https://github.com/p5sagit/JSON-MaybeXS',
44 type => 'git',
45 },
46 bugtracker => {
47 mailto => 'bug-JSON-MaybeXS@rt.cpan.org',
48 web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=JSON-MaybeXS',
49 },
50 license => [ 'http://dev.perl.org/licenses/' ],
51 },
52 x_contributors => [ # manually added, from git shortlog -e -s -n
53 'Clinton Gormley <develop@traveljury.com>',
54 'Graham Knop <haarg@haarg.org>',
55 'John SJ Anderson <genehack@genehack.org>',
56 'Karen Etheridge <ether@cpan.org>',
57 'Kieren Diment <diment@gmail.com>',
58 'Matt S Trout <mst@shadowcat.co.uk>',
59 ],
60 keywords => [ qw(json serializer serialiser data) ],
61 no_index => {
62 directory => [ 't', 'xt' ]
63 },
44459f01 64);
65
23db00ab 66my %MM_ARGS = ();
67
68if (! parse_args()->{PUREPERL_ONLY}) {
c2426812 69 # we require Cpanel::JSON::XS whenever a compiler is available.
23db00ab 70 # (we also always recommend Cpanel::JSON::XS, just to make sure.)
71 $MM_ARGS{PREREQ_PM}{'Cpanel::JSON::XS'} = '2.3310'
72 if eval { require Cpanel::JSON::XS; 1 }
c2426812 73 or can_compile_loadable_object(quiet => 1);
23db00ab 74
75 # JSON::XS 3 changed its boolean handling - update it
76 # if JSON::XS is installed and < 3.0
77 $MM_ARGS{PREREQ_PM}{'JSON::XS'} = '3.00'
78 if eval { require JSON::XS; 1 }
79 and not eval { JSON::XS->VERSION('3.0'); 1 };
db16ce21 80}
14a1801c 81
23db00ab 82use Text::ParseWords;
6f3c496c 83
84sub parse_args {
85 # copied from EUMM
6f3c496c 86 ExtUtils::MakeMaker::parse_args(
87 my $tmp = {},
88 Text::ParseWords::shellwords($ENV{PERL_MM_OPT} || ''),
89 @ARGV,
90 );
91 return $tmp->{ARGS} || {};
92}
93
23db00ab 94## BOILERPLATE ###############################################################
95require ExtUtils::MakeMaker;
96(do './maint/Makefile.PL.include' or die $@) unless -f 'META.yml';
44459f01 97
23db00ab 98# have to do this since old EUMM dev releases miss the eval $VERSION line
99my $eumm_version = eval $ExtUtils::MakeMaker::VERSION;
100my $mymeta = $eumm_version >= 6.57_02;
101my $mymeta_broken = $mymeta && $eumm_version < 6.57_07;
102
103($MM_ARGS{NAME} = $META{name}) =~ s/-/::/g;
104($MM_ARGS{VERSION_FROM} = "lib/$MM_ARGS{NAME}.pm") =~ s{::}{/}g;
105$META{license} = [ $META{license} ]
106 if $META{license} && !ref $META{license};
107$MM_ARGS{LICENSE} = $META{license}[0]
108 if $META{license} && $eumm_version >= 6.30;
109$MM_ARGS{NO_MYMETA} = 1
110 if $mymeta_broken;
111$MM_ARGS{META_ADD} = { 'meta-spec' => { version => 2 }, %META }
112 unless -f 'META.yml';
44459f01 113
23db00ab 114for (qw(configure build test runtime)) {
115 my $key = $_ eq 'runtime' ? 'PREREQ_PM' : uc $_.'_REQUIRES';
116 my $r = $MM_ARGS{$key} = {
117 %{$META{prereqs}{$_}{requires} || {}},
118 %{delete $MM_ARGS{$key} || {}},
119 };
120 defined $r->{$_} or delete $r->{$_} for keys %$r;
44459f01 121}
122
23db00ab 123$MM_ARGS{MIN_PERL_VERSION} = delete $MM_ARGS{PREREQ_PM}{perl} || 0;
44459f01 124
23db00ab 125delete $MM_ARGS{MIN_PERL_VERSION}
126 if $eumm_version < 6.47_01;
127$MM_ARGS{BUILD_REQUIRES} = {%{$MM_ARGS{BUILD_REQUIRES}}, %{delete $MM_ARGS{TEST_REQUIRES}}}
128 if $eumm_version < 6.63_03;
129$MM_ARGS{PREREQ_PM} = {%{$MM_ARGS{PREREQ_PM}}, %{delete $MM_ARGS{BUILD_REQUIRES}}}
130 if $eumm_version < 6.55_01;
131delete $MM_ARGS{CONFIGURE_REQUIRES}
132 if $eumm_version < 6.51_03;
44459f01 133
23db00ab 134ExtUtils::MakeMaker::WriteMakefile(%MM_ARGS);
135## END BOILERPLATE ###########################################################