]> git.vpit.fr Git - perl/modules/Test-Valgrind.git/blobdiff - Makefile.PL
Also strip the (new) tail after cutting the suppression at Perl_runops
[perl/modules/Test-Valgrind.git] / Makefile.PL
index 228fd1b4c5293651dd58e69c3ff57649b9059ed9..4588d5b435f35ca3a621bb1dabb8958029c458e4 100644 (file)
@@ -4,90 +4,110 @@ use strict;
 use warnings;
 use ExtUtils::MakeMaker;
 
-my $vg;
-print 'Checking for valgrind >= 3.1.0 in PATH... ';
-for (split /:/, $ENV{PATH}) {
- $_ .= '/valgrind';
- if (-x) {
-  my $ver = qx/$_ --version/;
-  if ($ver =~ s/^valgrind-//) {
-   $ver = join '', map chr, split /\./, $ver;
-   if ($ver ge v3.1.0) {
-    print "yes, $_\n";
-    $vg = $_;
-    last;
-   }
-  }
- }
-}
-if (!$vg) {
- print "no\n";
- die 'OS unsupported';
+BEGIN {
+ eval { require Config };
+ die 'OS unsupported' if $@;
+ Config->import(qw/%Config/);
+ eval { require File::Spec };
+ die 'OS unsupported' if $@;
 }
 
-my $BUILD_REQUIRES = {
- 'ExtUtils::MakeMaker' => 0,
- 'Test::More'          => 0
-};
-
-sub build_req {
- my $tometa = ' >> $(DISTVNAME)/META.yml;';
- my $build_req = 'echo "build_requires:" ' . $tometa;
- foreach my $mod ( sort { lc $a cmp lc $b } keys %$BUILD_REQUIRES ) {
-  my $ver = $BUILD_REQUIRES->{$mod};
-  $build_req .= sprintf 'echo "    %-30s %s" %s', "$mod:", $ver, $tometa;
+# Inspired from Module::Install::Can
+print "Checking for a valid C compiler in the PATH... ";
+my @ccs = ($Config{cc});
+unshift @ccs, $ENV{CC} if $ENV{CC};
+my @path = File::Spec->path;
+@ccs = map {
+ my $cc = $_;
+ File::Spec->file_name_is_absolute($cc)
+   ? $cc
+   : map File::Spec->catfile($_, $cc), @path
+} @ccs;
+my $has_cc;
+CC:
+for my $cc (@ccs) {
+ if (-x $cc or MM->maybe_command($cc)) {
+  $has_cc = $cc;
+  last CC;
  }
- return $build_req;
 }
-
-my $supp = 'lib/Test/Valgrind/Suppressions';
-open my $tpl, '<', $supp . '.tpl' or die "open($supp.tpl): $!";
-open my $out, '>', $supp . '.pm'  or die "open($supp.pm): $!";
-while (<$tpl>) {
- s/(VG_PATH\s*=>\s*)undef/$1'$vg'/g;
- print $out $_;
+my (@C);
+if ($has_cc) {
+ my $xs = 'Valgrind.xs';
+ (my $c = $xs) =~ s/\.xs$/.c/;
+ push @C, $c;
+ print $has_cc, "\n";
+} else {
+ print "none\n";
 }
-close $out;
-close $tpl;
 
-$supp = 'Test/Valgrind/perlTestValgrind.supp';
+my $dist = 'Test-Valgrind';
 
-WriteMakefile(
-    NAME          => 'Test::Valgrind',
-    AUTHOR        => 'Vincent Pit <perl@profvince.com>',
-    LICENSE       => 'perl',
-    VERSION_FROM  => 'lib/Test/Valgrind.pm',
-    ABSTRACT_FROM => 'lib/Test/Valgrind.pm',
-    PL_FILES      => { './Gensupp.PL' => 'lib/' . $supp },
-    PM            => {
-        'lib/Test/Valgrind.pm'
-        => '$(INST_LIB)/Test/Valgrind.pm',
-        'lib/Test/Valgrind/Suppressions.pm'
-        => '$(INST_ARCHLIB)/Test/Valgrind/Suppressions.pm',
-        'lib/' . $supp => '$(INST_ARCHLIB)/' . $supp,
-    },
-    PREREQ_PM     => {
-        'Carp'                  => 0,
-        'Exporter'              => 0,
-        'POSIX'                 => 0,
-        'Perl::Destruct::Level' => 0,
-        'Test::More'            => 0,
-    },
-    dist          => {
-        PREOP      => 'pod2text lib/Test/Valgrind.pm > $(DISTVNAME)/README; '
-                      . build_req,
-        COMPRESS   => 'gzip -9f', SUFFIX => 'gz',
-    },
-    clean         => { FILES => "Test-Valgrind-* lib/$supp *.gcov *.gcda *.gcno cover_db" },
+(my $name = $dist) =~ s{-}{::}g;
+
+(my $file = $dist) =~ s{-}{/}g;
+$file = "lib/$file.pm";
+
+my %PREREQ_PM = (
+ 'Carp'                  => 0,
+ 'Digest::MD5'           => 0,
+ 'Env::Sanctify'         => 0,
+ 'File::HomeDir'         => '0.86',
+ 'File::Path'            => 0,
+ 'File::Spec'            => 0,
+ 'File::Temp'            => '0.14', # OO interface
+ 'Filter::Util::Call'    => 0,
+ 'Fcntl'                 => 0,
+ 'List::Util'            => 0,
+ 'POSIX'                 => 0,
+ 'Perl::Destruct::Level' => 0,
+ 'Scalar::Util'          => 0,
+ 'Test::Builder'         => 0,
+ 'Test::More'            => 0,
+ 'XML::Twig'             => 0,
+ 'base'                  => 0,
+ 'version'               => 0,
 );
-1 while unlink 'lib/' . $supp;
 
-package MY;
+my %META = (
+ configure_requires => {
+  'File::Spec'          => 0,
+  'ExtUtils::MakeMaker' => 0,
+ },
+ build_requires => {
+  'ExtUtils::MakeMaker' => 0,
+  'Test::More'          => 0,
+  %PREREQ_PM,
+ },
+ recommends => {
+  'DynaLoader' => 0,
+  'XSLoader'   => 0,
+ },
+ dynamic_config => 1,
+ resources => {
+  bugtracker => "http://rt.cpan.org/NoAuth/ReportBug.html?Queue=$dist",
+  homepage   => "http://search.cpan.org/dist/$dist/",
+  license    => 'http://dev.perl.org/licenses/',
+  repository => "http://git.profvince.com/?p=perl%2Fmodules%2F$dist.git",
+ },
+);
 
-sub postamble {
- <<POSTAMBLE;
-clean ::
-\t\$(CP) lib/Test/Valgrind/Suppressions.{tpl,pm}
-\t\$(TOUCH) lib/Test/Valgrind/perlTestValgrind.supp
-POSTAMBLE
-}
+WriteMakefile(
+ NAME             => $name,
+ AUTHOR           => 'Vincent Pit <perl@profvince.com>',
+ LICENSE          => 'perl',
+ VERSION_FROM     => $file,
+ ABSTRACT_FROM    => $file,
+ OPTIMIZE         => '-g',
+ C                => \@C,
+ PREREQ_PM        => \%PREREQ_PM,
+ MIN_PERL_VERSION => 5.006,
+ META_MERGE       => \%META,
+ dist             => {
+  PREOP    => "pod2text $file > \$(DISTVNAME)/README",
+  COMPRESS => 'gzip -9f', SUFFIX => 'gz',
+ },
+ clean            => {
+  FILES => "$dist-* *.gcov *.gcda *.gcno cover_db Debian_CPANTS.txt"
+ },
+);