]> git.vpit.fr Git - perl/modules/Test-Valgrind.git/blob - Makefile.PL
Importing Test-Valgrind-0.02.tar.gz
[perl/modules/Test-Valgrind.git] / Makefile.PL
1 use strict;
2 use warnings;
3 use ExtUtils::MakeMaker;
4
5 my $has_vg = 0;
6 my $vg;
7 print 'Checking for valgrind >= 3.1.0 in PATH... ';
8 for (split /:/, $ENV{PATH}) {
9  $vg = $_ . '/valgrind';
10  if (-x $vg) {
11   my $ver = qx/$vg --version/;
12   if ($ver =~ s/^valgrind-//) {
13    $ver = join '', map chr, split /\./, $ver;
14    if ($ver ge v3.1.0) {
15     print "yes, $vg\n";
16     $has_vg = 1;
17     last;
18    }
19   }
20  }
21 }
22 if (!$has_vg) {
23  print "no\n";
24  die 'OS unsupported';
25 }
26
27 my $BUILD_REQUIRES = {
28  'ExtUtils::MakeMaker' => 0,
29  'Test::More'          => 0
30 };
31
32 sub build_req {
33  my $tometa = ' >> $(DISTVNAME)/META.yml;';
34  my $build_req = 'echo "build_requires:" ' . $tometa;
35  foreach my $mod ( sort { lc $a cmp lc $b } keys %$BUILD_REQUIRES ) {
36   my $ver = $BUILD_REQUIRES->{$mod};
37   $build_req .= sprintf 'echo "    %-30s %s" %s', "$mod:", $ver, $tometa;
38  }
39  return $build_req;
40 }
41
42 my $supp = 'lib/Test/Valgrind/Suppressions';
43 open my $tpl, '<', $supp . '.tpl' or die "open($supp.tpl): $!";
44 open my $out, '>', $supp . '.pm'  or die "open($supp.pm): $!";
45 while (<$tpl>) {
46  s/(VG_PATH\s*=>\s*)undef/$1'$vg'/g;
47  print $out $_;
48 }
49 close $out;
50 close $tpl;
51
52 $supp = 'Test/Valgrind/perlTestValgrind.supp';
53
54 WriteMakefile(
55     NAME          => 'Test::Valgrind',
56     AUTHOR        => 'Vincent Pit <perl@profvince.com>',
57     LICENSE       => 'perl',
58     VERSION_FROM  => 'lib/Test/Valgrind.pm',
59     ABSTRACT_FROM => 'lib/Test/Valgrind.pm',
60     PL_FILES      => { './Gensupp.PL' => 'lib/' . $supp },
61     PM            => {
62         'lib/Test/Valgrind.pm'
63         => '$(INST_LIB)/Test/Valgrind.pm',
64         'lib/Test/Valgrind/Suppressions.pm'
65         => '$(INST_ARCHLIB)/Test/Valgrind/Suppressions.pm',
66         'lib/' . $supp => '$(INST_ARCHLIB)/' . $supp,
67     },
68     PREREQ_PM     => {
69         'Carp'                  => 0,
70         'Exporter'              => 0,
71         'POSIX'                 => 0,
72         'Perl::Destruct::Level' => 0,
73         'Test::More'            => 0,
74     },
75     dist          => {
76         PREOP      => 'pod2text lib/Test/Valgrind.pm > $(DISTVNAME)/README; '
77                       . build_req,
78         COMPRESS   => 'gzip -9f', SUFFIX => 'gz',
79     },
80     clean         => { FILES => "Test-Valgrind-* lib/$supp *.gcov *.gcda *.gcno cover_db" },
81 );
82 1 while unlink 'lib/' . $supp;
83