2017-09-20 12:04:36 +02:00
|
|
|
ifneq (, $(filter buildtest info-concurrency, $(MAKECMDGOALS)))
|
|
|
|
ifeq (, $(strip $(NPROC)))
|
|
|
|
# Linux (utility program)
|
|
|
|
NPROC := $(shell nproc 2>/dev/null)
|
|
|
|
|
|
|
|
ifeq (, $(strip $(NPROC)))
|
|
|
|
# Linux (generic)
|
|
|
|
NPROC := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
|
|
|
|
endif
|
|
|
|
ifeq (, $(strip $(NPROC)))
|
|
|
|
# BSD (at least FreeBSD and Mac OSX)
|
|
|
|
NPROC := $(shell sysctl -n hw.ncpu 2>/dev/null)
|
|
|
|
endif
|
|
|
|
ifeq (, $(strip $(NPROC)))
|
|
|
|
# Fallback
|
|
|
|
NPROC := 1
|
|
|
|
endif
|
|
|
|
|
|
|
|
NPROC := $(shell echo $$(($(NPROC) + 1)))
|
|
|
|
|
|
|
|
ifneq (, $(NPROC_MAX))
|
2018-03-22 16:20:19 +01:00
|
|
|
NPROC := $(shell if [ $(NPROC) -gt $(NPROC_MAX) ]; then echo $(NPROC_MAX); else echo $(NPROC); fi)
|
2017-09-20 12:04:36 +02:00
|
|
|
endif
|
|
|
|
ifneq (, $(NPROC_MIN))
|
2018-03-22 16:20:19 +01:00
|
|
|
NPROC := $(shell if [ $(NPROC) -lt $(NPROC_MIN) ]; then echo $(NPROC_MIN); else echo $(NPROC); fi)
|
2017-09-20 12:04:36 +02:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
.PHONY: info-concurrency
|
|
|
|
|
|
|
|
info-concurrency:
|
|
|
|
@echo "$(NPROC)"
|