From b0ad3d8490421c7b60b7070c652c06980a2e31b4 Mon Sep 17 00:00:00 2001 From: Stefan Sperling Date: Mon, 25 Jun 2018 15:19:17 +0200 Subject: default to number of CPUs for parallel make jobs The previous default behaviour was to always run 'make -j8', which can cause C++ build failures on machines which are low on memory. "Low" being a relative measure; I've seen failures with 4GB of RAM. Rather than assuming a beefy 8-core box, try to detect the number of available CPU cores with nproc(1) from GNU coreutils and set the number of parallel make jobs to the number of CPU cores. If this command is not available, default to a safe choice: -j1 Note that installing ccache will speed up repeated builds a lot more than -jX ever will, so falling back to -j1 isn't very bad. Change-Id: I61c3ea1b3cb5b64eecb08ad6c390594f70cdf785 --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index fcd66012..a12a5041 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,10 @@ SUBDIRS=bsc bsc-nat bts ggsn_tests hlr lapdm mgw msc pcu selftest sgsn sip sysinfo -PARALLEL_MAKE ?= -j8 +NPROC=$(shell nproc 2>/dev/null) +ifeq ($(NPROC),) +NPROC=1 +endif +PARALLEL_MAKE ?= -j$(NPROC) # This master makefile allows you to do things like # make clean (remove all generated binary, c++ and symlinks) -- cgit v1.2.3