]> git.vpit.fr Git - perl/modules/Scalar-Vec-Util.git/blob - Makefile.PL
Importing Scalar-Vec-Util-0.02.tar.gz
[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 $arch = $Config{archname} || '';
39 my ($cpu) = $arch =~ /^([^-]+)/;
40
41 my @DEFINES;
42 my $unit = 8;
43 if (unpack("h*", pack("s", 0x1234)) != 4321) {
44  print "Forcing unit size of 8 on non-little-endian systems.\n";
45 } else {
46  my $align = int($Config{alignbytes} || 0);
47  print "Checking unit size in bits... ";
48  my @s = (8, 16, 32);
49  push @s, 64 unless $^O eq 'MSWin32';
50  for (@s) {
51   my $size = int($Config{'u' . $_ . 'size'} || 0);
52   $unit = $_ if $size && $size <= $align;
53  }
54  print $unit, "\n";
55 }
56 push @DEFINES, DEFINE => '-DBV_UNIT="'
57                                  . ($unit == 64 ? 'uint64_t' : 'U' . $unit)
58                                  . '"'
59                       . ' -DSVU_SIZE=' . $unit;
60
61 my $BUILD_REQUIRES = {
62  'Config'              => 0,
63  'ExtUtils::MakeMaker' => 0,
64  'File::Spec'          => 0,
65  'Test::More'          => 0,
66 };
67
68 sub build_req {
69  my $tometa = ' >> $(DISTVNAME)/META.yml;';
70  my $build_req = 'echo "build_requires:" ' . $tometa;
71  foreach my $mod ( sort { lc $a cmp lc $b } keys %$BUILD_REQUIRES ) {
72   my $ver = $BUILD_REQUIRES->{$mod};
73   $build_req .= sprintf 'echo "    %-30s %s" %s', "$mod:", $ver, $tometa;
74  }
75  return $build_req;
76 }
77
78 WriteMakefile(
79     NAME          => 'Scalar::Vec::Util',
80     AUTHOR        => 'Vincent Pit <perl@profvince.com>',
81     LICENSE       => 'perl',
82     VERSION_FROM  => 'lib/Scalar/Vec/Util.pm',
83     ABSTRACT_FROM => 'lib/Scalar/Vec/Util.pm',
84     PL_FILES      => {},
85     C             => \@C,
86     @DEFINES,
87     PREREQ_PM     => {
88         'Exporter' => 0,
89         'Carp'     => 0,
90         'XSLoader' => 0
91     },
92     dist          => {
93         PREOP      => 'pod2text lib/Scalar/Vec/Util.pm > $(DISTVNAME)/README; '
94                       . build_req,
95         COMPRESS   => 'gzip -9f', SUFFIX => 'gz'
96     },
97     clean         => { FILES => 'Scalar-Vec-Util-* *.gcov *.gcda *.gcno cover_db' },
98 );
99
100 1;
101
102 package MY;
103
104 sub postamble {
105  my $cv = join ' -coverage ', 'cover',
106                             qw/statement branch condition path subroutine time/;
107  <<POSTAMBLE;
108 cover test_cover:
109         $cv -test
110 POSTAMBLE
111 }