#!/bin/bash

QT_CFG=''

COMPILE_JOBS=1

if [[ $OSTYPE = darwin* ]]; then
   # We only support modern Mac machines, they are at least using
   # hyperthreaded dual-core CPU.
   COMPILE_JOBS=4
else
   CPU_CORES=`grep -c ^processor /proc/cpuinfo`
   if [[ "$CPU_CORES" -gt 1 ]]; then
       COMPILE_JOBS=$CPU_CORES
       if [[ "$COMPILE_JOBS" -gt 8 ]]; then
           # Safety net.
           COMPILE_JOBS=8
       fi
   fi
fi


until [ -z "$1" ]; do
    case $1 in
        "--qt-config")
            shift
            QT_CFG+=" $1"
            shift;;
        "--jobs")
            shift
            COMPILE_JOBS=$1
            shift;;
        "--help")
            echo "Usage: $0 [--qt-config CONFIG] [--jobs NUM]"
            echo
            echo "  --qt-config CONFIG          Specify extra config options to be used when configuring Qt"
            echo "  --jobs NUM                  How many parallel compile jobs to use. Defaults to 4."
            echo
            exit 0
            ;;
        *)
            echo "Unrecognised option: $1"
            exit 1;;
    esac
done

cd src/qt && ./preconfig.sh --jobs $COMPILE_JOBS && cd ../..
src/qt/bin/qmake
make -j$COMPILE_JOBS

#!/bin/bash

COMPILE_JOBS=4

QT_CFG=''

until [ -z "$1" ]; do
    case $1 in
        "--qt-config")
            shift
            QT_CFG+=" $1"
            shift;;
        "--jobs")
            shift
            COMPILE_JOBS=$1
            shift;;
        "--help")
            echo "Usage: $0 [--qt-config CONFIG] [--jobs NUM]"
            echo
            echo "  --qt-config CONFIG          Specify extra config options to be used when configuring Qt"
            echo "  --jobs NUM                  How many parallel compile jobs to use. Defaults to 4."
            echo
            exit 0
            ;;
        *)
            echo "Unrecognised option: $1"
            exit 1;;
    esac
done

cd src/qt && ./preconfig.sh --jobs $COMPILE_JOBS && cd ../..
src/qt/bin/qmake
make -j$COMPILE_JOBS

--- 
+++ 
@@ -1,24 +1,8 @@
 #!/bin/bash
 
+COMPILE_JOBS=4
+
 QT_CFG=''
-
-COMPILE_JOBS=1
-
-if [[ $OSTYPE = darwin* ]]; then
-   # We only support modern Mac machines, they are at least using
-   # hyperthreaded dual-core CPU.
-   COMPILE_JOBS=4
-else
-   CPU_CORES=`grep -c ^processor /proc/cpuinfo`
-   if [[ "$CPU_CORES" -gt 1 ]]; then
-       COMPILE_JOBS=$CPU_CORES
-       if [[ "$COMPILE_JOBS" -gt 8 ]]; then
-           # Safety net.
-           COMPILE_JOBS=8
-       fi
-   fi
-fi
-
 
 until [ -z "$1" ]; do
     case $1 in
Build system: do not assume 4 parallel jobs on Linux.

Try to grab the number of CPU cores from /proc/cpuinfo and use it as
the number of parallel make jobs (limit to 8 as a safety measure).

http://code.google.com/p/phantomjs/issues/detail?id=454
