SUMMARY="A Simple Books Organizer"
DESCRIPTION="Application to Organize with ease your pdf book"
COPYRIGHT="2014-2015 Abou Zakaria"
LICENSE="GNU GPL v3"
REVISION="5"
HOMEPAGE="https://sourceforge.net/projects/booksorg/"
SOURCE_URI="https://downloads.sourceforge.net/booksorg/booksorg_${portVersion/./}.tar.gz"
SOURCE_DIR="booksorg_${portVersion/./}"
CHECKSUM_SHA256="dcdcce89090d1539c020412d294e2f6c0ffc84a0f4f400132f57e1c1be29d234"
PATCHES="booksorg-$portVersion.patchset"
ADDITIONAL_FILES="booksorg.rdef.in"

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

USER_SETTINGS_FILES="
	settings/elokab/BooksOrg directory
	"

PROVIDES="
	booksorg$secondaryArchSuffix = $portVersion
	app:BooksOrg = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libpoppler$secondaryArchSuffix
	lib:libpoppler_qt5$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5DBus$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5PrintSupport$secondaryArchSuffix
	lib:libQt5Sql$secondaryArchSuffix
	lib:libQt5Svg$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libGL$secondaryArchSuffix
	devel:libpoppler$secondaryArchSuffix >= 117
	devel:libpoppler_qt5$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5DBus$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5PrintSupport$secondaryArchSuffix
	devel:libQt5Sql$secondaryArchSuffix
	devel:libQt5Svg$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:qmake$secondaryArchSuffix >= 5
	"

BUILD()
{
	qmake
	make $jobArgs
}

INSTALL()
{
	install -d $appsDir
	install -T ./bin/BooksOrg $appsDir/BooksOrg
	local APP_SIGNATURE="application/x-vnd.booksorg"
	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:-0}|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/booksorg.rdef.in > booksorg.rdef
	addResourcesToBinaries booksorg.rdef $appsDir/BooksOrg
	addAppDeskbarSymlink $appsDir/BooksOrg
}
