diff options
author | Modestas Vainius <modestas@vainius.eu> | 2009-10-28 15:49:34 -0400 |
---|---|---|
committer | Joey Hess <joey@gnu.kitenet.net> | 2009-10-28 15:49:34 -0400 |
commit | dace0773fe5f66fdf040f54383322e21a65fa1e8 (patch) | |
tree | d03e084c1980708e31773b1b422cfec4e5546c7d /Debian/Debhelper/Buildsystem/makefile.pm | |
parent | 834d95aaba24e5cee1c5a74078a09443f5e122a7 (diff) |
Support parallel building in makefile buildsystem
1) Add routine to Dh_Lib (used by dh and makefile.pm) which is capable of
detecting make jobserver and job control options from the MAKEFLAGS environment
variable. It also generates and returns a clean up MAKEFLAGS from these
options.
2) Add --parallel option to build system framework which allows source packages
to specify that they support parallel building. Optional value for this option is
the number of maximum parallel process to allow. However, the actual number of
parallel process (if any) for the specific build is determined from
DEB_BUILD_OPTIONS env variable as specified by Debian Policy.
By default (no --parallel option) parallel is neither enabled nor disabled
(depends on the external environment). However, dh may pass --parallel to
dh_auto_* implicitly in case 4) described below.
3) Add parallel support for makefile buildsystem. This implementation
forcefully starts a new make job server (or disables parallel) for the number
of process requested. If --parallel was not passed to the build system at all,
the build system will only clean up MAKEFLAGS from stale jobserver options to
avoid pointless make warnings.
4) If dh detects that it is being run by dpkg-buildpackage -jX and it is NOT
run with "+" prefix from debian/rules (i.e. jobserver is not reachable), it
enables --parallel implicitly. This closes: #532805.
Signed-off-by: Modestas Vainius <modestas@vainius.eu>
Diffstat (limited to 'Debian/Debhelper/Buildsystem/makefile.pm')
-rw-r--r-- | Debian/Debhelper/Buildsystem/makefile.pm | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/Debian/Debhelper/Buildsystem/makefile.pm b/Debian/Debhelper/Buildsystem/makefile.pm index 3809d594..6629d25b 100644 --- a/Debian/Debhelper/Buildsystem/makefile.pm +++ b/Debian/Debhelper/Buildsystem/makefile.pm @@ -7,7 +7,7 @@ package Debian::Debhelper::Buildsystem::makefile; use strict; -use Debian::Debhelper::Dh_Lib qw(escape_shell); +use Debian::Debhelper::Dh_Lib qw(escape_shell get_make_jobserver_status); use base 'Debian::Debhelper::Buildsystem'; sub get_makecmd_C { @@ -30,13 +30,38 @@ sub exists_make_target { return length($ret); } +sub do_make { + my $this=shift; + + # Always clean MAKEFLAGS from unavailable jobserver options. If parallel + # is enabled, do more extensive clean up from all job control specific + # options and start our own jobserver if parallel building (> 1) was + # requested. + 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}; + } + } + + # Start a new jobserver if parallel building was requested + if (defined $this->get_parallel()) { + unshift @_, "-j" . ($this->get_parallel() > 1 ? $this->get_parallel() : 1); + } + + $this->doit_in_builddir($this->{makecmd}, @_); +} + sub make_first_existing_target { my $this=shift; my $targets=shift; foreach my $target (@$targets) { if ($this->exists_make_target($target)) { - $this->doit_in_builddir($this->{makecmd}, $target, @_); + $this->do_make($target, @_); return $target; } } @@ -71,7 +96,7 @@ sub check_auto_buildable { sub build { my $this=shift; - $this->doit_in_builddir($this->{makecmd}, @_); + $this->do_make(@_); } sub test { |