# Template file for 'linphone-desktop'
pkgname=linphone-desktop
version=5.0.4
revision=1
build_wrksrc="linphone-app" # The root cmake is glue code for their vendored libs
build_style=cmake
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"
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=0399b32100dd555ab503b0f8856f6a632cd704672805301c7c753b8a1183a445
replaces="linphone-gui>=0"

pre_configure() {
	IFS=. read _major _minor _patch <<<"$version"
	vsed -e "s/set(FULL_VERSION )/set(FULL_VERSION $version)/g" -i CMakeLists.txt
	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
	vsed -e "/bc_compute_full_version/d" -i CMakeLists.txt
	vsed -e "/bc_parse_full_version/d" -i CMakeLists.txt
	vsed -e "/find_package(bctoolbox CONFIG)/d" -i CMakeLists.txt
	vsed -e "/project(/ a find_package(bctoolbox CONFIG)" -i CMakeLists.txt
}

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 build/linphone
	vinstall build/libapp-plugin.so 644 usr/lib
	vinstall build/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
}
