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