Makefile support for using NPROCS as an env var
authorCampbell Barton <ideasman42@gmail.com>
Sat, 13 Jun 2015 22:26:33 +0000 (08:26 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 13 Jun 2015 22:27:29 +0000 (08:27 +1000)
GNUmakefile

index 80366af261044a5139a58d38efde9c6f76b9b875..d37d810626f780e00461b15c549bcc111ee7a05b 100644 (file)
@@ -81,18 +81,20 @@ endif
 
 # -----------------------------------------------------------------------------
 # Get the number of cores for threaded build
-NPROCS:=1
-ifeq ($(OS), Linux)
-       NPROCS:=$(shell nproc)
-endif
-ifeq ($(OS), Darwin)
-       NPROCS:=$(shell sysctl -a | grep "hw.ncpu" | cut -d" " -f3)
-endif
-ifeq ($(OS), FreeBSD)
-       NPROCS:=$(shell sysctl -a | grep "hw.ncpu" | cut -d" " -f2 )
-endif
-ifeq ($(OS), NetBSD)
-       NPROCS:=$(shell sysctl -a | grep "hw.ncpu" | cut -d" " -f2 )
+ifndef NPROCS
+       NPROCS:=1
+       ifeq ($(OS), Linux)
+               NPROCS:=$(shell nproc)
+       endif
+       ifeq ($(OS), Darwin)
+               NPROCS:=$(shell sysctl -a | grep "hw.ncpu" | cut -d" " -f3)
+       endif
+       ifeq ($(OS), FreeBSD)
+               NPROCS:=$(shell sysctl -a | grep "hw.ncpu" | cut -d" " -f2 )
+       endif
+       ifeq ($(OS), NetBSD)
+               NPROCS:=$(shell sysctl -a | grep "hw.ncpu" | cut -d" " -f2 )
+       endif
 endif