5 use ExtUtils::MakeMaker;
11 my ($name, $preferred_path) = @_;
13 my (@candidates, @args);
14 if (File::Spec->file_name_is_absolute($name)) {
15 # No need to look for args if the name is absolute.
19 if (defined $preferred_path) {
20 @path = ($preferred_path, grep { $_ ne $preferred_path } File::Spec->path);
22 @path = File::Spec->path;
25 (my $base, @args) = split ' ', $name;
26 for my $path_entry (@path) {
27 my ($vol, $dir, $file) = File::Spec->splitpath($path_entry, 1);
28 next if defined $file and length $file;
29 push @candidates, File::Spec->catpath($vol, $dir, $base);
33 for my $path (@candidates) {
34 my $command = MM->maybe_command($path);
35 if (defined $command) {
36 $command .= " @args" if @args;
47 my $desc = delete $args{desc};
48 my $arg_var = delete $args{arg_var};
49 my $tries = delete $args{try};
50 my $preferred_path = delete $args{preferred_path};
55 if (/^\Q$arg_var\E=(.*)/) {
56 $exe = validate_exe($1, $preferred_path);
62 print "Forcing the use of $exe as the $desc.\n";
64 print "Checking for a valid $desc in the PATH... ";
65 for my $try (@$tries) {
66 next unless defined $try;
67 $exe = validate_exe($try, $preferred_path);
81 my ($var, $code) = @_;
85 for my $i (0 .. $#ARGV) {
87 if ($arg =~ /^\Q$var\E=(.*)/) {
95 @ARGV = grep defined, @ARGV;
101 my $pp = filter_argv PP => sub {
103 return (do { no warnings 'numeric'; int $val } or $val =~ /^(?:y|yes)$/i)
107 print "Forcing the pure-Perl implementation from the arguments passed to Makefile.PL.\n";
110 desc => 'C compiler',
112 try => [ $Config{cc}, $ENV{CC}, 'cc' ],
115 my ($vol, $dir, $file) = File::Spec->splitpath($cc);
116 my $preferred_path = File::Spec->catpath($vol, $dir, '');
120 try => [ $Config{ld}, $ENV{LD}, 'ld' ],
121 preferred_path => $preferred_path,
126 sub is_little_endian {
127 my $order = $Config{byteorder};
128 return 0 unless $order;
129 my $len = length $order;
131 $order = substr $order, 0, 8;
134 return $order eq (join '', 1 .. $len);
140 if (defined $cc and defined $ld) {
141 $PARAMS{C} = [ 'Util.c' ];
142 $PARAMS{XS} = { 'Util.xs' => 'Util.c' };
146 my $type = filter_argv UNIT => sub { return $_[0] };
148 print "Forcing '$type' as the unit.\n";
149 push @DEFINES, '-DBV_UNIT="' . $type . '"';
152 if (not is_little_endian()) {
153 print "Forcing unit size of 8 on non-little-endian systems.\n";
155 print "Checking unit size in bits... ";
157 my $align = $Config{alignbytes} || 1;
158 my @units = (8, 16, 32, 64);
159 for my $unit (@units) {
160 my $unit_size = $Config{"u${unit}size"};
161 if ($unit_size and $unit_size <= $align) {
166 print "$bits (actually $size bytes for $align bytes alignment).\n";
168 push @DEFINES, '-DBV_UNIT="' . ($Config{"u${bits}type"} || "U$bits") . '"';
169 push @DEFINES, "-DSVU_SIZE=$bits";
174 $PARAMS{OBJECT} = '';
175 print "Falling back to the pure-Perl implementation.\n";
178 $PARAMS{DEFINE} = join ' ', @DEFINES if @DEFINES;
180 my $dist = 'Scalar-Vec-Util';
182 (my $name = $dist) =~ s{-}{::}g;
184 (my $file = $dist) =~ s{-}{/}g;
185 $file = "lib/$file.pm";
194 my %BUILD_REQUIRES = (
196 'ExtUtils::MakeMaker' => 0,
203 configure_requires => {
205 'ExtUtils::MakeMaker' => 0,
213 bugtracker => "http://rt.cpan.org/Dist/Display.html?Name=$dist",
214 homepage => "http://search.cpan.org/dist/$dist/",
215 license => 'http://dev.perl.org/licenses/',
216 repository => "http://git.profvince.com/?p=perl%2Fmodules%2F$dist.git",
222 AUTHOR => 'Vincent Pit <perl@profvince.com>',
224 VERSION_FROM => $file,
225 ABSTRACT_FROM => $file,
227 BUILD_REQUIRES => \%BUILD_REQUIRES,
228 PREREQ_PM => \%PREREQ_PM,
229 MIN_PERL_VERSION => '5.006',
230 META_MERGE => \%META,
232 PREOP => "pod2text -u $file > \$(DISTVNAME)/README",
233 COMPRESS => 'gzip -9f', SUFFIX => 'gz'
236 FILES => "$dist-* *.gcov *.gcda *.gcno cover_db Debian_CPANTS.txt*"
246 my $cv = join ' -coverage ', 'cover',
247 qw<statement branch condition path subroutine time>;