From bc0ee0b54dd4dde15c10c81bd8cade3bd6d5d9d7 Mon Sep 17 00:00:00 2001 From: Alex Jurkiewicz Date: Fri, 29 Mar 2019 00:26:08 +1100 Subject: [PATCH] feat: Auto-detect number of processors (#1970) In case anyone is building on FreeBSD or another unsupported OS, leave the default at four. --- Makefile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c82c016ae..791c69a31 100644 --- a/Makefile +++ b/Makefile @@ -12,12 +12,22 @@ DEBUG=${ALL_DEBUG} #export EXTRALINK export MAKE export CURVER?=2.0.4 -export MAKEOPT=-j 4 ifneq (,$(wildcard /etc/os-release)) DISTRO := $(shell gawk -F= '/^NAME/{print $$2}' /etc/os-release) else - DISTRO := unknown + DISTRO := Unknown endif + +NPROCS := 4 +OS := $(shell uname -s) +ifeq ($(OS),Linux) + NPROCS := $(shell nproc) +endif +ifeq ($(OS),Darwin) + NPROCS := $(shell sysctl -n hw.ncpu) +endif +export MAKEOPT=-j ${NPROCS} + ifeq ($(wildcard /usr/lib/systemd/system), /usr/lib/systemd/system) SYSTEMD=1 else