SUMMARY="A nice LaTeX-IDE"
DESCRIPTION="Texmaker is a free, modern and cross-platform LaTeX editor for \
linux, macosx, haiku and windows systems that integrates many tools needed to \
develop documents with LaTeX, in just one application.
Texmaker includes unicode support, spell checking, auto-completion, code \
folding and a built-in pdf viewer with synctex support and continuous view \
mode.
Texmaker is easy to use and to configure."
HOMEPAGE="https://xm1math.net/texmaker/"
COPYRIGHT="2003-2019 Pascal Brachet"
LICENSE="GNU GPL v2"
REVISION="4"
SOURCE_URI="https://xm1math.net/texmaker/texmaker-$portVersion.tar.bz2"
CHECKSUM_SHA256="1de3ab3f6d6bee37a7d0b528ca1cbb7ce8e7aef5ec6a4405aff2caf9d12bd0e2"
PATCHES="texmaker-$portVersion.patchset"
ADDITIONAL_FILES="texmaker.rdef.in"

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

PROVIDES="
	texmaker$secondaryArchSuffix = $portVersion
	cmd:texmaker = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libQt5Concurrent$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5PrintSupport$secondaryArchSuffix
	lib:libQt5Script$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libQt5Xml$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libGL$secondaryArchSuffix
	devel:libQt5Concurrent$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5PrintSupport$secondaryArchSuffix
	devel:libQt5Script$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libQt5Xml$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:qmake$secondaryArchSuffix >= 5
	"

BUILD()
{
	qmake texmaker.pro \
		PREFIX=$prefix \
		UTILITIESDIR=$dataDir/texmaker \
		DESKTOPDIR=$dataDir/applications \
		ICONDIR=$dataDir/pixmaps \
		METAINFODIR=$dataDir/metainfo \
		AUTHORIZELINUXQSTYLES=yes
	make $jobArgs
}

INSTALL()
{
	make install

	mkdir -p $appsDir
	ln -s $prefix/bin/texmaker $appsDir/Texmaker
	rm -rf $dataDir/{applications,pixmaps,metainfo}

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

	addResourcesToBinaries $sourceDir/texmaker.rdef $appsDir/Texmaker
	addAppDeskbarSymlink $appsDir/Texmaker
}
