2 use warnings FATAL => 'all';
4 use ExtUtils::MakeMaker;
5 (do 'maint/Makefile.PL.include' or die $@) unless -f 'META.yml';
8 NAME => 'JSON::MaybeXS',
9 VERSION_FROM => 'lib/JSON/MaybeXS.pm',
11 'JSON::PP' => '2.27202',
12 'Test::Without::Module' => '0.17',
14 ? ('Cpanel::JSON::XS' => '2.3310')
19 # can we locate a (the) C compiler
21 my @chunks = split(/ /, $Config::Config{cc}) or return;
23 # $Config{cc} may contain args; try to find out the program part
25 return can_run("@chunks") || (pop(@chunks), next);
31 # check if we can run some command
35 return $cmd if -x $cmd;
36 if (my $found_cmd = MM->maybe_command($cmd)) {
41 for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
43 my $abs = File::Spec->catfile($dir, $cmd);
44 return $abs if (-x $abs or $abs = MM->maybe_command($abs));
50 # Can our C compiler environment build XS files
52 # Do we have the configure_requires checker?
54 eval "require ExtUtils::CBuilder; ExtUtils::CBuilder->VERSION(0.27)";
56 # They don't obey configure_requires, so it is
57 # someone old and delicate. Try to avoid hurting
58 # them by falling back to an older simpler test.
62 # Do we have a working C compiler
63 my $builder = ExtUtils::CBuilder->new(
66 unless ( $builder->have_compiler ) {
67 # No working C compiler
71 # Write a C file representative of what XS becomes
73 my ( $FH, $tmpfile ) = File::Temp::tempfile(
83 int main(int argc, char **argv) {
94 # Can the C compiler access the same headers XS does
99 $object = $builder->compile(
102 @libs = $builder->link(
104 module_name => 'sanexs',
107 my $result = $@ ? 0 : 1;
109 # Clean up all the build files
110 foreach ( $tmpfile, $object, @libs ) {
111 next unless defined $_;