# Template file for 'linphone'
pkgname=linphone
version=3.12.0
revision=1
build_style="cmake"
configure_args="-DENABLE_STRICT=0 -DENABLE_GTK_UI=$(vopt_if gui true false)"
hostmakedepends="doxygen graphviz python-pystache python-six"
makedepends="sqlite-devel readline-devel mediastreamer-devel
 belle-sip-devel speex-devel libxml2-devel libnotify-devel
 bctoolbox-devel ortp-devel bzrtp-devel gettext-devel
 libupnp-devel libsrtp-devel belcard-devel $(vopt_if gui gtk+-devel)"
short_desc="Voice-over-IP phone"
maintainer="John <johnz@posteo.net>"
license="GPL-2.0-or-later"
homepage="https://www.linphone.org"
distfiles="https://www.linphone.org/releases/sources/${pkgname}/${pkgname}-${version}.tar.gz"
checksum=3da4fa55c01aa4a04923a8f028eb7fadeaed094614594e1a12cfb75e4a9f105e

build_options="gui"
build_options_default="gui"
subpackages="linphone-daemon linphone-console linphone-tools
 linphone-devel $(vopt_if gui linphone-gui)"


pre_build() {
	echo "#define MS2_GIT_VERSION=unknown" > coreapi/gitversion.h
	echo "#define MS2_GIT_VERSION=unknown" > gtk/liblinphone_gitversion.h
}

linphone-daemon_package() {
	short_desc+=" - daemon"
	pkg_install() {
		vmove usr/bin/linphone-daemon
	}
}

linphone-gui_package() {
	short_desc+=" - gtk based gui"
	depends="${sourcepkg}>=${version}_${revision} hicolor-icon-theme
	desktop-file-utils"
	pkg_install() {
		vmove usr/bin/linphone
		vmove usr/share/applications
		vmove usr/share/icons
		vmove usr/share/pixmaps
		vmove "usr/share/linphone/*.ui"
		vmove usr/share/locale
	}
}

linphone-console_package() {
	short_desc+=" - console interface"
	pkg_install() {
		vmove usr/bin/linphonec
		vmove usr/bin/linphonecsh
	}
}

linphone-tools_package() {
	short_desc+=" - tools"
	pkg_install() {
		for i in buddy_status chatroom filetransfer helloworld lp-auto-answer\
			lp-sendmsg lp-test-ecc lpc2xml_test notify realtimetext_receiver\
			realtimetext_sender registration xml2lpc_test; do
			vmove usr/bin/$i;
		done
		vmove "usr/bin/*test"
	}
}

linphone-devel_package() {
	short_desc+=" - development files"
	depends="${sourcepkg}>=${version}_${revision} libxml2-devel ortp-devel"
	pkg_install() {
		vmove "usr/lib/*.so"
		vmove "usr/lib/*.a"
		vmove usr/include
		vmove usr/share/LinphoneCxx/cmake
		vmove usr/share/Linphone/cmake
	}

}
