Package: dpkg-dev
Version: 1.17.9
Severity: wishlist
Tags: patch

Hi,

 Recently I've watched openSUSE conference video and they uses %{?_smp_flags} 
 rpm macro to detect multi CPU cores to be enabled to do parallel building
 package.

 http://presentations.nordisch.org/packaging-oSC2014/#/13


 Then, I'd like to introduce such feature (not manually specify -j<job number>,
 but automatically uses all CPUs and run multiple make) to dpkg-buildpackage,
 patch attached.


Pros)
 - Automatically use all CPU cores to build package, faster build.

Cons)
 - It may introduce FTBFS to some packages (e.g. Bug#694726), but it should
   be fixed, right? ;)


diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl
index ec40e7d..adc7acd 100755
--- a/scripts/dpkg-buildpackage.pl
+++ b/scripts/dpkg-buildpackage.pl
@@ -129,6 +129,7 @@ my $signcommand;
 my $noclean;
 my $cleansource;
 my $parallel;
+my $smp;
 my $checkbuilddep = 1;
 my @checkbuilddep_opts;
 my @source_opts;
@@ -356,6 +357,12 @@ if (defined $parallel) {
     $ENV{MAKEFLAGS} .= " -j$parallel";
     $build_opts->set('parallel', $parallel);
     $build_opts->export();
+} else {
+    $smp = int `getconf _NPROCESSORS_ONLN`;
+    $ENV{MAKEFLAGS} ||= '';
+    $ENV{MAKEFLAGS} .= " -j$smp";
+    $build_opts->set('parallel', $smp);
+    $build_opts->export();
 }
 
 set_build_profiles(@build_profiles) if @build_profiles;


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to