This patch tells make to, by default, run as many parallel jobs as the
compilation machine has CPUs.
This default can be overridden by the user by using the -j option explicitly
in the "make" command line, e.g., "make -j8" or "make -j". Unfortunately,
doing "make -j1" will not be supported, because GNU make doesn't give us
any way to differentiate between "make -j1" and the case of no -j option,
so "make -j1" will use our new default of `nproc` jobs, not one job.
I know that Dor and Avi *don't* like this patch, saying that people should
type the "-j" option themselves. Any other people have opinion about this
issue?
Signed-off-by: Nadav Har'El <
n...@cloudius-systems.com>
---
Makefile | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 85f4e7a..e8f9abf 100644
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,12 @@ all: $(submake)
$(call quiet, $(silentant) ant -Dmode=$(mode) -Dout=$(abspath $(out)/tests/bench) \
-e -f tests/bench/build.xml $(if $V,,-q), ANT tests/bench)
$(call only-if, $(mgmt), cd mgmt && ./gradlew --daemon :web:jar build)
- $(MAKE) -r -C $(dir $(submake)) $@
+ # By default, use -j `nproc`, to make reasonable use of all the CPUs
+ # available. If the user specified a different -j option, use that
+ # instead. Unfortunately, make gives us no way to differentiate between
+ # the user not giving any -j option at all, or using -j1, so "-j1"
+ # will not correctly use single-threaded make.
+ $(MAKE) $(if $(findstring j,$(MAKEFLAGS)),,-j$(shell nproc)) -r -C $(dir $(submake)) $@
$(submake): Makefile
mkdir -p $(dir $@)
--
1.8.3.1