From: Karen Etheridge Date: Fri, 10 Oct 2014 05:28:26 +0000 (-0700) Subject: do not add an XS prereq if PUREPERL_ONLY passed to Makefile.PL X-Git-Tag: v1.002004~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6f3c496c2c9bb40dba65a1809c09d90bd78eeaee;p=p5sagit%2FJSON-MaybeXS.git do not add an XS prereq if PUREPERL_ONLY passed to Makefile.PL --- diff --git a/Changes b/Changes index 63b4d45..7404d56 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for JSON-MaybeXS + - support use of PUREPERL_ONLY in Makefile.PL to avoid adding an XS + dependency + 1.002003 - 2014-10-07 - document how to use booleans diff --git a/Makefile.PL b/Makefile.PL index 86f0a6e..2982b81 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -70,7 +70,8 @@ for (qw(configure build test runtime)) { # 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} + && not eval { require JSON::XS; 1; } && can_xs(); $WriteMakefileArgs{MIN_PERL_VERSION} = delete $WriteMakefileArgs{PREREQ_PM}{perl} || 0; @@ -101,6 +102,19 @@ delete $WriteMakefileArgs{LICENSE} 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;