SUMMARY="A document processor based on structure rather than appearance"
DESCRIPTION="LyX combines the power and flexibility of TeX/LaTeX with the ease \
of use of a graphical interface. This results in world-class support for creation \
of mathematical content (via a fully integrated equation editor) and structured \
documents like academic articles, theses, and books. In addition, staples of \
scientific authoring such as reference list and index creation come standard. But \
you can also use LyX to create a letter or a novel or a theatre play or film \
script. A broad array of ready, well-designed document layouts are built in.

LyX is for people who want their writing to look great, right out of the box. \
No more endless tinkering with formatting details, \"finger painting\" font \
attributes or futzing around with page boundaries. You just write. On screen, \
LyX looks like any word processor; its printed output - or richly \
cross-referenced PDF, just as readily produced - looks like nothing else."
HOMEPAGE="http://www.lyx.org"
COPYRIGHT="the lyx community"
LICENSE="GNU GPL v2"
REVISION="2"
SOURCE_URI="ftp://ftp.lyx.org/pub/lyx/stable/2.3.x/lyx-$portVersion.tar.gz"
CHECKSUM_SHA256="6cd22594f2dc1e7c4860a97e3340513ab7a82899cd5e824bbaa2a147aa122932"
ADDITIONAL_FILES="lyx.rdef.in"

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

PROVIDES="
	lyx$secondaryArchSuffix = $portVersion
	app:LyX
	cmd:lyxclient$secondaryArchSuffix
	cmd:tex2lyx$secondaryArchSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libQt5Concurrent$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Svg$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libboost_system$secondaryArchSuffix >= 1.69.0
	devel:libiconv$secondaryArchSuffix
	devel:libQt5Concurrent$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Svg$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:bc
	cmd:autoconf
	cmd:automake
	cmd:find
	cmd:gcc$secondaryArchSuffix
	cmd:gettext$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:python3
	cmd:sed
	"

BUILD()
{
	./autogen.sh
	runConfigure ./configure --without-included-boost --enable-qt5
	make $jobArgs
}

INSTALL()
{
	make install

	mkdir $appsDir
	mv $binDir/lyx $appsDir/LyX

	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"
	local INTERNAL="0"
	sed \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		-e "s|@INTERNAL@|$INTERNAL|" \
		$portDir/additional-files/lyx.rdef.in > lyx.rdef

	addResourcesToBinaries lyx.rdef \
		$appsDir/LyX

	addAppDeskbarSymlink $appsDir/LyX
}
