2 use warnings FATAL => 'all';
4 use ExtUtils::MakeMaker;
5 (do 'maint/Makefile.PL.include' or die $@) unless -f 'META.yml';
8 'Test::Without::Module' => '0.17',
13 NAME => 'JSON::MaybeXS',
14 VERSION_FROM => 'lib/JSON/MaybeXS.pm',
16 'JSON::PP' => '2.27202',
18 ? ('Cpanel::JSON::XS' => '2.3310')
22 BUILD_REQUIRES => \%BUILD_DEPS,
25 # can we locate a (the) C compiler
27 my @chunks = split(/ /, $Config::Config{cc}) or return;
29 # $Config{cc} may contain args; try to find out the program part
31 return can_run("@chunks") || (pop(@chunks), next);
37 # check if we can run some command
41 return $cmd if -x $cmd;
42 if (my $found_cmd = MM->maybe_command($cmd)) {
47 for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
49 my $abs = File::Spec->catfile($dir, $cmd);
50 return $abs if (-x $abs or $abs = MM->maybe_command($abs));
56 # Can our C compiler environment build XS files
58 # Do we have the configure_requires checker?
60 eval "require ExtUtils::CBuilder; ExtUtils::CBuilder->VERSION(0.27)";
62 # They don't obey configure_requires, so it is
63 # someone old and delicate. Try to avoid hurting
64 # them by falling back to an older simpler test.
68 # Do we have a working C compiler
69 my $builder = ExtUtils::CBuilder->new(
72 unless ( $builder->have_compiler ) {
73 # No working C compiler
77 # Write a C file representative of what XS becomes
79 my ( $FH, $tmpfile ) = File::Temp::tempfile(
89 int main(int argc, char **argv) {
100 # Can the C compiler access the same headers XS does
105 $object = $builder->compile(
108 @libs = $builder->link(
110 module_name => 'sanexs',
113 my $result = $@ ? 0 : 1;
115 # Clean up all the build files
116 foreach ( $tmpfile, $object, @libs ) {
117 next unless defined $_;