# Contributor: Milan P. Stanić <mps@arvanta.net>
# Maintainer: Milan P. Stanić <mps@arvanta.net>
pkgname=svxlink
pkgver=24.02
pkgrel=2
pkgdesc="advanced radio repeater controller and EchoLink"
url="http://www.svxlink.org"
arch="all"
license="GPL-2.0-or-later"
pkgusers="svxlink"
pkggroups="svxlink"
options="!check" # package doesn't have tests
makedepends="
	alsa-lib-dev
	cmake
	curl-dev
	groff
	gsm-dev
	libgcrypt-dev
	libogg-dev
	libsigc++-dev
	librtlsdr-dev
	linux-headers
	jsoncpp-dev
	opus-dev
	popt-dev
	speex-dev
	tcl-dev
	"
install="$pkgname.pre-install $pkgname.post-install"
subpackages="$pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/sm0svx/svxlink/archive/refs/tags/$pkgver.tar.gz
	svxlink.initd
	svxlink.confd

	0001-add-include-stdint.h-AsyncAudioContainerPcm.cpp.patch
	0001-refactor-AsyncCppDnsLookupWorker.cpp.patch
	0001-change-include-of-time.h-in-AsyncAtTimer.h.patch
	"

build() {
	cd src
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DSYSCONF_INSTALL_DIR=/etc \
		-DLOCAL_STATE_DIR=/var \
		-DLIB_INSTALL_DIR=/usr/lib \
		-DBUILD_STATIC_LIBS=ON \
		-DUSE_OSS=NO -DUSE_QT=NO \

	make
	make doc
}

package() {
	cd src
	make DESTDIR="$pkgdir" install
	rm -rf $pkgdir/usr/share/doc
	install -m755 -D "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname
	install -m644 -D "$srcdir"/$pkgname.confd \
		"$pkgdir"/etc/conf.d/$pkgname
	install -o svxlink -g svxlink -d "$pkgdir"/var/spool/svxlink
	install -o svxlink -g svxlink -d "$pkgdir"/var/spool/svxlink/voice_mail/
	install -o svxlink -g svxlink -d "$pkgdir"/var/spool/svxlink/qso_recorder/
	install -o svxlink -g svxlink -d "$pkgdir"/var/spool/svxlink/propagation_monitor
}

sha512sums="
7bd8d9bf272922ec5d4b134ca1d5ee9cb1f9713c5cb9985aed5f63e601425bb6b6a17de026095c9cbb83797cf58228bcf05284c5a87384b4d019f6c27ac3e848  svxlink-24.02.tar.gz
39d1a4febfdd5e50b9df21c0e77c80a50af1680a6e001cda3f31fc752b1cba0948c40bf70106579e32c1de37ee76d6dde218824bcac2b013a71b144256f60168  svxlink.initd
1a587c032e73c3a76a1aa8c18d2b3d90a716f49ffb75a5b863da02a59a76a433355e2c1a07f44795545bce01e713890881a14ef9b9d2aae3690e0bf462d432a7  svxlink.confd
76e16c898bda0bfa2cb8089367aa6dd55502184548747d05ee091b8dff6756d2024ea63c35cd454eff90a8af2a3f24981edac79322e596eff008fd5351ebb075  0001-add-include-stdint.h-AsyncAudioContainerPcm.cpp.patch
d2272518f495cf0d7c8db27f95fd5bc605a1cb67aa21b92226768fdb41b9431ef462e4b5a4592968cd49f270eab41a1a66c0f1147ba1af3e72224e89ac278ee8  0001-refactor-AsyncCppDnsLookupWorker.cpp.patch
5717b47a6b18974ecfcdf931b3ce7bd327be5a45ad062b0656fa1aa033c29b474df17779d61f262c46e7bd777381102a9c34a95c6dcdc8a2fa5da3cac92943b6  0001-change-include-of-time.h-in-AsyncAtTimer.h.patch
"
