SUMMARY="WebKit rendering library for the Qt5 framework"
DESCRIPTION="QtWebKit provides a Web browser engine that makes it easy to embed \
content from the World Wide Web into your Qt application. At the same time Web \
content can be enhanced with native controls.
QtWebKit provides facilities for rendering of HyperText Markup Language (HTML), \
Extensible HyperText Markup Language (XHTML) and Scalable Vector Graphics (SVG) \
documents, styled using Cascading Style Sheets (CSS) and scripted with JavaScript."
HOMEPAGE="https://www.qt.io"
COPYRIGHT="2015-2020 The Qt Company Ltd."
LICENSE="BSD (3-clause)
	GNU LGPL v2.1"
REVISION="2"
srcGitRev="ac8ebc6c3a56064f88f5506e5e3783ab7bee2456"
SOURCE_URI="https://github.com/qt/qtwebkit/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="405b32de1ac1921759190ef68b7dcb7620c545d0055a84ea8e1ba7b86b3d6dc4"
SOURCE_DIR="qtwebkit-$srcGitRev"
PATCHES="qtwebkit-$portVersion.patchset"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	qtwebkit$secondaryArchSuffix = $portVersion compat >= 5
	cmd:QtWebNetworkProcess$secondaryArchSuffix = $portVersion compat >= 5
	cmd:QtWebProcess$secondaryArchSuffix = $portVersion compat >= 5
	cmd:QtWebStorageProcess$secondaryArchSuffix = $portVersion compat >= 5
	lib:libQt5WebKit$secondaryArchSuffix = $portVersion compat >= 5
	lib:libQt5WebKitWidgets$secondaryArchSuffix = $portVersion compat >= 5
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libenchant_2$secondaryArchSuffix
	lib:libfontconfig$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libgcrypt$secondaryArchSuffix
	lib:libgl$secondaryArchSuffix
	lib:libglib_2.0$secondaryArchSuffix
	lib:libglu$secondaryArchSuffix
	lib:libgnutls$secondaryArchSuffix
	lib:libhyphen$secondaryArchSuffix
	lib:libicudata$secondaryArchSuffix
	lib:libicui18n$secondaryArchSuffix
	lib:libicuuc$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Multimedia$secondaryArchSuffix
	lib:libQt5MultimediaWidgets$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5Positioning$secondaryArchSuffix
	lib:libQt5PrintSupport$secondaryArchSuffix
	lib:libQt5Qml$secondaryArchSuffix
	lib:libQt5Quick$secondaryArchSuffix
	lib:libQt5Sensors$secondaryArchSuffix
	lib:libQt5WebChannel$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libsqlite3$secondaryArchSuffix
	lib:libstdc++$secondaryArchSuffix
	lib:libtasn1$secondaryArchSuffix
	lib:libwebp$secondaryArchSuffix
	lib:libxml2$secondaryArchSuffix
	lib:libxslt$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	qtwebkit${secondaryArchSuffix}_devel = $portVersion compat >= 5
	devel:libQt5WebKit$secondaryArchSuffix = $portVersion compat >= 5
	devel:libQt5WebKitWidgets$secondaryArchSuffix = $portVersion compat >= 5
	"
REQUIRES_devel="
	haiku$secondaryArchSuffix
	qtwebkit$secondaryArchSuffix == $portVersion base
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcrypto$secondaryArchSuffix
	devel:libegl$secondaryArchSuffix
	devel:libenchant_2$secondaryArchSuffix
	devel:libfontconfig$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix
	devel:libgcc$secondaryArchSuffix
	devel:libgcrypt$secondaryArchSuffix
	devel:libgl$secondaryArchSuffix
	devel:libglib_2.0$secondaryArchSuffix
	devel:libglu$secondaryArchSuffix
	devel:libgnutls$secondaryArchSuffix >= 30
	devel:libhyphen$secondaryArchSuffix
	devel:libicuuc$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libpcre2_16$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Multimedia$secondaryArchSuffix
	devel:libQt5MultimediaWidgets$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5Positioning$secondaryArchSuffix
	devel:libQt5PrintSupport$secondaryArchSuffix
	devel:libQt5Qml$secondaryArchSuffix
	devel:libQt5Quick$secondaryArchSuffix
	devel:libQt5Sensors$secondaryArchSuffix
	devel:libQt5WebChannel$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libruby$secondaryArchSuffix
	devel:libsqlite3$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libtasn1$secondaryArchSuffix
	devel:libwebp$secondaryArchSuffix >= 7
	devel:libxml2$secondaryArchSuffix
	devel:libxslt$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:bison
	cmd:cmake
	cmd:find
	cmd:flex
	cmd:g++$secondaryArchSuffix
	cmd:gcc$secondaryArchSuffix
	cmd:gperf
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:perl
	cmd:pkg_config$secondaryArchSuffix
	cmd:python
	cmd:ruby
	cmd:sed
	"

BUILD()
{
	mkdir -p build && cd build

	cmake .. $cmakeDirArgs \
		-DCMAKE_INSTALL_PREFIX:PATH=$prefix \
		-DCMAKE_INSTALL_INCLUDEDIR=$includeDir \
		-DCMAKE_INSTALL_LIBDIR=$libDir \
		-DCMAKE_INSTALL_BINDIR:PATH=$binDir \
		-DCMAKE_INSTALL_SBINDIR:PATH=$binDir \
		-DCMAKE_INSTALL_LIBEXECDIR:PATH=$binDir \
		-DCMAKE_INSTALL_DATAROOTDIR:PATH=$dataDir/Qt5 \
		-DCMAKE_BUILD_TYPE=RELEASE \
		-DPORT=Qt \
		-DENABLE_ALLINONE_BUILD=OFF \
		-DENABLE_API_TESTS=OFF \
		-DENABLE_FTPDIR=ON \
		-DENABLE_MEDIA_SOURCE=OFF \
		-DENABLE_SAMPLING_PROFILER=OFF \
		-DENABLE_THREADED_COMPOSITOR=OFF \
		-DENABLE_TOOLS=OFF \
		-DENABLE_SUBTLE_CRYPTO=ON \
		-DENABLE_FULLSCREEN_API=ON \
		-DENABLE_SHADOW_DOM=ON \
		-DENABLE_JIT=ON \
		-DENABLE_DFG_JIT=ON \
		-DENABLE_SPELLCHECK=ON \
		-DENABLE_INDEXED_DATABASE=ON \
		-DENABLE_INPUT_TYPE_DATE=ON \
		-DENABLE_INPUT_TYPE_TIME=ON \
		-DENABLE_INPUT_TYPE_MONTH=ON \
		-DENABLE_INPUT_TYPE_WEEK=ON \
		-DENABLE_INPUT_TYPE_DATETIMELOCAL=ON \
		-DENABLE_INPUT_TYPE_COLOR=ON \
		-DENABLE_CUSTOM_ELEMENTS=ON \
		-DENABLE_WEB_ANIMATIONS=ON \
		-DENABLE_FETCH_API=ON \
		-DENABLE_PDFKIT_PLUGIN=ON \
		-DENABLE_WEBGL=ON \
		-DUSE_GSTREAMER=OFF \
		-DUSE_LIBHYPHEN=ON \
		-DUSE_QT_MULTIMEDIA=ON \
		-DUSE_SYSTEM_MALLOC=ON
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	mkdir -p $dataDir/Qt5
	mv -f $libDir/qml $dataDir/Qt5
	mv -f $prefix/mkspecs $dataDir/Qt5

	fixPkgconfig

	prepareInstalledDevelLibs libQt5WebKit libQt5WebKitWidgets

	cd $libDir
	for i in lib*.so.5.*;do
		ln -fs $i $(echo $i | cut -f1,2 -d.)
	done

	packageEntries devel \
		$developDir \
		$libDir/cmake \
		$dataDir/Qt5/mkspecs
}
