SUMMARY="E-Book Reader. Supports many e-book formats"
DESCRIPTION="FBReader is an e-book reader for Linux, Microsoft Windows, Android, and other platforms.
It was originally written for the Sharp Zaurus and currently runs on many other mobile devices, like \
the Nokia Internet Tablets, as well as desktop computers.
Supported formats include EPUB, FictionBook, HTML, plucker, PalmDoc, zTxt, TCR, CHM, RTF, OEB, mobi \
without DRM, and plain-text."
HOMEPAGE="http://www.fbreader.org"
COPYRIGHT="Geometer Plus, LLC; FBReader.ORG Limited"
LICENSE="GNU GPL v2"
REVISION="5"
SOURCE_URI="http://www.fbreader.org/files/desktop/fbreader-sources-$portVersion.tgz"
CHECKSUM_SHA256="3d7c31d5ea314589d2a963290ad16f4d3d631a41e802b8b39f8be0c9f71eb8e9"
PATCHES="fbreader-$portVersion.patchset"
ADDITIONAL_FILES="
	fbreader.rdef.in
	haikuicons.zip
	"

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

PROVIDES="
	fbreader$secondaryArchSuffix = $portVersion
	app:fbreader$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libbz2$secondaryArchSuffix
	lib:libcurl$secondaryArchSuffix
	lib:libexpat$secondaryArchSuffix
	lib:libfribidi$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5PrintSupport$secondaryArchSuffix
	lib:libQt5Svg$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libsqlite3$secondaryArchSuffix
	lib:libunibreak$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libbz2$secondaryArchSuffix
	devel:libcurl$secondaryArchSuffix
	devel:libexpat$secondaryArchSuffix
	devel:libfribidi$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libpng$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5PrintSupport$secondaryArchSuffix
	devel:libQt5Svg$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libsqlite3$secondaryArchSuffix
	devel:libunibreak$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:find
	cmd:g++$secondaryArchSuffix
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:qmake$secondaryArchSuffix >= 5
	cmd:unzip
	"

BUILD()
{
	make INSTALLDIR=$appsDir/FBReader
}

INSTALL()
{
	make INSTALLDIR=$appsDir/FBReader install

	mv -f $appsDir/FBReader/bin/FBReader $appsDir/FBReader/FBReader
	rm -rf $appsDir/FBReader/bin
	unzip -o $sourceDir/../../additional-files/haikuicons.zip -d $appsDir/FBReader/pixmaps/FBReader

	local APP_SIGNATURE="application/x-vnd.fbreader"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"
	local LONG_INFO="$SUMMARY"

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

	addResourcesToBinaries fbreader.rdef $appsDir/FBReader/FBReader
	addAppDeskbarSymlink $appsDir/FBReader/FBReader
}
