From 0dfb2f6ef57d9d537fd3ea67d83595c84a166f7f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 14 Nov 2019 10:49:54 -0800 Subject: [PATCH] Pass the make's -j option to rpmbuild For most people simply running "make autospec" or "make build", this will have no effect. The RPM macro %{_smp_mflags} is predefined to be the number of CPUs in your system anyway (output of getconf _NPROCESSORS_ONLN). But if you do have MAKEFLAGS set in your environment to your CPU number (and you should), that will get passed to rpmbuild, which then uses it during the build. And if you, like me, have it set to a slightly higher number, RPM will use that too. But if you run "make -jN autospec", then that N will be passed to the build. This is especially important if you have something doing "make -j1": RPM will be -j1 too! So instead of "make -j1", run "MAKEFLAGS= make" --- Makefile.common | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile.common b/Makefile.common index e616e15..7c7e506 100644 --- a/Makefile.common +++ b/Makefile.common @@ -21,7 +21,8 @@ RPMS ?= $(LATEST_RPMS) WITH_SUDO = $(shell cmp /usr/bin/mock /usr/sbin/mock &> /dev/null && echo sudo ) # MOCK_CONFIG_VAL is set in Makefile.shared -MOCK ?= $(WITH_SUDO) /usr/bin/mock -r $(MOCK_CONFIG_VAL) $(MOCK_OPTS) +MOCK_SMP_FLAGS=$(patsubst -j%, -D_smp_mflags\ -j%,$(filter -j%, $(MAKEFLAGS))) +MOCK ?= $(WITH_SUDO) /usr/bin/mock -r $(MOCK_CONFIG_VAL) $(MOCK_SMP_FLAGS) $(MOCK_OPTS) ifneq ($(wildcard upstream),) __allsources := $(notdir $(strip $(shell cat upstream))) @@ -172,7 +173,7 @@ autospec: preautospec-checks pullrebase localreponotice clean-old-content --name $(PKG_NAME) \ --archives $(ARCHIVES) \ --mock-config $(MOCK_CONFIG_VAL) \ - --mock-opts="$(MOCK_OPTS)" \ + --mock-opts="$(MOCK_SMP_FLAGS) $(MOCK_OPTS)" \ $${SETVERSION:+ --version $${SETVERSION}} \ $${NON_INTERACTIVE:+ --non_interactive} \ $${SKIP_GIT:+ --skip-git} \