# Building_Qt5_From_Source_with_QtWebkit_Added_Back_on_MacOSX

# In order to use offical Qt 5.6 or later versions of Qt you will need to add QtWebkit back
# and build from source.  This is what Linux distributions are doing too.

# FIRST:  make sure you have XCode 6 or XCode 7 installed and the Command Line Tools

# As of Qt 5.6, QtWebkit was removed from the stock Qt releases.  Sigil depends on this 
# module for both its BookView and Preview windows.  We are following the examples of
# the Linux Distributions and Adding back QtWebKit to the Qt sources to build our own
# Qt distribution.

# Here are the steps to building Qt from source with QtWebkit added back

# We highly recommend you use the same Qt versions as official Sigil builds on Mac OS X.
# which is Qt 5.6.2

# cd to a location to store your src tree then do

export MYQTSRC=`pwd`

# clone qtwebkit from git::/code.qt.io/qt/qtwebkit.git
git clone git://code.qt.io/qt.qtwebkit.git

# download qt-everywhere-opensource-src-5.6.2.tar.gz directly from Qt
# From:  http://download.qt.io/archive/qt/5.6/5.6.2/single/

# and then unpack it
tar -zxvf qt-everywhere-opensource-src-5.6.2.tar.gz

# copy the qtwebkit directory into qt-everywhere-opensource-src-5.6.1 to sit beside qtbase, etc
cd qt-everywhere-opensource-src-5.6.2
mkdir qtwebkit
cp -R ../qtwebkit/ ./qtwebkit

# set the correct module version inside of the newly added qtwebkit directory
# edit qtwebkit/.qmake.conf and change this line 

# MODULE_VERSION = 5.7

# to

# MODULE_VERSION = 5.6.2

# Create a destination directory to house your complete Qt binary in your home directory
# to match how stock Qt does it
cd ~/
mkdir Qt56

# Now return and create a shadow build inside a new directory to keep your Qt sources clean
cd ${MYQTSRC}
mkdir buildqt
cd buildqt
../qt-everywhere-opensource-src-5.6.2/configure --prefix=/Users/${USER}/Qt56 -opensource -nomake examples -nomake tests
# note the build itself can take a couple of hours depending on memory available, disk and cpus used
make -j4
make install

# After the install phase completes your newly built Qt should exist in ~/Qt56 ready to be
# Used to build Sigil with and for use with the PyQt5 Module iwth Python
