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