changeset 182:fc827ab6166f

Autodetect number of processors and feed appropriate -j to make.
author Rob Landley <rob@landley.net>
date Tue, 26 Jun 2007 17:51:14 -0400
parents 3398664933af
children d2a27709d3b6
files cross-compiler.sh host-tools.sh include.sh mini-native.sh
diffstat 4 files changed, 18 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/cross-compiler.sh	Tue Jun 26 09:44:23 2007 -0400
+++ b/cross-compiler.sh	Tue Jun 26 17:51:14 2007 -0400
@@ -21,7 +21,7 @@
 	--disable-shared --disable-multilib --program-prefix="${ARCH}-" \
 	$BINUTILS_FLAGS &&
 make configure-host &&
-make &&
+make -j $CPUS &&
 make install &&
 cd .. &&
 mkdir -p "${CROSS}/include" &&
@@ -37,7 +37,7 @@
 	--prefix="${CROSS}" --host=${CROSS_HOST} --target=${CROSS_TARGET} \
 	--enable-languages=c --disable-threads --disable-multilib \
 	--disable-nls --disable-shared --program-prefix="${ARCH}-" &&
-make all-gcc &&
+make -j CPUS all-gcc &&
 make install-gcc &&
 cd .. &&
 
@@ -72,7 +72,7 @@
 
 setupfor linux
 # Install Linux kernel headers (for use by uClibc).
-make headers_install ARCH="${KARCH}" INSTALL_HDR_PATH="${CROSS}" &&
+make -j $CPUS headers_install ARCH="${KARCH}" INSTALL_HDR_PATH="${CROSS}" &&
 cd .. &&
 $CLEANUP linux-*
 
@@ -83,7 +83,8 @@
 setupfor uClibc
 make CROSS= allnoconfig KCONFIG_ALLCONFIG="${WORK}"/miniconfig-uClibc &&
 make CROSS="${ARCH}-" KERNEL_HEADERS="${CROSS}/include" PREFIX="${CROSS}/" \
-	RUNTIME_PREFIX=/ DEVEL_PREFIX=/ all install_runtime install_dev &&
+	RUNTIME_PREFIX=/ DEVEL_PREFIX=/ -j $CPUS all install_runtime \
+	install_dev &&
 # "make utils" in uClibc is broken for cross compiling.  Either it creates a
 # target binary (which you can't run on the host), or it tries to link the
 # host binary against the target library, and use the target compiler flags
--- a/host-tools.sh	Tue Jun 26 09:44:23 2007 -0400
+++ b/host-tools.sh	Tue Jun 26 17:51:14 2007 -0400
@@ -43,7 +43,7 @@
 CONFIG_PROC_FS=y
 EOF
   make ARCH=um allnoconfig KCONFIG_ALLCONFIG=mini.conf &&
-  make ARCH=um &&
+  make -j $CPUS ARCH=um &&
   cp linux "${HOSTTOOLS}" &&
   cd .. &&
   rm -rf linux-*
--- a/include.sh	Tue Jun 26 09:44:23 2007 -0400
+++ b/include.sh	Tue Jun 26 17:51:14 2007 -0400
@@ -219,3 +219,8 @@
 
 [ -z "$CLEANUP" ] && CLEANUP="rm -rf"
 [ -z "$CC" ] && CC=gcc
+if [ -z "$CPUS" ]
+then
+  export CPUS=$[$(echo /sys/devices/system/cpu/cpu[0-9]* | wc -w)+0]
+  [ "$CPUS" -lt 1 ] && CPUS=1
+fi
--- a/mini-native.sh	Tue Jun 26 09:44:23 2007 -0400
+++ b/mini-native.sh	Tue Jun 26 17:51:14 2007 -0400
@@ -23,7 +23,7 @@
 make headers_install ARCH="${KARCH}" INSTALL_HDR_PATH="${TOOLS}" &&
 # build bootable kernel for target
 make ARCH="${KARCH}" allnoconfig KCONFIG_ALLCONFIG="${WORK}/miniconfig-linux" &&
-make ARCH="${KARCH}" CROSS_COMPILE="${ARCH}-" &&
+make -j $CPUS ARCH="${KARCH}" CROSS_COMPILE="${ARCH}-" &&
 cp "${KERNEL_PATH}" "${BUILD}/zImage-${ARCH}" &&
 cd .. &&
 $CLEANUP linux-*
@@ -37,7 +37,7 @@
 make allnoconfig KCONFIG_ALLCONFIG="${WORK}/miniconfig-uClibc" &&
 make CROSS="${ARCH}-" KERNEL_HEADERS="${TOOLS}/include" PREFIX="${TOOLS}/" \
         RUNTIME_PREFIX=/ DEVEL_PREFIX=/ UCLIBC_LDSO_NAME=ld-uClibc \
-        all install_runtime install_dev utils &&
+        -j $CPUS all install_runtime install_dev utils &&
 # utils_install wants to put stuff in usr/bin instead of bin.
 install -m 755 utils/{readelf,ldd,ldconfig} "${TOOLS}/bin" &&
 cd .. &&
@@ -49,7 +49,7 @@
 
 setupfor busybox
 make defconfig &&
-make CROSS="${ARCH}-" &&
+make -j $CPUS CROSS="${ARCH}-" &&
 cp busybox "${TOOLS}/bin"
 [ $? -ne 0 ] && dienow
 for i in $(sed 's@.*/@@' busybox.links)
@@ -72,7 +72,7 @@
   --disable-nls --disable-shared --disable-multilib --program-prefix= \
   $BINUTILS_FLAGS &&
 make configure-host &&
-make &&
+make -j $CPUS &&
 make install &&
 cd .. &&
 mkdir -p "${TOOLS}/include" &&
@@ -100,7 +100,7 @@
   --enable-long-long --enable-c99 --enable-shared --enable-threads=posix \
   --enable-__cxa_atexit --disable-nls --enable-languages=c,c++ \
   --disable-libstdcxx-pch --program-prefix="" &&
-make all-gcc &&
+make -j $CPUS all-gcc &&
 make install-gcc &&
 ln -s gcc "${TOOLS}/bin/cc" &&
 cd .. &&
@@ -127,7 +127,7 @@
 setupfor make
 CC="${ARCH}-gcc" ./configure --prefix="${TOOLS}" --build="${CROSS_HOST}" \
   --host="${CROSS_TARGET}" &&
-make &&
+make -j $CPUS &&
 make install &&
 cd .. &&
 $CLEANUP make-*
@@ -148,7 +148,7 @@
 CC="${ARCH}-gcc" RANLIB="${ARCH}-ranlib" ./configure --prefix="${TOOLS}" \
   --build="${CROSS_HOST}" --host="${CROSS_TARGET}" --cache-file=config.cache \
   --without-bash-malloc --disable-readline &&
-make &&
+make -j $CPUS &&
 make install &&
 # Make bash the default shell.
 ln -s bash "${TOOLS}/bin/sh" &&