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;
45 my ($desc, $arg_var, $config_var, $env_var, $preferred_path) = @_;
50 if (/^\Q$arg_var\E=(.*)/) {
51 $exe = validate_exe($1, $preferred_path);
57 print "Forcing the use of $exe as the $desc.\n";
59 print "Checking for a valid $desc in the PATH... ";
60 $exe = validate_exe($Config{$config_var}, $preferred_path);
61 # Only fall back to env if we cannot find the one used to build perl.
62 if (not defined $exe and defined $ENV{$env_var}) {
63 $exe = validate_exe($ENV{$env_var}, $preferred_path);
76 my ($var, $code) = @_;
80 for my $i (0 .. $#ARGV) {
82 if ($arg =~ /^\Q$var\E=(.*)/) {
90 @ARGV = grep defined, @ARGV;
96 my $pp = filter_argv PP => sub {
98 return (do { no warnings 'numeric'; int $val } or $val =~ /^(?:y|yes)$/i)
102 print "Forcing the pure-Perl implementation from the arguments passed to Makefile.PL.\n";
104 $cc = check_exe('C compiler', 'CC', 'cc', 'CC');
106 my ($vol, $dir, $file) = File::Spec->splitpath($cc);
107 my $preferred_path = File::Spec->catpath($vol, $dir, '');
108 $ld = check_exe('linker', 'LD', 'ld', 'LD', $preferred_path);
112 sub is_little_endian {
113 my $order = $Config{byteorder};
114 return 0 unless $order;
115 my $len = length $order;
117 $order = substr $order, 0, 8;
120 return $order eq (join '', 1 .. $len);
126 if (defined $cc and defined $ld) {
127 $PARAMS{C} = [ 'Util.c' ];
128 $PARAMS{XS} = { 'Util.xs' => 'Util.c' };
133 if (not is_little_endian()) {
134 print "Forcing unit size of 8 on non-little-endian systems.\n";
136 print "Checking unit size in bits... ";
138 my $align = $Config{alignbytes} || 1;
139 my @units = (8, 16, 32, 64);
140 for my $unit (@units) {
141 my $unit_size = $Config{"u${unit}size"};
142 if ($unit_size and $unit_size <= $align) {
147 print "$bits (actually $size bytes for $align bytes alignment).\n";
149 push @DEFINES, '-DBV_UNIT="' . ($Config{"u${bits}type"} || "U$bits") . '"';
150 push @DEFINES, "-DSVU_SIZE=$bits";
154 $PARAMS{OBJECT} = '';
155 print "Falling back to the pure-Perl implementation.\n";
158 $PARAMS{DEFINE} = join ' ', @DEFINES if @DEFINES;
160 my $dist = 'Scalar-Vec-Util';
162 (my $name = $dist) =~ s{-}{::}g;
164 (my $file = $dist) =~ s{-}{/}g;
165 $file = "lib/$file.pm";
174 my %BUILD_REQUIRES = (
176 'ExtUtils::MakeMaker' => 0,
183 configure_requires => {
185 'ExtUtils::MakeMaker' => 0,
193 bugtracker => "http://rt.cpan.org/Dist/Display.html?Name=$dist",
194 homepage => "http://search.cpan.org/dist/$dist/",
195 license => 'http://dev.perl.org/licenses/',
196 repository => "http://git.profvince.com/?p=perl%2Fmodules%2F$dist.git",
202 AUTHOR => 'Vincent Pit <perl@profvince.com>',
204 VERSION_FROM => $file,
205 ABSTRACT_FROM => $file,
207 BUILD_REQUIRES => \%BUILD_REQUIRES,
208 PREREQ_PM => \%PREREQ_PM,
209 MIN_PERL_VERSION => '5.006',
210 META_MERGE => \%META,
212 PREOP => "pod2text -u $file > \$(DISTVNAME)/README",
213 COMPRESS => 'gzip -9f', SUFFIX => 'gz'
216 FILES => "$dist-* *.gcov *.gcda *.gcno cover_db Debian_CPANTS.txt*"
226 my $cv = join ' -coverage ', 'cover',
227 qw<statement branch condition path subroutine time>;