]> git.donarmstrong.com Git - debhelper.git/blobdiff - Debian/Debhelper/Buildsystem/makefile.pm
dh_auto_install: Set AM_UPDATE_INFO_DIR=no to avoid automake generating an info dir...
[debhelper.git] / Debian / Debhelper / Buildsystem / makefile.pm
index f21b2cbd6971c06e634b1ea238cb643b51831c13..1eb4b5b50b14eaf81bbb7de4e4065c2fc2b56425 100644 (file)
@@ -7,50 +7,36 @@
 package Debian::Debhelper::Buildsystem::makefile;
 
 use strict;
-use Debian::Debhelper::Dh_Lib qw(escape_shell get_make_jobserver_status);
+use Debian::Debhelper::Dh_Lib qw(escape_shell clean_jobserver_makeflags);
 use base 'Debian::Debhelper::Buildsystem';
 
-sub get_makecmd_C {
-       my $this=shift;
-       my $buildpath = $this->get_buildpath();
-       if ($buildpath ne '.') {
-               return $this->{makecmd} . " -C " . escape_shell($buildpath);
-       }
-       return $this->{makecmd};
-}
-
 sub exists_make_target {
        my ($this, $target) = @_;
-       my $makecmd=$this->get_makecmd_C();
 
        # Use make -n to check to see if the target would do
        # anything. There's no good way to test if a target exists.
-       my $ret=`$makecmd -s -n --no-print-directory $target 2>/dev/null`;
-       chomp $ret;
-       return length($ret);
+       my @opts=("-s", "-n", "--no-print-directory");
+       my $buildpath = $this->get_buildpath();
+       unshift @opts, "-C", $buildpath if $buildpath ne ".";
+       open(SAVEDERR, ">&STDERR");
+       open(STDERR, ">/dev/null");
+       open(MAKE, "-|", $this->{makecmd}, @opts, $target);
+       my $output=<MAKE>;
+       chomp $output;
+       close MAKE;
+       open(STDERR, ">&SAVEDERR");
+       return defined $output && length $output;
 }
 
 sub do_make {
        my $this=shift;
 
-       # Remove unavailable jobserver options from MAKEFLAGS.
-       # Always clean MAKEFLAGS from unavailable jobserver options. If parallel
-       # is enabled, do more extensive clean up from all job control specific
-       # options
-       my ($status, $makeflags) = get_make_jobserver_status();
-       if ($status eq "jobserver-unavailable" || defined $this->get_parallel()) {
-               if (defined $makeflags) {
-                       $ENV{MAKEFLAGS} = $makeflags;
-               }
-               else {
-                       delete $ENV{MAKEFLAGS} if exists $ENV{MAKEFLAGS};
-               }
-       }
+       # Avoid possible warnings about unavailable jobserver,
+       # and force make to start a new jobserver.
+       clean_jobserver_makeflags();
 
-       # Start a new jobserver if parallel building was requested
-       if (defined $this->get_parallel()) {
-               unshift @_, "-j" . ($this->get_parallel() > 1 ? $this->get_parallel() : 1);
-       }
+       # Note that this will override any -j settings in MAKEFLAGS.
+       unshift @_, "-j" . ($this->get_parallel() > 0 ? $this->get_parallel() : "");
 
        $this->doit_in_builddir($this->{makecmd}, @_);
 }
@@ -83,13 +69,21 @@ sub check_auto_buildable {
        my $this=shift;
        my ($step) = @_;
 
-       # Handles build, test, install, clean; configure - next class
-       if (grep /^\Q$step\E$/, qw{build test install clean}) {
+       if (-e $this->get_buildpath("Makefile") ||
+           -e $this->get_buildpath("makefile") ||
+           -e $this->get_buildpath("GNUmakefile"))
+       {
                # This is always called in the source directory, but generally
                # Makefiles are created (or live) in the the build directory.
-               return -e $this->get_buildpath("Makefile") ||
-                      -e $this->get_buildpath("makefile") ||
-                      -e $this->get_buildpath("GNUmakefile");
+               return 1;
+       } elsif ($step eq "clean" && defined $this->get_builddir() &&
+                $this->check_auto_buildable("configure"))
+       {
+               # Assume that the package can be cleaned (i.e. the build directory can
+               # be removed) as long as it is built out-of-source tree and can be
+               # configured. This is useful for derivative buildsystems which
+               # generate Makefiles.
+               return 1;
        }
        return 0;
 }
@@ -107,7 +101,9 @@ sub test {
 sub install {
        my $this=shift;
        my $destdir=shift;
-       $this->make_first_existing_target(['install'], "DESTDIR=$destdir", @_);
+       $this->make_first_existing_target(['install'],
+               "DESTDIR=$destdir",
+               "AM_UPDATE_INFO_DIR=no", @_);
 }
 
 sub clean {