SUMMARY="A powerful desktop publishing application"
DESCRIPTION="Scribus is an Open Source program that brings professional page \
layout to Linux, BSD UNIX, Solaris, OpenIndiana, GNU/Hurd, Mac OS X, OS/2 \
Warp 4, eComStation, Haiku and Windows desktops with a combination of \
press-ready output and new approaches to page design. Underneath a modern and \
user-friendly interface, Scribus supports professional publishing features, \
such as color separations, CMYK and spot colors, ICC color management, and \
versatile PDF creation."
HOMEPAGE="https://www.scribus.net"
COPYRIGHT="2014-2021 Scribus Team"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://sourceforge.net/projects/scribus/files/scribus-devel/$portVersion/scribus-$portVersion.tar.xz"
CHECKSUM_SHA256="47816e8fcf6d05788ff16aa4499f97ff22431c777a7789149b0a88b451e16b74"
PATCHES="scribus-$portVersion.patchset"
ADDITIONAL_FILES="scribus.rdef.in"

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

PROVIDES="
	scribus$secondaryArchSuffix = $portVersion
	app:Scribus
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libcairo$secondaryArchSuffix
	lib:libcdr_0.1$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
	lib:libexecinfo$secondaryArchSuffix
	lib:libfontconfig$secondaryArchSuffix
	lib:libfreehand_0.1$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libharfbuzz_icu$secondaryArchSuffix
	lib:libhunspell_1.7$secondaryArchSuffix
	lib:libhyphen$secondaryArchSuffix
	lib:libicudata$secondaryArchSuffix >= 66
	lib:libicuuc$secondaryArchSuffix >= 66
	lib:libjpeg$secondaryArchSuffix
	lib:liblcms2$secondaryArchSuffix
	lib:libmspub_0.1$secondaryArchSuffix
	lib:libpagemaker_0.0${secondaryArchSuffix}
	lib:libpng16$secondaryArchSuffix
	lib:libpodofo$secondaryArchSuffix
	lib:libpoppler$secondaryArchSuffix
	lib:libpython3.7m$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5OpenGL$secondaryArchSuffix
	lib:libQt5PrintSupport$secondaryArchSuffix
	lib:libQt5Qml$secondaryArchSuffix
	lib:libQt5Quick$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libQt5Xml$secondaryArchSuffix
	lib:libqxp_0.0$secondaryArchSuffix
	lib:librevenge_0.0${secondaryArchSuffix}
	lib:librevenge_generators_0.0${secondaryArchSuffix}
	lib:librevenge_stream_0.0${secondaryArchSuffix}
	lib:libssl$secondaryArchSuffix
	lib:libtiff$secondaryArchSuffix
	lib:libvisio_0.1$secondaryArchSuffix
	lib:libxml2$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	lib:libzmf_0.0$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libboost_system${secondaryArchSuffix} >= 1.69.0
	devel:libcairo$secondaryArchSuffix
	devel:libcdr_0.1$secondaryArchSuffix
	devel:libcrypto$secondaryArchSuffix
	devel:libexecinfo$secondaryArchSuffix
	devel:libfontconfig$secondaryArchSuffix
	devel:libfreehand_0.1$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libharfbuzz_icu$secondaryArchSuffix
	devel:libhunspell_1.7$secondaryArchSuffix
	devel:libhyphen$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:liblcms2$secondaryArchSuffix
	devel:libmspub_0.1$secondaryArchSuffix
	devel:libpagemaker_0.0$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libpodofo$secondaryArchSuffix
	devel:libpoppler$secondaryArchSuffix >= 117
	devel:libpython3.7m$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libqxp_0.0$secondaryArchSuffix
	devel:librevenge_0.0$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libtiff$secondaryArchSuffix
	devel:libvisio_0.1$secondaryArchSuffix
	devel:libxml2$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	devel:libzmf_0.0$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:python3
	"

BUILD()
{
	cmake .  -DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=$appsDir/Scribus \
		-DEXECUTABLE_OUTPUT_PATH=$appsDir/Scribus \
		-DPLUGINDIR=$appsDir/Scribus/plugins \
		-DCMAKE_INSTALL_DATAROOTDIR=$dataDir \
		-DSHAREDIR=$dataDir \
		-DAPPLICATION_DATA_DIR="config/settings/Scribus" \
		-DWANT_DISTROBUILD=1 \
		-DLIB_SUFFIX="$secondaryArchSuffix" \
		-DWANT_CPP17=1

	make $jobArgs
}

INSTALL()
{
	make install

	mv $appsDir/Scribus/scribus $appsDir/Scribus/Scribus
	rm -rf $appsDir/Scribus/bin

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

	addResourcesToBinaries $sourceDir/scribus.rdef $appsDir/Scribus/Scribus
	addAppDeskbarSymlink $appsDir/Scribus/Scribus Scribus
}
