From abb7d2e5740e4cdf436a994c00c2b23d1ebcb044 Mon Sep 17 00:00:00 2001
From: Michael Jerris <mike@jerris.com>
Date: Mon, 7 Jun 2010 20:44:27 -0400
Subject: [PATCH] merge -j option for bootstrap (FSBUILD-237)

---
 bootstrap.sh | 44 ++++++++++++++++++++++++++++++++++----------
 1 file changed, 34 insertions(+), 10 deletions(-)

diff --git a/bootstrap.sh b/bootstrap.sh
index f4da83706f..a1c93a87c7 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -1,6 +1,11 @@
 #!/bin/sh
 echo "bootstrap: checking installation..."
 
+BGJOB=false
+if [ "${1}" == "-j" ]  ; then
+	BGJOB=true
+fi
+
 BASEDIR=`pwd`;
 LIBDIR=${BASEDIR}/libs;
 SUBDIRS="ilbc curl iksemel js js/nsprpub libdingaling libedit libsndfile pcre sofia-sip \
@@ -264,16 +269,10 @@ ${AUTOCONF:-autoconf}
 echo "Creating include/arch/unix/apr_private.h.in ..."
 ${AUTOHEADER:-autoheader}
 
-
-# Remove autoconf 2.5x's cache directory
-rm -rf autom4te*.cache
-
-echo "Entering directory ${LIBDIR}/apr-util"
-cd ${LIBDIR}/apr-util
-./buildconf
-
-for i in ${SUBDIRS}
-do
+# Libs automake automation function
+libbootstrap()
+{
+  i=$1
   echo "Entering directory ${LIBDIR}/${i}"
   cd ${LIBDIR}/${i}
   rm -f aclocal.m4
@@ -323,8 +322,33 @@ do
       fi
       rm -rf autom4te*.cache
   fi
+}
+
+
+# Remove autoconf 2.5x's cache directory
+rm -rf autom4te*.cache
+
+echo "Entering directory ${LIBDIR}/apr-util"
+cd ${LIBDIR}/apr-util
+if [ "${BGJOB}" == "false" ] ; then
+	./buildconf
+else
+	./buildconf &
+fi
+
+
+for i in ${SUBDIRS}
+do
+  if [ "${BGJOB}" == "false" ] ; then
+  	libbootstrap ${i}
+  else
+	libbootstrap ${i} &
+  fi
 done
 
+if [ "${BGJOB}" == "true" ] ; then
+	wait
+fi
 cd ${BASEDIR}
 
 rm -f aclocal.m4