2 use warnings FATAL => 'all';
3 use ExtUtils::MakeMaker;
4 (do './maint/Makefile.PL.include' or die $@) unless -f 'META.yml';
6 my %WriteMakefileArgs = (
7 NAME => 'JSON::MaybeXS',
8 VERSION_FROM => 'lib/JSON/MaybeXS.pm',
11 'meta-spec' => { version => 2 },
14 # GitHub mirrors from Shadowcat. We list it so we can get pull requests.
15 # The canonical repo is:
16 # r/o: git://git.shadowcat.co.uk/p5sagit/JSON-MaybeXS.git
17 # r/w: p5sagit@git.shadowcat.co.uk:JSON-MaybeXS.git
18 # web: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit/JSON-MaybeXS.git
20 url => 'https://github.com/p5sagit/JSON-MaybeXS.git',
21 web => 'https://github.com/p5sagit/JSON-MaybeXS',
25 mailto => 'bug-JSON-MaybeXS@rt.cpan.org',
26 web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=JSON-MaybeXS',
29 x_contributors => [ # manually added, from git shortlog -e -s -n
30 'Clinton Gormley <develop@traveljury.com>',
31 'Graham Knop <haarg@haarg.org>',
32 'John SJ Anderson <genehack@genehack.org>',
33 'Karen Etheridge <ether@cpan.org>',
34 'Kieren Diment <diment@gmail.com>',
35 'Matt S Trout <mst@shadowcat.co.uk>',
37 keywords => [ qw(json serializer serialiser data) ],
41 'meta-spec' => { version => 2 },
45 'ExtUtils::MakeMaker' => '0',
46 'ExtUtils::CBuilder' => '0.27',
53 'Scalar::Util' => '0',
55 'JSON::PP' => '2.27300',
56 # we may also add a runtime prereq for Cpanel::JSON::XS, on the
60 recommends => { 'Cpanel::JSON::XS' => '2.3310' },
64 'Test::More' => '0.88',
71 my $eumm_version = eval $ExtUtils::MakeMaker::VERSION;
73 for (qw(configure build test runtime)) {
74 my $key = $_ eq 'runtime' ? 'PREREQ_PM' : uc $_.'_REQUIRES';
75 next unless exists $WriteMakefileArgs{META_ADD}{prereqs}{$_}
76 or exists $WriteMakefileArgs{$key};
77 my $r = $WriteMakefileArgs{$key} = {
78 %{$WriteMakefileArgs{META_ADD}{prereqs}{$_}{requires} || {}},
79 %{delete $WriteMakefileArgs{$key} || {}},
81 defined $r->{$_} or delete $r->{$_} for keys %$r;
84 # dynamic prereqs get added here.
86 my $args = parse_args();
88 if (not $args->{PUREPERL_ONLY}) {
89 # we require Cpanel::JSON::XS, except if JSON::XS is already installed.
90 # (we also always recommend Cpanel::JSON::XS, just to make sure.)
91 $WriteMakefileArgs{PREREQ_PM}{'Cpanel::JSON::XS'} = '2.3310'
92 if eval { require Cpanel::JSON::XS; 1 }
93 or (not eval { require JSON::XS; 1; } and can_xs());
95 # JSON::XS 3 changed its boolean handling - update it
96 # if JSON::XS is installed and < 3.0
97 $WriteMakefileArgs{PREREQ_PM}{'JSON::XS'} = '3.00'
98 if eval { require JSON::XS; 1 } and not eval { JSON::XS->VERSION('3.0'); 1 };
101 $WriteMakefileArgs{MIN_PERL_VERSION} = delete $WriteMakefileArgs{PREREQ_PM}{perl} || 0;
103 die 'attention developer: you need to do a sane meta merge here!'
104 if keys %{$WriteMakefileArgs{BUILD_REQUIRES}};
106 $WriteMakefileArgs{BUILD_REQUIRES} = {
107 %{$WriteMakefileArgs{BUILD_REQUIRES} || {}},
108 %{delete $WriteMakefileArgs{TEST_REQUIRES}}
109 } if $eumm_version < 6.63_03;
111 $WriteMakefileArgs{PREREQ_PM} = {
112 %{$WriteMakefileArgs{PREREQ_PM}},
113 %{delete $WriteMakefileArgs{BUILD_REQUIRES}}
114 } if $eumm_version < 6.55_01;
116 delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
117 if $eumm_version < 6.51_03;
119 delete $WriteMakefileArgs{MIN_PERL_VERSION}
120 if $eumm_version < 6.48;
122 delete @WriteMakefileArgs{qw(META_ADD META_MERGE)}
123 if $eumm_version < 6.46;
125 delete $WriteMakefileArgs{LICENSE}
126 if $eumm_version < 6.31;
128 WriteMakefile(%WriteMakefileArgs);
133 require ExtUtils::MakeMaker;
134 require Text::ParseWords;
135 ExtUtils::MakeMaker::parse_args(
137 Text::ParseWords::shellwords($ENV{PERL_MM_OPT} || ''),
140 return $tmp->{ARGS} || {};
143 # can we locate a (the) C compiler
145 my @chunks = split(/ /, $Config::Config{cc}) or return;
147 # $Config{cc} may contain args; try to find out the program part
149 return can_run("@chunks") || (pop(@chunks), next);
155 # check if we can run some command
159 return $cmd if -x $cmd;
160 if (my $found_cmd = MM->maybe_command($cmd)) {
165 for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
167 my $abs = File::Spec->catfile($dir, $cmd);
168 return $abs if (-x $abs or $abs = MM->maybe_command($abs));
174 # Can our C compiler environment build XS files
176 # Do we have the configure_requires checker?
178 eval "require ExtUtils::CBuilder; ExtUtils::CBuilder->VERSION(0.27)";
180 # They don't obey configure_requires, so it is
181 # someone old and delicate. Try to avoid hurting
182 # them by falling back to an older simpler test.
186 # Do we have a working C compiler
187 my $builder = ExtUtils::CBuilder->new(
190 unless ( $builder->have_compiler ) {
191 # No working C compiler
195 # Write a C file representative of what XS becomes
197 my ( $FH, $tmpfile ) = File::Temp::tempfile(
207 int main(int argc, char **argv) {
218 # Can the C compiler access the same headers XS does
223 $object = $builder->compile(
226 @libs = $builder->link(
228 module_name => 'sanexs',
231 my $result = $@ ? 0 : 1;
233 # Clean up all the build files
234 foreach ( $tmpfile, $object, @libs ) {
235 next unless defined $_;