[PATCH 1/1] kbuild: deb-pkg: Allow parallel build

From: Bastian Germann
Date: Mon Mar 13 2023 - 13:12:29 EST


Currently, the only way to build the deb-pkg generated package parallely
is adding -jN to the MAKEFLAGS environment variable. The package ignores
the usual parallel build option that is described in Debian Policy §4.9.1.

Derive make's -j parameter from the DEB_BUILD_OPTIONS environment variable
that ends up being set by Debian's build tools.

Link: https://www.debian.org/doc/debian-policy/ch-source.html
Signed-off-by: Bastian Germann <bage@xxxxxxxxxxxxx>
---
scripts/package/deb-build-option | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/scripts/package/deb-build-option b/scripts/package/deb-build-option
index b079b0d121d4..dd170e2b3018 100755
--- a/scripts/package/deb-build-option
+++ b/scripts/package/deb-build-option
@@ -7,6 +7,12 @@ if [ -z "${CROSS_COMPILE}${cross_compiling}" -a "${DEB_HOST_ARCH}" != "${DEB_BUI
echo CROSS_COMPILE=${DEB_HOST_GNU_TYPE}-
fi

+for build_opt in $DEB_BUILD_OPTIONS; do
+ if [ "${build_opt#parallel=}" != "$build_opt" ]; then
+ echo -j${build_opt#parallel=}
+ fi
+done
+
version=$(dpkg-parsechangelog -S Version)
version_upstream="${version%-*}"
debian_revision="${version#${version_upstream}}"
--
2.39.2