MAKEALL: Automatically use parallel builds
authorWolfgang Denk <wd@denx.de>
Mon, 8 Dec 2008 23:39:08 +0000 (00:39 +0100)
committerWolfgang Denk <wd@denx.de>
Mon, 8 Dec 2008 23:39:08 +0000 (00:39 +0100)
Add logic to the MAKEALL script to determine the number of CPU cores
on the system, and run a parallel build if there is more than one.
Usually this significantrly accelerates builds.

Allow to manually adjust the number of parallel make jobs by using
the "BUILD_NCPUS" environment variable.

Signed-off-by: Wolfgang Denk <wd@denx.de>
MAKEALL

diff --git a/MAKEALL b/MAKEALL
index dbed26805236ceb273f3b55d144e834253b1b2d6..a16549c10db79ac91d269220d6dfbe9fd56021e1 100755 (executable)
--- a/MAKEALL
+++ b/MAKEALL
@@ -1,6 +1,15 @@
 #!/bin/sh
 
-: ${JOBS:=}
+# Determine number of CPU cores if no default was set
+: ${BUILD_NCPUS:="`getconf _NPROCESSORS_ONLN`"}
+
+if [ "$BUILD_NCPUS" -gt 1 ]
+then
+       JOBS=-j`expr "$BUILD_NCPUS" + 1`
+else
+       JOBS=""
+fi
+
 
 if [ "${CROSS_COMPILE}" ] ; then
        MAKE="make CROSS_COMPILE=${CROSS_COMPILE}"