aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build-root/Makefile17
-rw-r--r--dpdk/Makefile8
2 files changed, 14 insertions, 11 deletions
diff --git a/build-root/Makefile b/build-root/Makefile
index f2f77804ad4..0fed520c728 100644
--- a/build-root/Makefile
+++ b/build-root/Makefile
@@ -653,16 +653,13 @@ configure_check_timestamp = \
# Package build
######################################################################
-linux_n_cpus = `grep '^processor' /proc/cpuinfo | wc -l`
-
-MAKE_PARALLEL_JOBS = \
- -j $(shell \
- if [ -f /proc/cpuinfo ] ; then \
- expr 2 '*' $(linux_n_cpus) ; \
- else \
- echo 1 ; \
- fi)
-
+# /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.
+# 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.
+MAKE_PARALLEL_JOBS = -j $(if $(shell [ -f /proc/cpuinfo ] && head /proc/cpuinfo), \
+ $(shell expr 2 '*' $$(grep -c ^processor /proc/cpuinfo)), 2)
MAKE_PARALLEL_FLAGS = $(if $($(PACKAGE)_make_parallel_fails),,$(MAKE_PARALLEL_JOBS))
# Make command shorthand for packages & tools.
diff --git a/dpdk/Makefile b/dpdk/Makefile
index d781ed5db40..06ba1270ed1 100644
--- a/dpdk/Makefile
+++ b/dpdk/Makefile
@@ -77,7 +77,13 @@ else
$(error unknown platform)
endif
-JOBS := $(shell grep processor /proc/cpuinfo | wc -l)
+# /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.
+# 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.
+JOBS := $(if $(shell [ -f /proc/cpuinfo ] && head /proc/cpuinfo),\
+ $(shell expr 2 '*' $$(grep -c ^processor /proc/cpuinfo)), 2)
# compiler/linker custom arguments
DPDK_CPU_CFLAGS := -pie -fPIC