Bumping version to 1.003005
[p5sagit/JSON-MaybeXS.git] / Makefile.PL
index 3edd45c..a898ce4 100644 (file)
@@ -1,15 +1,38 @@
 use strict;
 use warnings FATAL => 'all';
-use 5.008001;
 use ExtUtils::MakeMaker;
 (do 'maint/Makefile.PL.include' or die $@) unless -f 'META.yml';
 
 my %WriteMakefileArgs = (
   NAME => 'JSON::MaybeXS',
   VERSION_FROM => 'lib/JSON/MaybeXS.pm',
-  META_ADD => {
+
+  META_MERGE => {
     'meta-spec' => { version => 2 },
     dynamic_config => 1,
+    resources => {
+    # r/w: p5sagit@git.shadowcat.co.uk:JSON-MaybeXS.git
+      repository => {
+        url => 'git://git.shadowcat.co.uk/p5sagit/JSON-MaybeXS.git',
+        web => 'http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit/JSON-MaybeXS.git',
+        type => 'git',
+      },
+      bugtracker => {
+        mailto => 'bug-JSON-MaybeXS@rt.cpan.org',
+        web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=JSON-MaybeXS',
+      },
+    },
+    x_contributors => [ # manually added, from git shortlog -e -s
+      'Clinton Gormley <develop@traveljury.com>',
+      'Graham Knop <haarg@haarg.org>',
+      'John SJ Anderson <genehack@genehack.org>',
+      'Karen Etheridge <ether@cpan.org>',
+      'Kieren Diment <diment@gmail.com>',
+      'Matt S Trout <mst@shadowcat.co.uk>',
+    ],
+  },
+
+  META_ADD => {
     prereqs => {
       configure => {
         requires => {
@@ -21,6 +44,8 @@ my %WriteMakefileArgs = (
       },
       runtime => {
         requires => {
+          'Scalar::Util' => '0',
+          'Carp' => '0',
           'JSON::PP' => '2.27202',
           # we may also add a runtime prereq for Cpanel::JSON::XS, on the
           # installer's machine
@@ -35,21 +60,7 @@ my %WriteMakefileArgs = (
         },
       },
     },
-
-    resources => {
-      repository => {
-        url => 'https://github.com/karenetheridge/JSON-MaybeXS.git',
-        web => 'https://github.com/karenetheridge/JSON-MaybeXS',
-        type => 'git',
-      },
-      bugtracker => {
-        mailto => 'bug-JSON-MaybeXS@rt.cpan.org',
-        web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=JSON-MaybeXS',
-      },
-    },
   },
-
-  realclean => { FILES => [ 'Distar/', 'MANIFEST*' ] },
 );
 
 my $eumm_version  = eval $ExtUtils::MakeMaker::VERSION;
@@ -65,13 +76,33 @@ for (qw(configure build test runtime)) {
   defined $r->{$_} or delete $r->{$_} for keys %$r;
 }
 
+# dynamic prereqs get added here.
+
 # we require Cpanel::JSON::XS, except if JSON::XS is already installed.
 # (we also always recommend Cpanel::JSON::XS, just to make sure.)
 $WriteMakefileArgs{PREREQ_PM}{'Cpanel::JSON::XS'} = '2.3310'
-    if can_xs() && !eval { require JSON::XS; 1; };
+    if not parse_args()->{PUREPERL_ONLY}
+        and ((eval { require Cpanel::JSON::XS; 1 } and not eval { Cpanel::JSON::XS->VERSION('2.3310'); 1 })
+            or (not eval { require JSON::XS; 1; } and can_xs()));
+
+# avoid "JSON::XS::Boolean::* redefined" warnings caused by incompatibilities
+# between JSON::XS 2.x and 3.0 --
+# if JSON::XS is installed and < 3.0
+# and Cpanel::JSON::JSON is (or is about to be) >= 3.0,
+# then update JSON::XS to eliminate the incompatibility
+$WriteMakefileArgs{PREREQ_PM}{'JSON::XS'} = '3.00'
+    if not parse_args()->{PUREPERL_ONLY}
+        and eval { require JSON::XS; 1 } and not eval { JSON::XS->VERSION('3.0'); 1 }
+        and (eval { require Cpanel::JSON::XS; Cpanel::JSON::XS->VERSION('3.0'); 1 }
+            # we presume here that if we are installing Cpanel::JSON::XS, we
+            # are installing the latest version
+            or exists $WriteMakefileArgs{PREREQ_PM}{'Cpanel::JSON::XS'});
 
 $WriteMakefileArgs{MIN_PERL_VERSION} = delete $WriteMakefileArgs{PREREQ_PM}{perl} || 0;
 
+die 'attention developer: you need to do a sane meta merge here!'
+  if keys %{$WriteMakefileArgs{BUILD_REQUIRES}};
+
 $WriteMakefileArgs{BUILD_REQUIRES} = {
     %{$WriteMakefileArgs{BUILD_REQUIRES} || {}},
     %{delete $WriteMakefileArgs{TEST_REQUIRES}}
@@ -85,8 +116,30 @@ $WriteMakefileArgs{PREREQ_PM} = {
 delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
   if $eumm_version < 6.51_03;
 
+delete $WriteMakefileArgs{MIN_PERL_VERSION}
+  if $eumm_version < 6.48;
+
+delete @WriteMakefileArgs{qw(META_ADD META_MERGE)}
+  if $eumm_version < 6.46;
+
+delete $WriteMakefileArgs{LICENSE}
+  if $eumm_version < 6.31;
+
 WriteMakefile(%WriteMakefileArgs);
 
+
+sub parse_args {
+  # copied from EUMM
+  require ExtUtils::MakeMaker;
+  require Text::ParseWords;
+  ExtUtils::MakeMaker::parse_args(
+    my $tmp = {},
+    Text::ParseWords::shellwords($ENV{PERL_MM_OPT} || ''),
+    @ARGV,
+  );
+  return $tmp->{ARGS} || {};
+}
+
 # can we locate a (the) C compiler
 sub can_cc {
   my @chunks = split(/ /, $Config::Config{cc}) or return;