stop relying on . in @INC
[gitmo/Class-C3.git] / Makefile.PL
index 5f53c66..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,12 +58,16 @@ 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' ) : ()
   },
 );
 
-##############################################################################
+sub is_smoker {
+  return ( $ENV{AUTOMATED_TESTING} && ! $ENV{PERL5_CPANM_IS_RUNNING} && ! $ENV{RELEASE_TESTING} )
+}
+
+## BOILERPLATE ###############################################################
 require ExtUtils::MakeMaker;
 (do 'maint/Makefile.PL.include' or die $@) unless -f 'META.yml';
 
@@ -73,8 +78,10 @@ my $mymeta_broken = $mymeta && $eumm_version < 6.57_07;
 
 ($MM_ARGS{NAME} = $META{name}) =~ s/-/::/g;
 ($MM_ARGS{VERSION_FROM} = "lib/$MM_ARGS{NAME}.pm") =~ s{::}{/}g;
-$MM_ARGS{LICENSE} = $META{license}
-  if $eumm_version >= 6.30;
+$META{license} = [ $META{license} ]
+  if $META{license} && !ref $META{license};
+$MM_ARGS{LICENSE} = $META{license}[0]
+  if $META{license} && $eumm_version >= 6.30;
 $MM_ARGS{NO_MYMETA} = 1
   if $mymeta_broken;
 $MM_ARGS{META_ADD} = { 'meta-spec' => { version => 2 }, %META }
@@ -101,53 +108,4 @@ delete $MM_ARGS{CONFIGURE_REQUIRES}
   if $eumm_version < 6.51_03;
 
 ExtUtils::MakeMaker::WriteMakefile(%MM_ARGS);
-##############################################################################
-
-# 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} )
-}
+## END BOILERPLATE ###########################################################