use ExtUtils::HasCompiler for compiler detection
[gitmo/Class-C3.git] / Makefile.PL
index 7ca6203..2bbaa13 100644 (file)
@@ -1,6 +1,8 @@
 use strict;
 use warnings FATAL => 'all';
 use 5.006;
+use lib 'inc';
+use ExtUtils::HasCompiler qw(can_compile_loadable_object);
 
 my %META = (
   name => 'Class-C3',
@@ -8,7 +10,6 @@ my %META = (
   prereqs => {
     configure => { requires => {
       'ExtUtils::MakeMaker'   => 0,
-      'ExtUtils::CBuilder'    => 0.27,
     } },
     build => { requires => {
     } },
@@ -47,7 +48,7 @@ my %META = (
     license => [ 'http://dev.perl.org/licenses/' ],
   },
   no_index => {
-    directory => [ 't', 'xt', 'opt' ]
+    directory => [ 't', 'xt', 'opt', 'inc' ]
   },
 );
 
@@ -57,56 +58,11 @@ my %MM_ARGS = (
       ? ( 'Devel::Hide' => 0 ) : ()
   },
   PREREQ_PM => {
-    ( $] < 5.009_005 and can_xs() )
+    ( $] < 5.009_005 and can_compile_loadable_object(quiet => 1) )
       ? ( 'Class::C3::XS'  => '0.13' ) : ()
   },
 );
 
-# Secondary compile testing via ExtUtils::CBuilder
-sub can_xs {
-  # Do we have the configure_requires checker?
-  local $@;
-  eval "require ExtUtils::CBuilder;";
-  if ( $@ ) {
-    # They don't obey configure_requires, so it is
-    # someone old and delicate. Try to avoid hurting
-    # them by falling back to an older simpler test.
-    return can_cc();
-  }
-
-  return ExtUtils::CBuilder->new( quiet => 1 )->have_compiler;
-}
-
-# can we locate a (the) C compiler
-sub can_cc {
-  my @chunks = split(/ /, $Config::Config{cc}) or return;
-
-  # $Config{cc} may contain args; try to find out the program part
-  while (@chunks) {
-    return can_run("@chunks") || (pop(@chunks), next);
-  }
-
-  return;
-}
-
-# check if we can run some command
-sub can_run {
-  my ($cmd) = @_;
-
-  return $cmd if -x $cmd;
-  if (my $found_cmd = MM->maybe_command($cmd)) {
-    return $found_cmd;
-  }
-
-  for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
-    next if $dir eq '';
-    my $abs = File::Spec->catfile($dir, $cmd);
-    return $abs if (-x $abs or $abs = MM->maybe_command($abs));
-  }
-
-  return;
-}
-
 sub is_smoker {
   return ( $ENV{AUTOMATED_TESTING} && ! $ENV{PERL5_CPANM_IS_RUNNING} && ! $ENV{RELEASE_TESTING} )
 }