SUMMARY="Dictionary lookup program"
DESCRIPTION="GoldenDict is a feature-rich dictionary lookup program, \
supporting multiple dictionary formats \
(StarDict/Babylon/Lingvo/Dictd/AARD/MDict/SDict) and online dictionaries, \
featuring perfect article rendering with the complete markup, illustrations \
and other content retained, and allowing you to type in words without any \
accents or correct case."
HOMEPAGE="http://goldendict.org/"
COPYRIGHT="2008-2016 Konstantiv Isakov"
LICENSE="GNU GPL v3"
REVISION="6"
SOURCE_URI="https://github.com/goldendict/goldendict/archive/1.5.0-RC2.tar.gz"
CHECKSUM_SHA256="bccee0a3d3902f8fa31e439e220a405065fff774e5f8c581be2b0743d3f83fde"
SOURCE_DIR="goldendict-1.5.0-RC2"
PATCHES="goldendict-1.5.0rc2.patchset"
ADDITIONAL_FILES="goldendict.rdef.in"

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

PROVIDES="
	goldendict$secondaryArchSuffix = $portVersion
	app:GoldenDict$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libao$secondaryArchSuffix
	lib:libavcodec$secondaryArchSuffix
	lib:libavformat$secondaryArchSuffix
	lib:libavutil$secondaryArchSuffix
	lib:libbz2$secondaryArchSuffix
	lib:libexecinfo$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libhunspell_1.7$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:liblzo2$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Help$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5PrintSupport$secondaryArchSuffix
	lib:libQt5Sql$secondaryArchSuffix
	lib:libQt5Svg$secondaryArchSuffix
	lib:libQt5WebKit$secondaryArchSuffix
	lib:libQt5WebKitWidgets$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libQt5Xml$secondaryArchSuffix
	lib:libtiff$secondaryArchSuffix
	lib:libvorbisfile$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libao$secondaryArchSuffix
	devel:libavcodec$secondaryArchSuffix
	devel:libavformat$secondaryArchSuffix
	devel:libavutil$secondaryArchSuffix
	devel:libbz2$secondaryArchSuffix
	devel:libexecinfo$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libhunspell_1.7$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:liblzo2$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Help$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5PrintSupport$secondaryArchSuffix
	devel:libQt5Sql$secondaryArchSuffix
	devel:libQt5Svg$secondaryArchSuffix
	devel:libQt5WebKit$secondaryArchSuffix
	devel:libQt5WebKitWidgets$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libQt5Xml$secondaryArchSuffix
	devel:libtiff$secondaryArchSuffix
	devel:libvorbisfile$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:qmake$secondaryArchSuffix >= 5
	"

BUILD()
{
	qmake "CONFIG+=no_epwing_support"
	make $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir/GoldenDict/{locale,help}
	cp locale/*.qm $appsDir/GoldenDict/locale
	cp help/*.qch $appsDir/GoldenDict/help
	cp goldendict $appsDir/GoldenDict/GoldenDict

	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3 | cut -d~ -f1`"
	local MINOR="0" # workaround rc2 in portVersion

	sed \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		$portDir/additional-files/goldendict.rdef.in > goldendict.rdef

	addResourcesToBinaries goldendict.rdef $appsDir/GoldenDict/GoldenDict
	addAppDeskbarSymlink $appsDir/GoldenDict/GoldenDict
}
