# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=freetdm
# upstream does not tag a release
# the pkgver is the commit date
pkgver=0_git20210830
_commitid=8918ee1c3637cad0f9d41a402d26d3aa076fc202
pkgrel=5
pkgdesc="FreeTDM Endpoint Module "
url="https://github.com/freeswitch/freetdm"
arch="all"
license="BSD-3-Clause"
makedepends="libtool automake autoconf
freeswitch-dev gsm-dev libpcap-dev zlib-dev
python3-dev"
checkdepends="gzip"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/freeswitch/freetdm/archive/$_commitid.tar.gz
remove-werr.patch"
builddir="$srcdir"/$pkgname-$_commitid

prepare() {
	default_prepare
	sh bootstrap
}

build() {
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		--with-modinstdir=/usr/lib/freeswitch
	make
}

check() {
	make check
}

package() {
	mkdir -p "$pkgdir"/etc/freeswitch/autoload_configs
	echo '<load module="mod_freetdm"/>' >> "$pkgdir"/etc/freeswitch/autoload_configs/modules.conf.xml
	make DESTDIR="$pkgdir" install
}

sha512sums="
059dd7c78a2fa08d79f9e4b9301ac4a0c8ccad9c32359e7c25f4fe5bdff33f9d146be746968baeb03b2c8702c33dbb962fc192f7fd20c8f8d2b5dbb81f2ecb77  freetdm-0_git20210830.tar.gz
9bbf829370a374c9e09b1bfc02be158695213f4e62d116ee25960f5d05a5a52a8b7956e1def6795686e054f9d03aa270e345930a3401025450a23fb381ac4450  remove-werr.patch
"
