X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debian%2FDebhelper%2FBuildsystem%2Fmakefile.pm;h=1eb4b5b50b14eaf81bbb7de4e4065c2fc2b56425;hb=4390c7584f2fd14e53b5ea54a5fcabd826fc9f47;hp=d84d3349bad49a96dd06811f0904016a7365e5ab;hpb=fdf8b4a8b4b4f50c39b6e4266773539bc13d6e56;p=debhelper.git diff --git a/Debian/Debhelper/Buildsystem/makefile.pm b/Debian/Debhelper/Buildsystem/makefile.pm index d84d334..1eb4b5b 100644 --- a/Debian/Debhelper/Buildsystem/makefile.pm +++ b/Debian/Debhelper/Buildsystem/makefile.pm @@ -7,27 +7,38 @@ package Debian::Debhelper::Buildsystem::makefile; use strict; -use Debian::Debhelper::Dh_Lib qw(escape_shell); +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=; + chomp $output; + close MAKE; + open(STDERR, ">&SAVEDERR"); + return defined $output && length $output; +} + +sub do_make { + my $this=shift; + + # Avoid possible warnings about unavailable jobserver, + # and force make to start a new jobserver. + clean_jobserver_makeflags(); + + # 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}, @_); } sub make_first_existing_target { @@ -36,7 +47,7 @@ sub make_first_existing_target { foreach my $target (@$targets) { if ($this->exists_make_target($target)) { - $this->doit_in_builddir($this->{makecmd}, $target, @_); + $this->do_make($target, @_); return $target; } } @@ -58,20 +69,28 @@ 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; } sub build { my $this=shift; - $this->doit_in_builddir($this->{makecmd}, @_); + $this->do_make(@_); } sub test { @@ -82,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 { @@ -92,4 +113,4 @@ sub clean { } } -1; +1