X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=Debian%2FDebhelper%2FBuildsystem%2Fmakefile.pm;h=159f7c1e43f56139bcdd582743270ba1611c7571;hb=76719d85abaa3a536af862b0aac2307d735e84d8;hp=32ad517889b1151d7e68f436c00e1c9a12bb2b51;hpb=962a2e10c930e3504ea1c0327be2fdf70d53023e;p=debhelper.git diff --git a/Debian/Debhelper/Buildsystem/makefile.pm b/Debian/Debhelper/Buildsystem/makefile.pm index 32ad517..159f7c1 100644 --- a/Debian/Debhelper/Buildsystem/makefile.pm +++ b/Debian/Debhelper/Buildsystem/makefile.pm @@ -6,58 +6,9 @@ package Debian::Debhelper::Buildsystem::makefile; -=head1 NAME - -B - make (Makefile) - -=head1 SYNOPSIS - -B [B<--buildsystem>=I] ... - -=head1 DESCRIPTION - -Makefile based projects use C to control build process. C utility -is the most popular tool on *NIX for building & installing packages from -source. It is also a basis for most other popular build systems. For example, -GNU Autoconf (autoconf) or CMake (cmake) generate Fs during I -step and leave the rest of build process for C to handle. - -=head1 DH_AUTO NOTES - -Since C itself does not strictly define standard target names, a couple -of the most popular targets are tried for each building step. Whichever first -of them is discovered to exist, it is run. If neither of the tried targets -exist in the actual, the building step is assumed to have completed -successfully. However, if executed C target fails, the respective dh_auto -program will fail too. - -If MAKE environment variable is set, its value is executed rather than default -C command. - -Both in source (default) and out of source tree building modes are supported. -Either F, F or F file should be present in the -build directory for this debhelper build system to work. - -=head1 BUILD PROCESS - -=head2 Configure step - -=over 4 - -=item I - -Do nothing (auto-selection continues). - -=item I - -It will never be auto-selected at this step. - -=back - -=cut - 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 { @@ -80,13 +31,32 @@ sub exists_make_target { 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; } } @@ -119,92 +89,22 @@ sub check_auto_buildable { return 0; } -=head2 Build step - -=over 4 - -=item I - -Execute C (without arguments) with working directory changed to the build -directory. - -=item I - -If either F, F or F exists in the build -directory, but F does not exist in the source directory. - -=back - -=cut sub build { my $this=shift; - $this->doit_in_builddir($this->{makecmd}, @_); + $this->do_make(@_); } -=head2 Test step - -=over 4 - -=item I - -Try to C either I or I target (the first existing one) with -working directory changed to the build directory. - -=item I - -If either F, F or F exists in the build -directory, but F does not exist in the source directory. - -=back - -=cut sub test { my $this=shift; $this->make_first_existing_target(['test', 'check'], @_); } -=head2 Install step - -=over 4 - -=item I - -Try to run C with working directory changed to -the build directory. $desdir is the path to the appropriate temporary -installation directory under debian/ (see L). - -=item I - -If either F, F or F exists in the build -directory, but F does not exist in the source directory. - -=back - -=cut sub install { my $this=shift; my $destdir=shift; $this->make_first_existing_target(['install'], "DESTDIR=$destdir", @_); } -=head2 Clean step - -=over 4 - -=item I - -When building in source, try to C either I, I or -I target (the first existing one) in the source directory. When building -out of source tree, recursively remove the whole build directory. - -=item I - -If either F, F or F exists in the build -directory, but F does not exist in the source directory. - -=back - -=cut sub clean { my $this=shift; if (!$this->rmdir_builddir()) { @@ -212,15 +112,4 @@ sub clean { } } -=head1 SEE ALSO - -L - -=head1 AUTHORS - - Joey Hess - Modestas Vainius - -=cut - -1; +1