SUMMARY="A lightweight QtWebKit browser"
DESCRIPTION="Project aiming to recreate the best aspects of the \
classic Opera (12.x) UI using Qt5."
HOMEPAGE="https://otter-browser.org/"
COPYRIGHT="2013-2020 Otter Browser Team"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://github.com/OtterBrowser/otter-browser/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="d1e090a80fa736cd128f594184817078a08cac31614e85e7838ff1b64511d62d"
SOURCE_FILENAME="otter-browser-$portVersion.tar.gz"
SOURCE_DIR="otter-browser-$portVersion"
PATCHES="otter_browser-$portVersion.patchset"
ADDITIONAL_FILES="
	otter.rdef.in
	haikuicons.zip
	"

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

PROVIDES="
	otter_browser$secondaryArchSuffix = $portVersion
	app:OtterBrowser$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
	lib:libhunspell_1.7$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5DBus$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Multimedia$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5PrintSupport$secondaryArchSuffix
	lib:libQt5Qml$secondaryArchSuffix
	lib:libQt5WebKit$secondaryArchSuffix
	lib:libQt5WebKitWidgets$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libQt5XmlPatterns$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcrypto$secondaryArchSuffix
	devel:libhunspell_1.7$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5DBus$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Multimedia$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5PrintSupport$secondaryArchSuffix
	devel:libQt5Qml$secondaryArchSuffix
	devel:libQt5WebKit$secondaryArchSuffix
	devel:libQt5WebKitWidgets$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libQt5XmlPatterns$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:g++$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:qdbuscpp2xml$secondaryArchSuffix >= 5
	cmd:sed
	cmd:unzip
	"

defineDebugInfoPackage otter_browser$secondaryArchSuffix \
	"$appsDir"/Otter-Browser/Otter-Browser

PATCH()
{
	unzip -o $sourceDir/../../additional-files/haikuicons.zip -d $sourceDir/resources/icons
}

BUILD()
{
	mkdir -p build
	cd build

	cmake .. -DCMAKE_INSTALL_PREFIX:PATH="$appsDir/Otter-Browser"
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	mv $appsDir/Otter-Browser/bin/otter-browser \
		$appsDir/Otter-Browser/Otter-Browser

	mkdir -p $manDir
	mv $appsDir/Otter-Browser/share/man/man1 $manDir
	mv $appsDir/Otter-Browser/share/otter-browser/locale \
		$appsDir/Otter-Browser

	rm -rf $appsDir/Otter-Browser/bin
	rm -rf $appsDir/Otter-Browser/share

	local APP_SIGNATURE="application/x-vnd.otter-browser"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		$portDir/additional-files/otter.rdef.in > otter.rdef

	addResourcesToBinaries otter.rdef \
		$appsDir/Otter-Browser/Otter-Browser

	addAppDeskbarSymlink $appsDir/Otter-Browser/Otter-Browser "Otter Browser"
}
