summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorStefan Sperling <ssperling@sysmocom.de>2018-06-25 15:19:17 +0200
committerStefan Sperling <ssperling@sysmocom.de>2018-06-25 15:35:22 +0200
commitb0ad3d8490421c7b60b7070c652c06980a2e31b4 (patch)
tree5861f756a80ae3a907e217f636e2a8cbf3f7237a /Makefile
parentdadde174254636573f28907e0d8ae8c61486f6bb (diff)
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
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile6
1 files changed, 5 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index fcd6601..a12a504 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)