SUMMARY="A lightweight QtWebKit browser"
DESCRIPTION="QupZilla is a free and open-source web browser, \
intended for general users. It allows seamless integration with \
users' desktop environments and has several distinguishing features \
positively received by reviewers:
 - A unified interface for bookmarks, history and RSS reading.
 - A themeable interface.
 - Integrated Adblock.
 - Speed dial."
HOMEPAGE="http://www.qupzilla.com"
COPYRIGHT="2010-2015 David Rosca"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://github.com/QupZilla/qupzilla/releases/download/v$portVersion/QupZilla-$portVersion.tar.xz"
CHECKSUM_SHA256="aecda29f8994c9dc4d6b5f76ce5b1ba947272a0d5a40b5d83a54023dd5d7a6a5"
SOURCE_DIR="QupZilla-$portVersion"
PATCHES="qupzilla-1.8.x-system_certificates.patchset"

ARCHITECTURES="x86 ?x86_64"
if [ $effectiveTargetArchitecture != x86_gcc2 ]; then
	ARCHITECTURES="$ARCHITECTURES x86_gcc2"
else
    ARCHITECTURES="$ARCHITECTURES !x86_gcc2"
fi
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	qupzilla$secondaryArchSuffix = $portVersion
	app:QupZilla$secondaryArchSuffix = $portVersion
	"
# TODO: update requirements to be more specific about which Qt
# libraries are required.
REQUIRES="
	haiku${secondaryArchSuffix}
	libqt4$secondaryArchSuffix >= 4.8.0
	lib:libexecinfo$secondaryArchSuffix
	"

BUILD_PREREQUIRES="
	cmd:qmake$secondaryArchSuffix
	cmd:make
	cmd:g++$secondaryArchSuffix
	cmd:pkg_config$secondaryArchSuffix
	"
BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	libqt4${secondaryArchSuffix}_devel >= 4.8.0
	devel:libssl$secondaryArchSuffix
	devel:libcrypto$secondaryArchSuffix
	devel:libexecinfo$secondaryArchSuffix
	"

BUILD()
{
	export QUPZILLA_PREFIX=$appsDir/QupZilla
	qmake
	make $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir/QupZilla/lib

	cd bin

	# Add Haiku resources
	rc -o ../haiku/QupZilla.rsrc ../haiku/QupZilla.rdef
	xres -o qupzilla ../haiku/QupZilla.rsrc
	mimeset -f qupzilla

	cp qupzilla $appsDir/QupZilla/QupZilla
	cp -R locale $appsDir/QupZilla
	cp -R plugins $appsDir/QupZilla
	cp -R themes $appsDir/QupZilla
	cp libQupZilla.* $appsDir/QupZilla/lib

	addAppDeskbarSymlink $appsDir/QupZilla/QupZilla "QupZilla"
}
