SUMMARY="LaTeX made comfortable"
DESCRIPTION="TeXstudio is an integrated writing environment for creating \
LaTeX documents. Our goal is to make writing LaTeX as easy and comfortable as \
possible. Therefore TeXstudio has numerous features like syntax-highlighting, \
integrated viewer, reference checking and various assistants. "
HOMEPAGE="https://www.texstudio.org/"
COPYRIGHT="2009-2022 Benito van der Zander"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://github.com/texstudio-org/texstudio/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="cac3842c06189745963ef9197373c9c2cbd6cd03cfa4148f0d55d252ad84b7f3"
SOURCE_FILENAME="texstudio-$portVersion.tar.gz"
PATCHES="texstudio-$portVersion.patchset"
ADDITIONAL_FILES="texstudio.rdef.in"

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

PROVIDES="
	texstudio$secondaryArchSuffix = $portVersion
	app:TeXstudio = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libhunspell_1.7$secondaryArchSuffix
	lib:libpoppler_cpp$secondaryArchSuffix
	lib:libpoppler_qt5$secondaryArchSuffix
	lib:libQt5Concurrent$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5DBus$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5PrintSupport$secondaryArchSuffix
	lib:libQt5Sql$secondaryArchSuffix
	lib:libQt5Svg$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libQt5Xml$secondaryArchSuffix
	lib:libquazip1_qt5$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libGL$secondaryArchSuffix
	devel:libhunspell_1.7$secondaryArchSuffix
	devel:libpoppler_qt5$secondaryArchSuffix
	devel:libQt5Concurrent$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5DBus$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5PrintSupport$secondaryArchSuffix
	devel:libQt5Sql$secondaryArchSuffix
	devel:libQt5Svg$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libQt5Xml$secondaryArchSuffix
	devel:libquazip1_qt5$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:g++$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:qmake$secondaryArchSuffix >= 5
	"

BUILD()
{
	qmake texstudio.pro \
		PREFIX=$appsDir \
		DATADIR=$dataDir \
		USE_SYSTEM_HUNSPELL=1 \
		USE_SYSTEM_QUAZIP=1 \
		QUAZIP_LIB=-lquazip1-qt5
	make $jobArgs
}

INSTALL()
{
	make install

	mv $appsDir/bin/texstudio $appsDir/TeXstudio
	rm -rf $dataDir/{appdata,applications,icons} $appsDir/bin

	local APP_SIGNATURE="application/x-vnd.qt5-texstudio"
	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/texstudio.rdef.in > $sourceDir/texstudio.rdef

	addResourcesToBinaries $sourceDir/texstudio.rdef $appsDir/TeXstudio
	addAppDeskbarSymlink $appsDir/TeXstudio
}
