# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=sngtc_client
pkgver=1.3.11
pkgrel=1
pkgdesc="Sangoma Media Transcode client and lib"
url="https://wiki.freepbx.org/display/MTC/Media+Transcoding"
arch="all"
license="LGPL"
options="!check" #no test suite
makedepends="ortp-dev linux-headers bctoolbox-dev"
subpackages="$pkgname-dev"
depends_dev="$pkgname=$pkgver-r$pkgrel"
# they ship firmware updater and server lib as precompiled closed source
# thats why the source package holds <arch>. The client code appears to
# be equal on both i686 an x86_64 so we just pick x86_64 package for all
# our archs.
source="https://ftp.sangoma.com/linux/transcoding/sng-tc-linux-$pkgver.x86_64.tgz
	sngtc_client-dynamic-ortp.patch
	musl-fix-types.patch
	ortp.patch
	bctoolbox-underlinking.patch"
builddir="$srcdir"/sng-tc-linux-$pkgver.x86_64

prepare() {
	default_prepare
	# use dynamic ortp from system
	rm -r client/sngtc_client/*ortp*
}

build() {
	make libsngtc libsngtc_node sngtc_client
}

check() {
	make test
}

package() {
	make DESTDIR="$pkgdir" libsngtc_node-install sngtc_client-install
	mkdir -p "$pkgdir"/usr/include/sng_tc
	cp server/libsngtc/*.h "$pkgdir"/usr/include/sng_tc/
}

sha512sums="
6bf871f7f0e9c70f1c7adae6f80756de335e3b1fd9afaa451c9adbc6896941157c17cf5e79ed8e753190057ac2d5ea03a0d40d587f13ec19c49d4d83f7baca90  sng-tc-linux-1.3.11.x86_64.tgz
2b784c56d1482ad9069502c408138d0c0b0ea6b393902d45b09200a3a588e02138c21a1fbee4d5715711e578130c30c607cae59f7ee24b8ce5bccd5a9c2fce14  sngtc_client-dynamic-ortp.patch
008447bf7c8f690cc9ee5efd232dee1b4f3f35e94827a518f88a7c46b4741b6d1e8418c32f099c807e61d7ae815467aed3a3b0134114e75574397ae324540067  musl-fix-types.patch
5d1dcf45834e192f9c14681aa9e7f5fc58ae08b283f25f0565ac6522f8af06bf71585e3dd7c92ae727c86fa7bfbe7a27bd7bfcafe4913ab005d857a1fef34a56  ortp.patch
be6cc8a349b2dede19223cef2d888fc6ab183d832d75d77dfbd8b029b31814f9391d9b6af08d81e9765231faef0cdc9a3c50e7f847401d6ccc740f2cedd2f39c  bctoolbox-underlinking.patch
"