# Contributor: Timo Teras <timo.teras@iki.fi>
# Maintainer: Timo Teras <timo.teras@iki.fi>
pkgname=dahdi-tools
pkgver=2.11.1
pkgrel=0
pkgdesc="Digium Asterisk Hardware Device Interface management utilities"
url="http://www.asterisk.org"
arch="all"
license="GPL"
depends=""
depends_dev="bsd-compat-headers linux-headers dahdi-linux-dev newt-dev"
makedepends="perl file $depends_dev"
install=
subpackages="$pkgname-doc $pkgname-dev"
source="http://downloads.digium.com/pub/telephony/dahdi-tools/releases/$pkgname-$pkgver.tar.gz
	fix-musl.patch
	$pkgname.initd"

builddir="$srcdir"/$pkgname-$pkgver

build() {
	cd "$builddir"
	eval local `perl -V:vendorlib`
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/infoa \
		--with-perllib="$vendorlib"
	sed -i -e 's/$(CC) $(LDFLAGS) -o $@ $^/$(CC) $^ $(LDFLAGS) -o $@/' \
		Makefile
	make
}

package() {
	cd "$builddir"
	make -j1 DESTDIR="$pkgdir" install
	install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/dahdi
}

sha512sums="d13f799baeaecab4601a379fb703fc169906e873f71baa9d13d688b2a3f4490a1c59eea8bd50e1a08a0712b38e556f8a17d02a8ea5289a003ca91b570ae5b8a6  dahdi-tools-2.11.1.tar.gz
45955caf04368ff30d60db0b3e892d940c9ac0422b337186ed251108ce25ab305d4590efff452f53f160a53fcd26a273f21d6d093307b426a3a2a6df53584daa  fix-musl.patch
3850ab9e323ec31d676d311c97d0cde70b809379b6c01c8ff6d5a01a860eb43bf3f18f2de53e952365d17f40638c7cb0481682d96cea5b7fdb1423d3e762e2f3  dahdi-tools.initd"
