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