use 5.00503;
use strict;
use Config;
use ExtUtils::MakeMaker;
my $make_xs = undef;
foreach ( @ARGV ) {
/^-pm/ and $make_xs = 0;
/^-xs/ and $make_xs = 1;
}
unless ( defined $make_xs ) {
$make_xs = can_cc();
}
my @tests = qw{
t/01_compile.t
t/02_main.t
t/03_all.t
t/04_codelike.t
t/05_typelike.t
t/06_invocant.t
t/07_handle.t
t/08_driver.t
t/09_insideout.t
};
if ( $make_xs ) {
foreach my $file ( @tests ) {
local *FILE;
local $/ = undef;
open( FILE, "<$file" ) or die("Failed to open '$file'");
my $buffer = <FILE>;
close( FILE ) or die("Failed to close '$file'");
$file =~ s/0/1/;
$buffer =~ s/0;/1;/;
open( FILE, ">$file" ) or die("Failed to open '$file'");
print FILE $buffer;
close( FILE ) or die("Failed to close '$file'");
}
}
my @clean = (
'*.old'
);
if ( $make_xs ) {
push @clean, @tests;
}
WriteMakefile(
NO_META => 1,
NAME => 'Params::Util',
ABSTRACT_FROM => 'lib/Params/Util.pm',
VERSION_FROM => 'lib/Params/Util.pm',
DEFINE => '-DPERL_EXT',
CONFIGURE => sub {
my $hash = $_[1];
unless ( $make_xs ) {
$hash->{XS} = {};
$hash->{C} = [];
}
return $hash;
},
clean => {
FILES => join( ' ', @clean ),
},
PREREQ_PM => {
'Scalar::Util' => '1.18',
'Test::More' => '0.42',
'File::Spec' => '0.80',
},
($] >= 5.005 ? (
AUTHOR => 'Adam Kennedy <adamk@cpan.org>',
) : ()),
($ExtUtils::MakeMaker::VERSION ge '6.30_00' ? (
LICENSE => 'perl',
) : ()),
);
sub can_cc {
my $self = shift;
my @chunks = split(/ /, $Config::Config{cc}) or return;
while ( @chunks ) {
return can_run("@chunks") || (pop(@chunks), next);
}
return;
}
sub can_run {
my ($self, $cmd) = @_;
my $_cmd = $cmd;
return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd));
for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
next if $dir eq '';
my $abs = File::Spec->catfile($dir, $_[1]);
return $abs if (-x $abs or $abs = MM->maybe_command($abs));
}
return;
}