# Template file for 'linphone-desktop'
pkgname=linphone-desktop
version=5.2.6
revision=2
build_wrksrc="linphone-app" # The root cmake is glue code for their vendored libs
build_style=cmake
cmake_builddir="build-cmake"
configure_args="-DLINPHONEAPP_VERSION=${version}"
hostmakedepends="qt5-qmake qt5-host-tools qt5-declarative"
makedepends="bctoolbox-devel belcard-devel belle-sip-devel linphone-devel
 mediastreamer-devel qt5-declarative-devel qt5-quickcontrols2-devel
 qt5-svg-devel qt5-tools-devel qt5-webview-devel qt5-speech-devel
 qt5-multimedia-devel sonnet-devel"
depends="qt5>=5.9_1 qt5-quickcontrols qt5-quickcontrols2 qt5-graphicaleffects"
short_desc="Linphone qt desktop"
maintainer="John <me@johnnynator.dev>"
license="GPL-3.0-or-later"
homepage="https://www.linphone.org/"
distfiles="https://gitlab.linphone.org/BC/public/linphone-desktop/-/archive/${version}/linphone-desktop-${version}.tar.gz"
checksum=7e7953f8b7da86b7b39a6a3dcf7aea1bae40b0c43f5715d20278fc0876012341
replaces="linphone-gui>=0"

pre_configure() {
	IFS=. read _major _minor _patch <<<"$version"
	vsed -e "s/set(version_major)/set(version_major $_major)/g" -i CMakeLists.txt
	vsed -e "s/set(version_minor)/set(version_minor $_minor)/g" -i CMakeLists.txt
	vsed -e "s/set(version_patch)/set(version_patch $_patch)/g" -i CMakeLists.txt

	rm -vf ${wrksrc}/linphone-app/cmake/FindLibLinphone.cmake \
		${wrksrc}/linphone-app/cmake/FindBCToolbox.cmake \
		${wrksrc}/linphone-app/cmake/FindBelcard.cmake \
		${wrksrc}/linphone-app/cmake/FindMediastreamer2.cmake \
		${wrksrc}/linphone-app/cmake/FindLinphoneCxx.cmake
}

linphone-gui_package() {
	short_desc+=" - (transitional dummy package)"
	depends="linphone-desktop"
	build_style=meta
}

# XXX: The cmake install does all kinds of stuff we don't want
do_install() {
	vbin ${cmake_builddir}/linphone
	vinstall ${cmake_builddir}/libapp-plugin.so 644 usr/lib
	vinstall ${cmake_builddir}/linphone.desktop 644 usr/share/applications/
	vinstall assets/images/linphone_logo.svg 644 usr/share/icons/hicolor/scalable/apps/ linphone.svg
	vinstall assets/linphonerc-factory 644 usr/share/linphone/
	vinstall assets/assistant/create-app-sip-account.rc 644 usr/share/linphone/assistant
	vinstall assets/assistant/use-app-sip-account.rc 644 usr/share/linphone/assistant
	vinstall assets/assistant/use-other-sip-account.rc 644 usr/share/linphone/assistant
	for s in 16x16 22x22 24x24 32x32 64x64 128x128 256x256; do
		vinstall assets/icons/hicolor/${s}/apps/icon.png 644 usr/share/icons/hicolor/${s}/apps/
	done
}
