aboutsummaryrefslogtreecommitdiffstats
path: root/build-root
diff options
context:
space:
mode:
authorTom Jones <thj@freebsd.org>2024-02-07 13:17:17 +0000
committerDamjan Marion <dmarion@0xa5.net>2024-03-26 15:09:39 +0000
commit26eec75f2b30f4c03b4ca671165cd0d4823f0175 (patch)
tree97f2260489d8d76a89f61c7de64e4e0eb4f76dd0 /build-root
parentb10561bbecb2870360a731b4696bff920150720d (diff)
build: Detect number of CPUs for build processes on FreeBSD
Type: improvement Change-Id: Ia3a00266f47f0c3e567efa143ef08bf4e8cffe35 Signed-off-by: Tom Jones <thj@freebsd.org>
Diffstat (limited to 'build-root')
-rw-r--r--build-root/Makefile7
1 files changed, 7 insertions, 0 deletions
diff --git a/build-root/Makefile b/build-root/Makefile
index 68d295e6808..d69a94c1e41 100644
--- a/build-root/Makefile
+++ b/build-root/Makefile
@@ -650,11 +650,18 @@ configure_check_timestamp = \
# /proc/cpuinfo does not exist on platforms without a /proc and on some
# platforms, notably inside containers, it has no content. In those cases
# we assume there's 1 processor; we use 2*ncpu for the -j option.
+#
+# On FreeBSD we can call nproc to get the number of processors.
+#
# NB: GNU Make 4.2 will let us use '$(file </proc/cpuinfo)' to both test
# for file presence and content; for now this will have to do.
ifndef MAKE_PARALLEL_JOBS
+ifeq ($(shell uname), FreeBSD)
+MAKE_PARALLEL_JOBS = $(shell nproc)
+else
MAKE_PARALLEL_JOBS = $(if $(shell [ -f /proc/cpuinfo ] && head /proc/cpuinfo), \
$(shell grep -c ^processor /proc/cpuinfo), 2)
+endif # FreeBSD
endif
MAKE_PARALLEL_FLAGS ?= $(if $($(PACKAGE)_make_parallel_fails),,-j $(MAKE_PARALLEL_JOBS))