document first version with is_bool
[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}) {
69 # we require Cpanel::JSON::XS, except if JSON::XS is already installed.
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 }
73 or (
74 not eval { require JSON::XS; 1; }
75 and can_compile_loadable_object(quiet => 1)
76 );
77
78 # JSON::XS 3 changed its boolean handling - update it
79 # if JSON::XS is installed and < 3.0
80 $MM_ARGS{PREREQ_PM}{'JSON::XS'} = '3.00'
81 if eval { require JSON::XS; 1 }
82 and not eval { JSON::XS->VERSION('3.0'); 1 };
db16ce21 83}
14a1801c 84
23db00ab 85use Text::ParseWords;
6f3c496c 86
87sub parse_args {
88 # copied from EUMM
6f3c496c 89 ExtUtils::MakeMaker::parse_args(
90 my $tmp = {},
91 Text::ParseWords::shellwords($ENV{PERL_MM_OPT} || ''),
92 @ARGV,
93 );
94 return $tmp->{ARGS} || {};
95}
96
23db00ab 97## BOILERPLATE ###############################################################
98require ExtUtils::MakeMaker;
99(do './maint/Makefile.PL.include' or die $@) unless -f 'META.yml';
44459f01 100
23db00ab 101# have to do this since old EUMM dev releases miss the eval $VERSION line
102my $eumm_version = eval $ExtUtils::MakeMaker::VERSION;
103my $mymeta = $eumm_version >= 6.57_02;
104my $mymeta_broken = $mymeta && $eumm_version < 6.57_07;
105
106($MM_ARGS{NAME} = $META{name}) =~ s/-/::/g;
107($MM_ARGS{VERSION_FROM} = "lib/$MM_ARGS{NAME}.pm") =~ s{::}{/}g;
108$META{license} = [ $META{license} ]
109 if $META{license} && !ref $META{license};
110$MM_ARGS{LICENSE} = $META{license}[0]
111 if $META{license} && $eumm_version >= 6.30;
112$MM_ARGS{NO_MYMETA} = 1
113 if $mymeta_broken;
114$MM_ARGS{META_ADD} = { 'meta-spec' => { version => 2 }, %META }
115 unless -f 'META.yml';
44459f01 116
23db00ab 117for (qw(configure build test runtime)) {
118 my $key = $_ eq 'runtime' ? 'PREREQ_PM' : uc $_.'_REQUIRES';
119 my $r = $MM_ARGS{$key} = {
120 %{$META{prereqs}{$_}{requires} || {}},
121 %{delete $MM_ARGS{$key} || {}},
122 };
123 defined $r->{$_} or delete $r->{$_} for keys %$r;
44459f01 124}
125
23db00ab 126$MM_ARGS{MIN_PERL_VERSION} = delete $MM_ARGS{PREREQ_PM}{perl} || 0;
44459f01 127
23db00ab 128delete $MM_ARGS{MIN_PERL_VERSION}
129 if $eumm_version < 6.47_01;
130$MM_ARGS{BUILD_REQUIRES} = {%{$MM_ARGS{BUILD_REQUIRES}}, %{delete $MM_ARGS{TEST_REQUIRES}}}
131 if $eumm_version < 6.63_03;
132$MM_ARGS{PREREQ_PM} = {%{$MM_ARGS{PREREQ_PM}}, %{delete $MM_ARGS{BUILD_REQUIRES}}}
133 if $eumm_version < 6.55_01;
134delete $MM_ARGS{CONFIGURE_REQUIRES}
135 if $eumm_version < 6.51_03;
44459f01 136
23db00ab 137ExtUtils::MakeMaker::WriteMakefile(%MM_ARGS);
138## END BOILERPLATE ###########################################################