SUMMARY="A distributed IRC client"
DESCRIPTION="Quassel IRC is a modern, cross-platform, distributed IRC client, \
meaning that one (or multiple) client(s) can attach to and detach from a \
central core -- much like the popular combination of screen and a text-based \
IRC client such as WeeChat, but graphical.

In addition to this unique feature, it aims to bring a pleasurable, \
comfortable chatting experience to all major platforms (including Linux, \
Windows, and Mac OS X as well as Android smartphones), making communication \
with your peers not only convenient, but also easily available."
HOMEPAGE="https://quassel-irc.org"
COPYRIGHT="2005-2019 The Quassel IRC Team"
LICENSE="GNU GPL v2
	GNU GPL v3"
REVISION="2"
srcGitRev="d46e1e86c9869996285ac3f88970cf0e9e23e128"
SOURCE_URI="https://github.com/quassel/quassel/archive/$srcGitRev.zip"
CHECKSUM_SHA256="f56ef034ed703d37415aface01e756692f50425af3ff7f14b4e7389c2d55fe3e"
SOURCE_DIR="quassel-$srcGitRev"
PATCHES="quassel-0.14~git.patchset"

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

PROVIDES="
	quassel${secondaryArchSuffix} = $portVersion
	cmd:quassel$secondaryArchSuffix
	cmd:quasselclient$secondaryArchSuffix
	cmd:quasselcore$secondaryArchSuffix
	lib:libquassel_client$secondaryArchSuffix
	lib:libquassel_common$secondaryArchSuffix
	lib:libquassel_core$secondaryArchSuffix
	lib:libquassel_qtui$secondaryArchSuffix
	lib:libquassel_uisupport$secondaryArchSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5Sql$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	qt5${secondaryArchSuffix}_tools
	devel:libboost_system$secondaryArchSuffix
	devel:libGl$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5Sql$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:g++$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:qdbuscpp2xml$secondaryArchSuffix >= 5
	"

BUILD()
{
	mkdir -p build
	cd build
	cmake -DCMAKE_INSTALL_PREFIX=$prefix \
		-DCMAKE_C_COMPILER="gcc" \
		-DCMAKE_CXX_COMPILER="g++" \
		-DCMAKE_CXX_FLAGS="-fno-stack-protector" \
		-DWITH_WEBENGINE=OFF \
		-DWITH_OXYGEN_ICONS=ON \
		-DEMBED_DATA=ON ..
	make $jobArgs
}

INSTALL()
{
	cd build

	# Optional: strip the binaries before installing.
	# To be updated/removed whenever resources are added.
	echo "Stripping binaries ..."
	strip quassel
	strip quasselcore
	strip quasselclient

	# Add Haiku resources.
	xres -o quassel ../Haiku/Quassel.rsrc
	xres -o quasselclient ../Haiku/Quassel.rsrc
	xres -o quasselcore ../Haiku/Quassel.rsrc
	mimeset -f quassel
	mimeset -f quasselclient
	mimeset -f quasselcore

	echo "Copying binaries to ${appsDir} ..."
	mkdir -p ${appsDir}/Quassel
	cp quassel ${appsDir}/Quassel
	cp quasselcore ${appsDir}/Quassel
	cp quasselclient ${appsDir}/Quassel
	echo "Copying libraries to ${libDir} ..."
	mkdir -p ${libDir}
	cp lib/libquassel-*.so* ${libDir}

	DIR_QUASSEL_DESKBAR="${dataDir}/deskbar/menu/Applications/Quassel"
	mkdir -p ${DIR_QUASSEL_DESKBAR}
	echo "Making links for Deskbar in ${DIR_QUASSEL_DESKBAR} ..."
	addAppDeskbarSymlink ${appsDir}/Quassel/quassel "Quassel/Quassel"
	addAppDeskbarSymlink ${appsDir}/Quassel/quasselcore "Quassel/Quassel Core"
	addAppDeskbarSymlink ${appsDir}/Quassel/quasselclient "Quassel/Quassel Client"
}
