2 use warnings FATAL => 'all';
4 use ExtUtils::MakeMaker;
5 (do 'maint/Makefile.PL.include' or die $@) unless -f 'META.yml';
7 # we require Cpanel::JSON::XS, except if JSON::XS is already installed we only
9 my $require_cpanel_json_xs = can_xs() && !eval { require JSON::XS; 1; };
11 my %WriteMakefileArgs = (
12 NAME => 'JSON::MaybeXS',
13 VERSION_FROM => 'lib/JSON/MaybeXS.pm',
15 'JSON::PP' => '2.27202',
16 ($require_cpanel_json_xs
17 ? ('Cpanel::JSON::XS' => '2.3310')
22 'Test::Without::Module' => '0.17',
23 'Test::More' => '0.88'
27 'meta-spec' => { version => 2 },
29 ($require_cpanel_json_xs
31 : (prereqs => { runtime => { recommends => { 'Cpanel::JSON::XS' => '2.3310' } } })),
35 url => 'https://github.com/karenetheridge/JSON-MaybeXS.git',
36 web => 'https://github.com/karenetheridge/JSON-MaybeXS',
40 mailto => 'bug-JSON-MaybeXS@rt.cpan.org',
41 web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=JSON-MaybeXS',
46 realclean => { FILES => 'Distar/' },
49 my $eumm_version = eval $ExtUtils::MakeMaker::VERSION;
50 $WriteMakefileArgs{MIN_PERL_VERSION} = delete $WriteMakefileArgs{PREREQ_PM}{perl} || 0;
51 $WriteMakefileArgs{BUILD_REQUIRES} = {
52 %{$WriteMakefileArgs{BUILD_REQUIRES}},
53 %{delete $WriteMakefileArgs{TEST_REQUIRES}}
54 } if $eumm_version < 6.63_03;
55 $WriteMakefileArgs{PREREQ_PM} = {
56 %{$WriteMakefileArgs{PREREQ_PM}},
57 %{delete $WriteMakefileArgs{BUILD_REQUIRES}}
58 } if $eumm_version < 6.55_01;
60 WriteMakefile(%WriteMakefileArgs);
62 # can we locate a (the) C compiler
64 my @chunks = split(/ /, $Config::Config{cc}) or return;
66 # $Config{cc} may contain args; try to find out the program part
68 return can_run("@chunks") || (pop(@chunks), next);
74 # check if we can run some command
78 return $cmd if -x $cmd;
79 if (my $found_cmd = MM->maybe_command($cmd)) {
84 for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
86 my $abs = File::Spec->catfile($dir, $cmd);
87 return $abs if (-x $abs or $abs = MM->maybe_command($abs));
93 # Can our C compiler environment build XS files
95 # Do we have the configure_requires checker?
97 eval "require ExtUtils::CBuilder; ExtUtils::CBuilder->VERSION(0.27)";
99 # They don't obey configure_requires, so it is
100 # someone old and delicate. Try to avoid hurting
101 # them by falling back to an older simpler test.
105 # Do we have a working C compiler
106 my $builder = ExtUtils::CBuilder->new(
109 unless ( $builder->have_compiler ) {
110 # No working C compiler
114 # Write a C file representative of what XS becomes
116 my ( $FH, $tmpfile ) = File::Temp::tempfile(
126 int main(int argc, char **argv) {
137 # Can the C compiler access the same headers XS does
142 $object = $builder->compile(
145 @libs = $builder->link(
147 module_name => 'sanexs',
150 my $result = $@ ? 0 : 1;
152 # Clean up all the build files
153 foreach ( $tmpfile, $object, @libs ) {
154 next unless defined $_;