build: Detect number of CPUs for build processes on FreeBSD
[vpp.git] / build-root / 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))