]> git.vpit.fr Git - perl/modules/Scalar-Vec-Util.git/blob - Makefile.PL
Also test veq_pp() out of its argument bounds
[perl/modules/Scalar-Vec-Util.git] / Makefile.PL
1 use 5.006;
2
3 use strict;
4 use warnings;
5 use ExtUtils::MakeMaker;
6
7 BEGIN {
8  eval { require Config };
9  die 'OS unsupported' if $@;
10  Config->import(qw<%Config>);
11  eval { require File::Spec };
12  die 'OS unsupported' if $@;
13 }
14
15 my $cc;
16 for (@ARGV) {
17  if (/^CC=(.*)/) {
18   $cc = $1;
19   last;
20  }
21 }
22 if (defined $cc) {
23  print "Forcing the use of $cc as the C compiler.\n";
24 } else {
25  # Inspired from Module::Install::Can
26  print "Checking for a valid C compiler in the PATH... ";
27  my @ccs = ($Config{cc});
28  unshift @ccs, $ENV{CC} if $ENV{CC};
29 CC:
30  for my $c (@ccs) {
31   for my $dir (split /$Config{path_sep}/, $ENV{PATH}) {
32    my $abs = File::Spec->catfile($dir, $c);
33    if (-x $abs or MM->maybe_command($abs)) {
34     $cc = $c;
35     print $cc, "\n";
36     last CC;
37    }
38   }
39  }
40  print "none\n" unless defined $cc;
41 }
42
43 my @C;
44 push @C, 'Util.c' if defined $cc;
45
46 my @DEFINES;
47
48 sub is_little_endian {
49  my $order = $Config{byteorder};
50  return 0 unless $order;
51  my $len = length $order;
52  if ($len > 8) {
53   $order = substr $order, 0, 8;
54   $len   = 8;
55  }
56  return $order eq (join '', 1 .. $len);
57 }
58
59 my $unit = { bits => 8, size => 1 };
60 if (not is_little_endian()) {
61  print "Forcing unit size of 8 on non-little-endian systems.\n";
62 } else {
63  print "Checking unit size in bits... ";
64  my $align = $Config{alignbytes} || 1;
65  my @bits = (8, 16, 32, 64);
66  for my $bits (@bits) {
67   my $size = $Config{"u${bits}size"};
68   next unless $size;
69   $unit = { bits => $bits, size => $size } if $size && $size <= $align;
70  }
71  print $unit->{bits},
72                 " (actually $unit->{size} bytes for $align bytes alignment).\n";
73 }
74
75 {
76  my $bits = $unit->{bits};
77  push @DEFINES, '-DBV_UNIT="' . ($Config{"u${bits}type"} || "U$bits") . '"';
78  push @DEFINES, "-DSVU_SIZE=$bits";
79 }
80
81 @DEFINES = (DEFINE => join ' ', @DEFINES) if @DEFINES;
82
83 my $dist = 'Scalar-Vec-Util';
84
85 (my $name = $dist) =~ s{-}{::}g;
86
87 (my $file = $dist) =~ s{-}{/}g;
88 $file = "lib/$file.pm";
89
90 my %PREREQ_PM = (
91  'Exporter' => 0,
92  'Carp'     => 0,
93  'XSLoader' => 0,
94  'base'     => 0,
95 );
96
97 my %META = (
98  configure_requires => {
99   'Config'              => 0,
100   'ExtUtils::MakeMaker' => 0,
101   'File::Spec'          => 0,
102  },
103  build_requires => {
104   'Config'              => 0,
105   'ExtUtils::MakeMaker' => 0,
106   'Test::More'          => 0,
107   %PREREQ_PM,
108  },
109  dynamic_config => 1,
110  resources => {
111   bugtracker => "http://rt.cpan.org/NoAuth/ReportBug.html?Queue=$dist",
112   homepage   => "http://search.cpan.org/dist/$dist/",
113   license    => 'http://dev.perl.org/licenses/',
114   repository => "http://git.profvince.com/?p=perl%2Fmodules%2F$dist.git",
115  },
116 );
117
118 WriteMakefile(
119  NAME             => $name,
120  AUTHOR           => 'Vincent Pit <perl@profvince.com>',
121  LICENSE          => 'perl',
122  VERSION_FROM     => $file,
123  ABSTRACT_FROM    => $file,
124  PL_FILES         => {},
125  C                => \@C,
126  @DEFINES,
127  PREREQ_PM        => \%PREREQ_PM,
128  MIN_PERL_VERSION => '5.006',
129  META_MERGE       => \%META,
130  dist             => {
131   PREOP    => "pod2text -u $file > \$(DISTVNAME)/README",
132   COMPRESS => 'gzip -9f', SUFFIX => 'gz'
133  },
134  clean            => {
135   FILES => "$dist-* *.gcov *.gcda *.gcno cover_db Debian_CPANTS.txt*"
136  },
137 );
138
139 1;
140
141 package MY;
142
143 sub postamble {
144  my $cv = join ' -coverage ', 'cover',
145                             qw<statement branch condition path subroutine time>;
146  <<POSTAMBLE;
147 cover test_cover:
148         $cv -test
149 POSTAMBLE
150 }