]> git.vpit.fr Git - perl/modules/Test-Valgrind.git/blobdiff - Makefile.PL
Test real-life leaks with some XS
[perl/modules/Test-Valgrind.git] / Makefile.PL
index 62a9060bca44076d67a588b4ad2f05770a812e9c..1ac71726eae30d9e71bc2f3cbe8b3b752c4754f9 100644 (file)
@@ -4,6 +4,14 @@ use strict;
 use warnings;
 use ExtUtils::MakeMaker;
 
+BEGIN {
+ eval { require Config };
+ die 'OS unsupported' if $@;
+ Config->import(qw/%Config/);
+ eval { require File::Spec };
+ die 'OS unsupported' if $@;
+}
+
 my $vg;
 print 'Checking for valgrind >= 3.1.0 in PATH... ';
 for (split /:/, $ENV{PATH}) {
@@ -13,7 +21,7 @@ for (split /:/, $ENV{PATH}) {
   if ($ver =~ s/^valgrind-//) {
    $ver = join '', map chr, split /\./, $ver;
    if ($ver ge v3.1.0) {
-    print "yes, $_\n";
+    print "$_\n";
     $vg = $_;
     last;
    }
@@ -25,9 +33,36 @@ if (!$vg) {
  die 'OS unsupported';
 }
 
+# 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 $cc;
+CC:
+for my $c (@ccs) {
+ for my $dir (split /$Config{path_sep}/, $ENV{PATH}) {
+  my $abs = File::Spec->catfile($dir, $c);
+  if (-x $abs or MM->maybe_command($abs)) {
+   $cc = $c;
+   last CC;
+  }
+ }
+}
+my (@C);
+if ($cc) {
+ my $xs = 'Valgrind.xs';
+ (my $c = $xs) =~ s/\.xs$/.c/;
+ push @C, $c;
+ print $cc, "\n";
+} else {
+ print "none\n";
+}
+
 my $BUILD_REQUIRES = {
  'ExtUtils::MakeMaker' => 0,
- 'Test::More'          => 0
+ 'File::Copy'          => 0,
+ 'Test::More'          => 0,
+ 'XSLoader'            => 0
 };
 
 sub build_req {
@@ -58,14 +93,18 @@ WriteMakefile(
     LICENSE       => 'perl',
     VERSION_FROM  => 'lib/Test/Valgrind.pm',
     ABSTRACT_FROM => 'lib/Test/Valgrind.pm',
-    PL_FILES      => { './Gensupp.PL' => 'lib/' . $supp },
+    PL_FILES      => {
+        './Gensupp.PL'    => 'blib/archpub/' . $supp,
+        './FixInstall.PL' => 'Makefile.bak',
+    },
+    OPTIMIZE      => '-g',
     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,
+        => 'blib/archpub/Test/Valgrind/Suppressions.pm',
     },
+    C             => \@C,
     PREREQ_PM     => {
         'Carp'                  => 0,
         'Exporter'              => 0,
@@ -74,20 +113,21 @@ WriteMakefile(
         'Test::More'            => 0,
     },
     dist          => {
-        PREOP      => 'pod2text lib/Test/Valgrind.pm > $(DISTVNAME)/README; '
+        PREOP      => "touch lib/$supp; "
+                      . '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 Debian_CPANTS.txt" },
+    clean         => { FILES => "Test-Valgrind-* lib/$supp Makefile.bak *.gcov *.gcda *.gcno cover_db Debian_CPANTS.txt" },
 );
 1 while unlink 'lib/' . $supp;
 
 package MY;
 
 sub postamble {
- <<POSTAMBLE;
+ <<'POSTAMBLE';
 clean ::
-\t\$(CP) lib/Test/Valgrind/Suppressions.{tpl,pm}
-\t\$(TOUCH) lib/Test/Valgrind/perlTestValgrind.supp
+       $(CP) lib/Test/Valgrind/Suppressions.{tpl,pm}
+       $(TOUCH) lib/Test/Valgrind/perlTestValgrind.supp
 POSTAMBLE
 }