From 356fd73a7b24fd5fdcc093639c12dfd60f35d681 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 22 Jan 2014 10:49:56 +0200 Subject: Make CPU limit for building configurable through _smp_ncpus_max macro - Makes the max number of cpu's used by %{_smp_mflags} configurable on spec, user or system level. - Originally reported as RhBug:669638 and included in redhat-rpm-config in RHEL/Fedora, but makes sense to have generally available. --- platform.in | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'platform.in') diff --git a/platform.in b/platform.in index 45c65a599..34ce787bf 100644 --- a/platform.in +++ b/platform.in @@ -47,9 +47,13 @@ %_defaultdocdir %{_datadir}/doc +# Maximum number of CPU's to use when building, 0 for unlimited. +#%_smp_ncpus_max 0 %_smp_mflags %([ -z "$RPM_BUILD_NCPUS" ] \\\ && RPM_BUILD_NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"; \\\ - [ "$RPM_BUILD_NCPUS" -gt 1 ] && echo "-j$RPM_BUILD_NCPUS") + ncpus_max=%{?_smp_ncpus_max}; \\\ + if [ -n "$ncpus_max" ] && [ "$ncpus_max" -gt 0 ] && [ "$RPM_BUILD_NCPUS" -gt "$ncpus_max" ]; then RPM_BUILD_NCPUS="$ncpus_max"; fi; \\\ + if [ "$RPM_BUILD_NCPUS" -gt 1 ]; then echo "-j$RPM_BUILD_NCPUS"; fi) #============================================================================== # ---- Build policy macros. -- cgit v1.2.1