SUMMARY="Yet Another Telephony Engine"
DESCRIPTION="Yate stands for Yet Another Telephony Engine, and like the name \
states it is mainly a telephony engine; while currently focused on Voice over \
Internet Protocol (VoIP) and PSTN, its power lies in its ability to be easily \
extended. Voice, video, data and instant messenging can all be unified under \
Yate's flexible routing engine, maximizing communications efficiency and \
minimizing infrastructure costs for businesses."
HOMEPAGE="http://www.yate.ro/"
COPYRIGHT="2005-2021 Null Team"
LICENSE="GNU LGPL v2"
REVISION="1"
SOURCE_URI="http://voip.null.ro/tarballs/yate6/yate-6.4.0-1.tar.gz"
CHECKSUM_SHA256="8c23dc6bffbf8d478db3a85964b5019771c8f6c9acf5220f3465516a748a03b0"
SOURCE_DIR="yate"
PATCHES="
	yate-$portVersion.patchset
	yate-$portVersion-qt5.patchset
	"
ADDITIONAL_FILES="yate.rdef.in"
ARCHITECTURES="?all !x86_gcc2"
SECONDARY_ARCHITECTURES="?x86"

GLOBAL_WRITABLE_FILES="
	settings/yate/accfile.conf keep-old
	settings/yate/amrnbcodec.conf keep-old
	settings/yate/analog.conf keep-old
	settings/yate/cache.conf keep-old
	settings/yate/callcounters.conf keep-old
	settings/yate/callfork.conf keep-old
	settings/yate/camel_map.conf keep-old
	settings/yate/ccongestion.conf keep-old
	settings/yate/cdrbuild.conf keep-old
	settings/yate/cdrfile.conf keep-old
	settings/yate/ciscosm.conf keep-old
	settings/yate/clustering.conf keep-old
	settings/yate/cpuload.conf keep-old
	settings/yate/dbpbx.conf keep-old
	settings/yate/dsoundchan.conf keep-old
	settings/yate/dummyradio.conf keep-old
	settings/yate/enumroute.conf keep-old
	settings/yate/eventlogs.conf keep-old
	settings/yate/extmodule.conf keep-old
	settings/yate/fileinfo.conf keep-old
	settings/yate/filetransfer.conf keep-old
	settings/yate/gvoice.conf keep-old
	settings/yate/h323chan.conf keep-old
	settings/yate/heartbeat.conf keep-old
	settings/yate/isupmangler.conf keep-old
	settings/yate/jabberclient.conf keep-old
	settings/yate/jabberserver.conf keep-old
	settings/yate/javascript.conf keep-old
	settings/yate/jbfeatures.conf keep-old
	settings/yate/lateroute.conf keep-old
	settings/yate/lksctp.conf keep-old
	settings/yate/mgcpca.conf keep-old
	settings/yate/mgcpgw.conf keep-old
	settings/yate/moh.conf keep-old
	settings/yate/monitoring.conf keep-old
	settings/yate/mux.conf keep-old
	settings/yate/mysqldb.conf keep-old
	settings/yate/openssl.conf keep-old
	settings/yate/pbxassist.conf keep-old
	settings/yate/pgsqldb.conf keep-old
	settings/yate/presence.conf keep-old
	settings/yate/providers.conf keep-old
	settings/yate/queues.conf keep-old
	settings/yate/queuesnotify.conf keep-old
	settings/yate/radiotest.conf keep-old
	settings/yate/regexroute.conf keep-old
	settings/yate/regfile.conf keep-old
	settings/yate/register.conf keep-old
	settings/yate/rmanager.conf keep-old
	settings/yate/sigtransport.conf keep-old
	settings/yate/sip_cnam_lnp.conf keep-old
	settings/yate/sipfeatures.conf keep-old
	settings/yate/sqlitedb.conf keep-old
	settings/yate/ss7_lnp_ansi.conf keep-old
	settings/yate/subscription.conf keep-old
	settings/yate/tdmcard.conf keep-old
	settings/yate/tonegen.conf keep-old
	settings/yate/users.conf keep-old
	settings/yate/wiresniff.conf keep-old
	settings/yate/wpcard.conf keep-old
	settings/yate/yate-qt4.conf keep-old
	settings/yate/yate.conf keep-old
	settings/yate/Yate.conf keep-old
	settings/yate/ybladerf.conf keep-old
	settings/yate/yiaxchan.conf keep-old
	settings/yate/yjinglechan.conf keep-old
	settings/yate/yradius.conf keep-old
	settings/yate/yrtpchan.conf keep-old
	settings/yate/ysigchan.conf keep-old
	settings/yate/ysipchan.conf keep-old
	settings/yate/ysnmpagent.conf keep-old
	settings/yate/ysockschan.conf keep-old
	settings/yate/ystunchan.conf keep-old
	settings/yate/zapcard.conf keep-old
	settings/yate/zlibcompress.conf keep-old
	"

PROVIDES="
	yate$secondaryArchSuffix = $portVersion
	app:YateClient$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libQt5Xml$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libQt5Core$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:autoconf
	cmd:g++$secondaryArchSuffix
	cmd:make
	cmd:qmake
	cmd:which
	"

BUILD()
{
	./autogen.sh
	export LDFLAGS=-lnetwork
	./configure \
		--prefix $appsDir/Yate \
		--sysconfdir=$settingsDir \
		--libdir=$appsDir/Yate/lib \
		--sharedstatedir=$appsDir/Yate/data

	make $jobArgs
}

INSTALL()
{
	make install

	mv $appsDir/Yate/bin/yate-qt5 $appsDir/Yate/Yate
	mv $settingsDir/yate/yate.conf $settingsDir/yate/Yate.conf
	mv $settingsDir/yate/yate-qt5.conf $settingsDir/yate/Yate-qt5.conf

	# FIXME: this is wrong, paths need to be configured propely
	mv $appsDir/Yate/share/yate/* $appsDir/Yate/share
	mv $appsDir/Yate/lib/yate/* $appsDir/Yate/lib

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

	addResourcesToBinaries yate.rdef $appsDir/Yate/Yate
	addAppDeskbarSymlink $appsDir/Yate/Yate
}
