-# A buildsystem plugin for handling simple Makefile based projects.
+# A debhelper build system class for handling simple Makefile based projects.
#
# Copyright: © 2008 Joey Hess
# © 2008-2009 Modestas Vainius
package Debian::Debhelper::Buildsystem::makefile;
use strict;
-use Debian::Debhelper::Dh_Lib qw(escape_shell);
+use Debian::Debhelper::Dh_Lib qw(escape_shell is_make_jobserver_unavailable
+ clean_makeflags);
use base 'Debian::Debhelper::Buildsystem';
sub get_makecmd_C {
return length($ret);
}
+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
+ if (defined $this->get_parallel() || is_make_jobserver_unavailable()) {
+ clean_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;
}
}
sub build {
my $this=shift;
- $this->doit_in_builddir($this->{makecmd}, @_);
+ $this->do_make(@_);
}
sub test {
}
}
-1;
+1