]> git.vpit.fr Git - perl/modules/Scalar-Vec-Util.git/blob - Makefile.PL
fc3276b1cde0b7daa417b11455c3ed107527a453
[perl/modules/Scalar-Vec-Util.git] / Makefile.PL
1 use strict;
2 use warnings;
3 use ExtUtils::MakeMaker;
4
5 BEGIN {
6  eval { require Config };
7  die 'OS unsupported' if $@;
8  Config->import(qw/%Config/);
9  eval { require File::Spec };
10  die 'OS unsupported' if $@;
11 }
12
13 # Inspired from Module::Install::Can
14 print "Checking for a valid C compiler in the PATH... ";
15 my @ccs = ($Config{cc});
16 unshift @ccs, $ENV{CC} if $ENV{CC};
17 my $cc;
18 CC:
19 for my $c (@ccs) {
20  for my $dir (split /$Config{path_sep}/, $ENV{PATH}) {
21   my $abs = File::Spec->catfile($dir, $c);
22   if (-x $abs or MM->maybe_command($abs)) {
23    $cc = $c;
24    last CC;
25   }
26  }
27 }
28 my @C;
29 if ($cc) {
30  push @C, 'Util.c';
31  print $cc, "\n";
32 } else {
33  print "none\n";
34 }
35
36 my $arch = $Config{archname} || '';
37 my ($cpu) = $arch =~ /^([^-]+)/;
38
39 my @DEFINES;
40 my $unit;
41 if (unpack("h*", pack("s", 0x1234)) != 4321) {
42  print "Forcing unit size of 8 on non-little-endian systems.\n";
43  $unit = 8;
44 } else {
45  my $align = int($Config{alignbytes} || 0);
46  print "Checking unit size in bits... ";
47  for (8, 16, 32, 64) {
48   my $size = int($Config{'u' . $_ . 'size'} || 0);
49   $unit = $_ if $size && $size <= $align;
50  }
51  print $unit, "\n";
52 }
53 push @DEFINES, DEFINE => '-DBV_UNIT="'
54                                  . ($unit == 64 ? 'uint64_t' : 'U' . $unit)
55                                  . '"'
56                       . ' -DSVU_SIZE=' . $unit;
57
58 my $BUILD_REQUIRES = {
59  'Config'              => 0,
60  'ExtUtils::MakeMaker' => 0,
61  'Test::More'          => 0,
62 };
63
64 sub build_req {
65  my $tometa = ' >> $(DISTVNAME)/META.yml;';
66  my $build_req = 'echo "build_requires:" ' . $tometa;
67  foreach my $mod ( sort { lc $a cmp lc $b } keys %$BUILD_REQUIRES ) {
68   my $ver = $BUILD_REQUIRES->{$mod};
69   $build_req .= sprintf 'echo "    %-30s %s" %s', "$mod:", $ver, $tometa;
70  }
71  return $build_req;
72 }
73
74 WriteMakefile(
75     NAME          => 'Scalar::Vec::Util',
76     AUTHOR        => 'Vincent Pit <perl@profvince.com>',
77     LICENSE       => 'perl',
78     VERSION_FROM  => 'lib/Scalar/Vec/Util.pm',
79     ABSTRACT_FROM => 'lib/Scalar/Vec/Util.pm',
80     PL_FILES      => {},
81     C             => \@C,
82     @DEFINES,
83     PREREQ_PM     => {
84         'Exporter' => 0,
85         'Carp'     => 0,
86         'XSLoader' => 0
87     },
88     dist          => {
89         PREOP      => 'pod2text lib/Scalar/Vec/Util.pm > $(DISTVNAME)/README; '
90                       . build_req,
91         COMPRESS   => 'gzip -9f', SUFFIX => 'gz'
92     },
93     clean         => { FILES => 'Scalar-Vec-Util-* *.gcov *.gcda *.gcno cover_db' },
94 );
95
96 1;
97
98 package MY;
99
100 sub postamble {
101  my $cv = join ' -coverage ', 'cover',
102                             qw/statement branch condition path subroutine time/;
103  <<POSTAMBLE;
104 cover test_cover:
105         $cv -test
106 POSTAMBLE
107 }