SUMMARY="The electronic Holy Quran browser"
DESCRIPTION="Electronic Holy Quran browser and reciter."
COPYRIGHT="1999-2019 Abou Zakaria"
HOMEPAGE="https://github.com/zakariakov/elforkane"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://github.com/zakariakov/elforkane/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="25f5352472e99e6dd018f6003408a793ee85f140a381d58b7de463e9b0bc2003"
SOURCE_FILENAME="elforkane-$portVersion.tar.gz"
SOURCE_DIR="elforkane-$portVersion"
ADDITIONAL_FILES="elforkane.rdef.in"
PATCHES="elforkane-$portVersion.patchset"

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

PROVIDES="
	elforkane$secondaryArchSuffix = $portVersion
	app:Elforkane = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	ayat_tarajem_data
	ayat_tafasir_data
	lib:libGL$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Multimedia$secondaryArchSuffix
	lib:libQt5MultimediaWidgets$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5PrintSupport$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"
BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Multimedia$secondaryArchSuffix
	devel:libQt5MultimediaWidgets$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5PrintSupport$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:qmake$secondaryArchSuffix >= 5
	"

BUILD()
{
	qmake
	make $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir/Elforkane/lib
	cp -rf usr/bin/elforkane $appsDir/Elforkane/Elforkane
	rm -rf usr/share/elforkane/translat
	rm -rf usr/share/elforkane/tafasir
	cp -rf usr/share/elforkane/* $appsDir/Elforkane/lib
	mkdir -p $appsDir/Elforkane/lib/images/default
	cp -rf data/* $appsDir/Elforkane/lib/images/default/
	ln -s $dataDir/ayat/translat $appsDir/Elforkane/lib/translat
	ln -s $dataDir/ayat/tafasir $appsDir/Elforkane/lib/tafasir
	ln -s $dataDir/ayat/audio $appsDir/Elforkane/lib/audio
	local APP_SIGNATURE="application/x-vnd.elforkane"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local LONG_INFO="$SUMMARY"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		"$portDir"/additional-files/elforkane.rdef.in > elforkane.rdef

	addResourcesToBinaries elforkane.rdef $appsDir/Elforkane/Elforkane
	addAppDeskbarSymlink $appsDir/Elforkane/Elforkane
}
