SUMMARY="A comic reader"
DESCRIPTION="YACReader is a Qt based comic reader for cross-platform reading \
and managing your digital comic collection.

Main features:

* File support: rar, zip, cbr, cbz, tar, pdf, 7z and cb7, jpeg, gif, \
png, tiff and bmp
* Configure your reading: Image rotation, double page mode, full size view, \
fullscreen mode, customizable background color, custom page fitting mode, \
bookmarks, resume reading, eye candy 'go to' and more.
* Image improvements: brightness, contrast and gamma sliders.
* Track your readings: YACReaderLibrary organizes your comics and keeps track \
of your reading progress and your collections' status.
* Tags (Comic Vine): Download your comics' information from Comic Vine. Title, \
number, volumen, authors and more.
* Search: Find your comics quickly using the built-in search engine."
HOMEPAGE="https://www.yacreader.com/"
COPYRIGHT="2018 Luis Ángel San Martín Rodríguez"
LICENSE="GNU GPL v3"
REVISION="2"
SOURCE_URI="https://github.com/YACReader/yacreader/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="44268a0c07a5ba3c25202064c088b1deba7cb048f6cbfcf33b3538f18225ae62"
SOURCE_FILENAME="yacreader-$portVersion.tar.gz"
PATCHES="yacreader-$portVersion.patchset"
ADDITIONAL_FILES="
	yacreader.rdef.in
	yacreader_library.rdef.in
	"

ARCHITECTURES="all !x86_gcc2"
if [ "$targetArchitecture" = x86_gcc2 ]; then
SECONDARY_ARCHITECTURES="x86"
fi

PROVIDES="
	yacreader$secondaryArchSuffix = $portVersion
	app:YACReader = $portVersion
	app:YACReaderLibrary = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libgl$secondaryArchSuffix
	lib:libglu$secondaryArchSuffix
	lib:libpoppler$secondaryArchSuffix
	lib:libpoppler_qt5$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Multimedia$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5OpenGL$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libunarr$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libgl$secondaryArchSuffix
	devel:libglu$secondaryArchSuffix
	devel:libpoppler$secondaryArchSuffix >= 117
	devel:libpoppler_qt5$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Multimedia$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5OpenGL$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libQt5Xml$secondaryArchSuffix
	devel:libunarr$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:g++$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:qmake$secondaryArchSuffix >= 5
	"

defineDebugInfoPackage yacreader$secondaryArchSuffix \
	"$appsDir"/YACReader/YACReader \
	"$appsDir"/YACReader/YACReaderLibrary

BUILD()
{
	qmake \
		PREFIX="$appsDir/YACReader" \
		MANDIR="$manDir" \
		DOCDIR="$docDir" \
		BINDIR="$appsDir"/YACReader \
		LIBDIR="$appsDir"/YACReader/lib \
		DATADIR="$appsDir"/YACReader/data \
		.
	make $jobArgs
}

INSTALL()
{
	mkdir -p "$appsDir"/YACReader
	make install

	# Cleanup
	mv "$appsDir"/YACReader/bin/* "$appsDir"/YACReader
	rm -rf "$appsDir"/YACReader/{bin,lib}

	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"

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

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

	addResourcesToBinaries yacreader.rdef \
		"$appsDir"/YACReader/YACReader
	addResourcesToBinaries yacreader_library.rdef \
		"$appsDir"/YACReader/YACReaderLibrary

	addAppDeskbarSymlink "$appsDir"/YACReader/YACReader
	addAppDeskbarSymlink "$appsDir"/YACReader/YACReaderLibrary
}

TEST()
{
	make check
}
