build: Detect number of CPUs for build processes on FreeBSD 09/40609/3
authorTom Jones <thj@freebsd.org>
Wed, 7 Feb 2024 13:17:17 +0000 (13:17 +0000)
committerDamjan Marion <dmarion@0xa5.net>
Tue, 26 Mar 2024 15:09:39 +0000 (15:09 +0000)
Type: improvement
Change-Id: Ia3a00266f47f0c3e567efa143ef08bf4e8cffe35
Signed-off-by: Tom Jones <thj@freebsd.org>
build-root/Makefile
build/external/Makefile

index 68d295e..d69a94c 100644 (file)
@@ -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))
 
index c5e6f63..046dd74 100644 (file)
@@ -21,8 +21,12 @@ INSTALL_DIR      ?= $(CURDIR)/_install
 PKG_VERSION ?= $(shell git describe --abbrev=0 --match 'v[0-9]*' | cut -d- -f1 | cut -dv -f2 | cut -d. -f1,2)
 PKG_SUFFIX ?= $(shell git log --oneline v$(PKG_VERSION)-rc0.. . | wc -l)
 SOURCE_DATE_EPOCH ?= $(shell git log -1 --pretty=%ct .)
+ifeq ($shell(uname), FreeBSD)
+JOBS := $(shell nproc)
+else
 JOBS := $(if $(shell [ -f /proc/cpuinfo ] && head /proc/cpuinfo),\
        $(shell grep -c ^processor /proc/cpuinfo), 2)
+endif  # FreeBSD
 
 B := $(BUILD_DIR)
 I := $(INSTALL_DIR)