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