diff --git a/rules/config b/rules/config index e813cd7ef1c..66f936c1fa0 100644 --- a/rules/config +++ b/rules/config @@ -16,6 +16,11 @@ # container. SONIC_CONFIG_BUILD_JOBS = 1 +# SONIC_CONFIG_BUILD_JOBS - set number of jobs for number of jobs per package. +# Corresponding -j argument will be passed to make/dpkg commands that build separate packages +# container. +SONIC_CONFIG_MAKE_JOBS = $(shell nproc) + # SONIC_CONFIG_LOG_TO_FILES - print output from execution of rule for each # target into separate log file under target/log/. # Useful when executing parallel build diff --git a/slave.mk b/slave.mk index c8ffbd8086f..40e28d6d67a 100644 --- a/slave.mk +++ b/slave.mk @@ -71,6 +71,7 @@ override PASSWORD := $(DEFAULT_PASSWORD) endif MAKEFLAGS += -j $(SONIC_CONFIG_BUILD_JOBS) +export SONIC_CONFIG_MAKE_JOBS ############################################################################### ## Dumping key config attributes associated to current building exercise @@ -178,7 +179,7 @@ $(addprefix $(DEBS_PATH)/, $(SONIC_DPKG_DEBS)) : $(DEBS_PATH)/% : .platform $$(a if [ -f $($*_SRC_PATH).patch/series ]; then pushd $($*_SRC_PATH) && QUILT_PATCHES=../$(notdir $($*_SRC_PATH)).patch quilt push -a; popd; fi pushd $($*_SRC_PATH) $(LOG) [ ! -f ./autogen.sh ] || ./autogen.sh $(LOG) - dpkg-buildpackage -rfakeroot -b -us -uc $(LOG) + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) $(LOG) popd $(LOG) # clean up if [ -f $($*_SRC_PATH).patch/series ]; then pushd $($*_SRC_PATH) && quilt pop -a -f; popd; fi diff --git a/src/hiredis/Makefile b/src/hiredis/Makefile index f8d9db43148..d302b327d31 100644 --- a/src/hiredis/Makefile +++ b/src/hiredis/Makefile @@ -14,7 +14,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : dpkg-source -x hiredis_$(HIREDIS_VERSION_FULL).dsc pushd hiredis-$(HIREDIS_VERSION) - fakeroot debian/rules binary + fakeroot debian/rules -j$(SONIC_CONFIG_MAKE_JOBS) binary popd mv $* $(DERIVED_TARGETS) $(DEST)/ diff --git a/src/initramfs-tools/Makefile b/src/initramfs-tools/Makefile index c7522aa3f66..95d5c24d118 100644 --- a/src/initramfs-tools/Makefile +++ b/src/initramfs-tools/Makefile @@ -15,7 +15,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Build the package rm -f debian/*.debhelper.log - dpkg-buildpackage -rfakeroot -b -us -uc + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) popd mv $* $(DEST)/ diff --git a/src/isc-dhcp/Makefile b/src/isc-dhcp/Makefile index b043c0bb266..44e77cdd9b4 100644 --- a/src/isc-dhcp/Makefile +++ b/src/isc-dhcp/Makefile @@ -20,7 +20,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Build source and Debian packages pushd ./isc-dhcp - dpkg-buildpackage -rfakeroot -b -us -uc + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) popd # Move the newly-built .deb packages to the destination directory diff --git a/src/libnl3/Makefile b/src/libnl3/Makefile index 97beb746454..efd234424df 100644 --- a/src/libnl3/Makefile +++ b/src/libnl3/Makefile @@ -27,7 +27,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : quilt push quilt push quilt push - dpkg-buildpackage -rfakeroot -b -us -uc + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/libteam/Makefile b/src/libteam/Makefile index c2b8a09cff6..283a6b56fbe 100644 --- a/src/libteam/Makefile +++ b/src/libteam/Makefile @@ -28,7 +28,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : mv tmp/debian libteam/ rm -rf tmp pushd ./libteam - dpkg-buildpackage -rfakeroot -b -us -uc + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/mpdecimal/Makefile b/src/mpdecimal/Makefile index c7f94203f47..5603c44b445 100644 --- a/src/mpdecimal/Makefile +++ b/src/mpdecimal/Makefile @@ -14,7 +14,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : dpkg-source -x mpdecimal_$(MPDECIMAL_VERSION_FULL).dsc pushd mpdecimal-$(MPDECIMAL_VERSION) - dpkg-buildpackage -us -uc -b + dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) popd mv $* $(DERIVED_TARGETS) $(DEST)/ diff --git a/src/python3/Makefile b/src/python3/Makefile index 80f977ff579..d7718cbeccf 100644 --- a/src/python3/Makefile +++ b/src/python3/Makefile @@ -32,7 +32,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : fi done - dpkg-buildpackage -rfakeroot -us -uc -b + dpkg-buildpackage -rfakeroot -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) popd cp $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/redis/Makefile b/src/redis/Makefile index ddc952ff75a..8cd4458b433 100644 --- a/src/redis/Makefile +++ b/src/redis/Makefile @@ -16,7 +16,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : dpkg-source -x redis_$(REDIS_VERSION_FULL).dsc pushd redis-$(REDIS_VERSION) - DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -us -uc -b + DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/snmpd/Makefile b/src/snmpd/Makefile index ace9fa6d4b8..457cd2ef05d 100644 --- a/src/snmpd/Makefile +++ b/src/snmpd/Makefile @@ -23,7 +23,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : dpkg-source -x net-snmp_$(SNMPD_VERSION_FULL).dsc pushd net-snmp-$(SNMPD_VERSION) - fakeroot debian/rules binary + fakeroot debian/rules -j$(SONIC_CONFIG_MAKE_JOBS) binary popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/thrift/Makefile b/src/thrift/Makefile index 2a4f67b9175..786a10641e6 100644 --- a/src/thrift/Makefile +++ b/src/thrift/Makefile @@ -20,7 +20,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : dpkg-source -x thrift_$(THRIFT_VERSION_FULL).dsc pushd thrift-$(THRIFT_VERSION) patch -p1 < ../patch/THRIFT-3577-assertion-failed.patch - DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -d -rfakeroot -b -us -uc + DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -d -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) popd mv $(DERIVED_TARGETS) $* $(DEST)/