SUMMARY="Open source web browser engine"
DESCRIPTION="
WebKit is an open source web browser engine. WebKit is also the name of the \
Mac OS X system framework version of the engine that's used by Safari, \
Dashboard, Mail, and many other OS X applications. WebKit's HTML and \
JavaScript code began as a branch of the KHTML and KJS libraries from KDE."
HOMEPAGE="http://www.webkit.org/"
COPYRIGHT="1998-2021 Apple Inc., Google Inc., et al"
LICENSE="GNU LGPL v2
	GNU LGPL v2.1
	MIT"
REVISION="1"
SOURCE_URI="https://github.com/haiku/haikuwebkit/archive/HaikuWebKit-$portVersion.tar.gz"
CHECKSUM_SHA256="c4ed2126239c484d7ef7e4532acffd4adddf5a9fbb7938d3859d34bea5e02e97"
SOURCE_FILENAME="haikuwebkit-$portVersion.tar.gz"
SOURCE_DIR="haikuwebkit-HaikuWebKit-$portVersion"

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

PROVIDES="
	haikuwebkit$secondaryArchSuffix = $portVersion
	cmd:jsc
	lib:libJavaScriptCore$secondaryArchSuffix = $portVersion compat >= 1
	lib:libWebKitLegacy$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix >= r1~beta2_hrev55169
	lib:libexecinfo$secondaryArchSuffix
	lib:libgcrypt$secondaryArchSuffix
	lib:libgl$secondaryArchSuffix
	lib:libicuuc$secondaryArchSuffix >= 66
	lib:libgpg_error$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libsqlite3$secondaryArchSuffix
	lib:libtasn1$secondaryArchSuffix
	lib:libwebp$secondaryArchSuffix
	lib:libxml2$secondaryArchSuffix
	lib:libxslt$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	haikuwebkit${secondaryArchSuffix}_devel = $portVersion
	devel:libJavaScriptCore$secondaryArchSuffix = $portVersion
	devel:libwebcore$secondaryArchSuffix = $portVersion
	devel:libWebKitLegacy$secondaryArchSuffix = $portVersion
	devel:libwtf$secondaryArchSuffix = $portVersion
	"
REQUIRES_devel="
	haikuwebkit$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	haiku_devel
	devel:libexecinfo$secondaryArchSuffix
	devel:libgcrypt$secondaryArchSuffix
	devel:libgl$secondaryArchSuffix
	devel:libicuuc$secondaryArchSuffix >= 66
	devel:libjpeg$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libsqlite3$secondaryArchSuffix
	devel:libtasn1$secondaryArchSuffix
	devel:libwebp$secondaryArchSuffix >= 7
	devel:libxml2$secondaryArchSuffix
	devel:libxslt$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:bison
	cmd:cmake >= 3.0.0
	cmd:flex
	cmd:gcc$secondaryArchSuffix
	cmd:gperf
	cmd:ld$secondaryArchSuffix
	cmd:m4
	cmd:make
	cmd:ninja
	cmd:perl
	cmd:pkg_config
	cmd:python3
	cmd:ruby
	cmd:which
	"

BUILD()
{
	export DISABLE_ASLR=1
	export PKG_CONFIG_LIBDIR="`finddir B_SYSTEM_DIRECTORY`/$relativeDevelopLibDir/pkgconfig"
	Tools/Scripts/build-webkit --haiku --no-webkit2 \
		--cmakeargs="-DCMAKE_INSTALL_PREFIX=$prefix -DCMAKE_BUILD_TYPE=Release -DSHOULD_INSTALL_JS_SHELL=ON"
}

INSTALL()
{
	cd WebKitBuild/Release
	ninja install

	prepareInstalledDevelLibs libWebKitLegacy libJavaScriptCore

	# devel package
	packageEntries devel \
		$developDir
}
