2013-01-05 15:15:15 +04:00
|
|
|
#!/usr/bin/env bash
|
2012-03-07 07:01:24 +04:00
|
|
|
|
2012-06-07 12:38:48 +04:00
|
|
|
set -e
|
|
|
|
|
2012-03-07 07:01:24 +04:00
|
|
|
QT_CFG=''
|
|
|
|
|
2012-11-10 12:09:25 +04:00
|
|
|
BUILD_CONFIRM=0
|
2012-04-16 05:21:02 +04:00
|
|
|
COMPILE_JOBS=1
|
2012-06-17 01:21:28 +04:00
|
|
|
MAKEFLAGS_JOBS=''
|
|
|
|
|
|
|
|
if [[ "$MAKEFLAGS" != "" ]]; then
|
|
|
|
MAKEFLAGS_JOBS=$(echo $MAKEFLAGS | egrep -o '\-j[0-9]+' | egrep -o '[0-9]+')
|
|
|
|
fi
|
2012-04-16 05:21:02 +04:00
|
|
|
|
2012-04-18 16:16:27 +04:00
|
|
|
if [[ "$MAKEFLAGS_JOBS" != "" ]]; then
|
|
|
|
# user defined number of jobs in MAKEFLAGS, re-use that number
|
|
|
|
COMPILE_JOBS=$MAKEFLAGS_JOBS
|
|
|
|
elif [[ $OSTYPE = darwin* ]]; then
|
2012-04-16 05:21:02 +04:00
|
|
|
# We only support modern Mac machines, they are at least using
|
|
|
|
# hyperthreaded dual-core CPU.
|
|
|
|
COMPILE_JOBS=4
|
2013-11-25 12:43:43 +04:00
|
|
|
elif [[ $OSTYPE == freebsd* ]] || [[ $OSTYPE == openbsd* ]]; then
|
2013-01-05 15:37:20 +04:00
|
|
|
COMPILE_JOBS=`sysctl -n hw.ncpu`
|
2012-04-16 05:21:02 +04:00
|
|
|
else
|
|
|
|
CPU_CORES=`grep -c ^processor /proc/cpuinfo`
|
|
|
|
if [[ "$CPU_CORES" -gt 1 ]]; then
|
|
|
|
COMPILE_JOBS=$CPU_CORES
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2013-01-05 15:37:20 +04:00
|
|
|
if [[ "$COMPILE_JOBS" -gt 8 ]]; then
|
|
|
|
# Safety net.
|
|
|
|
COMPILE_JOBS=8
|
|
|
|
fi
|
|
|
|
|
2014-01-07 06:45:59 +04:00
|
|
|
SILENT=''
|
|
|
|
|
2012-03-07 07:01:24 +04:00
|
|
|
until [ -z "$1" ]; do
|
|
|
|
case $1 in
|
|
|
|
"--qt-config")
|
|
|
|
shift
|
2012-04-20 15:38:11 +04:00
|
|
|
QT_CFG=" $1"
|
2012-03-07 07:01:24 +04:00
|
|
|
shift;;
|
2012-06-18 23:15:15 +04:00
|
|
|
"--qmake-args")
|
|
|
|
shift
|
|
|
|
QMAKE_ARGS=$1
|
|
|
|
shift;;
|
2012-03-07 07:01:24 +04:00
|
|
|
"--jobs")
|
|
|
|
shift
|
|
|
|
COMPILE_JOBS=$1
|
|
|
|
shift;;
|
2012-11-10 12:09:25 +04:00
|
|
|
"--confirm")
|
|
|
|
BUILD_CONFIRM=1
|
|
|
|
shift;;
|
2014-01-07 06:45:59 +04:00
|
|
|
"--silent")
|
|
|
|
SILENT='--silent'
|
|
|
|
QT_CFG+=" -silent"
|
|
|
|
shift;;
|
2012-03-07 07:01:24 +04:00
|
|
|
"--help")
|
|
|
|
echo "Usage: $0 [--qt-config CONFIG] [--jobs NUM]"
|
|
|
|
echo
|
2012-11-10 12:09:25 +04:00
|
|
|
echo " --confirm Silently confirm the build."
|
2012-03-07 07:01:24 +04:00
|
|
|
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."
|
2014-01-07 06:45:59 +04:00
|
|
|
echo " --silent Produce less verbose output."
|
2012-03-07 07:01:24 +04:00
|
|
|
echo
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unrecognised option: $1"
|
|
|
|
exit 1;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2012-11-10 12:09:25 +04:00
|
|
|
|
|
|
|
if [[ "$BUILD_CONFIRM" -eq 0 ]]; then
|
|
|
|
cat << EOF
|
|
|
|
----------------------------------------
|
|
|
|
WARNING
|
|
|
|
----------------------------------------
|
|
|
|
|
|
|
|
Building PhantomJS from source takes a very long time, anywhere from 30 minutes
|
|
|
|
to several hours (depending on the machine configuration). It is recommended to
|
|
|
|
use the premade binary packages on supported operating systems.
|
|
|
|
|
|
|
|
For details, please go the the web site: http://phantomjs.org/download.html.
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
echo "Do you want to continue (y/n)?"
|
|
|
|
read continue
|
|
|
|
if [[ "$continue" != "y" ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
2014-01-07 06:45:59 +04:00
|
|
|
echo
|
|
|
|
echo "Building PhantomJS. Please wait..."
|
|
|
|
echo
|
|
|
|
|
|
|
|
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
|
|
|
|
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
|
|
|
|
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
|
|
|
|
|
|
|
|
echo "System architecture... ($UNAME_SYSTEM $UNAME_RELEASE $UNAME_MACHINE)"
|
|
|
|
echo
|
|
|
|
|
|
|
|
cd src/qt && ./preconfig.sh --jobs $COMPILE_JOBS --qt-config "$QT_CFG" $SILENT && cd ../..
|
|
|
|
|
|
|
|
echo "Building main PhantomJS application. Please wait..."
|
|
|
|
echo
|
2012-06-18 23:15:15 +04:00
|
|
|
src/qt/bin/qmake $QMAKE_ARGS
|
2012-03-07 07:01:24 +04:00
|
|
|
make -j$COMPILE_JOBS
|