# Contributor: Bradford D. Boyle <bradford.d.boyle@gmail.com>
# Maintainer: Bradford D. Boyle <bradford.d.boyle@gmail.com>
pkgname=hamlib
pkgver=3.0
pkgrel=0
pkgdesc="Library to control radio transceivers and receivers"
url="http://www.hamlib.org/"
arch="all"
license="LGPL-2.0-or-later"
depends=""
depends_dev=""
makedepends="$depends_dev linux-headers perl-dev python-dev swig tcl-dev chrpath"
install=""
subpackages="$pkgname-dev $pkgname-doc $pkgname-perl $pkgname-python $pkgname-tcl"
source="http://downloads.sourceforge.net/project/hamlib/hamlib/3.0/hamlib-3.0.tar.gz"

builddir="$srcdir"/$pkgname-$pkgver
build() {
	cd "$builddir"
	./configure --prefix=/usr --sbindir=/usr/bin \
		--with-perl-binding \
		--with-python-binding \
		--with-tcl-binding
	make
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install

	install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
}

perl() {
	depends="perl"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/perl5 "$subpkgdir"/usr/lib/

	# fix perl module location
	cd "$subpkgdir"/usr/lib/perl5/site_perl/
	mkdir current
	mv auto current
	mv Hamlib.pm current
	rm perltest.pl

	chrpath --delete "$subpkgdir"/usr/lib/perl5/site_perl/current/auto/Hamlib/Hamlib.so
}

python() {
	depends="python"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/python2.7 "$subpkgdir"/usr/lib/
}

tcl() {
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/tcl "$subpkgdir"/usr/lib/
}

md5sums="ffe192ff83c5935966367efe5bb33334  hamlib-3.0.tar.gz"
sha256sums="bc16546161a47e21a44a710a40aeb0bce478f112bffcc4f253eb27e150f1c21e  hamlib-3.0.tar.gz"
sha512sums="16ac66ab91d44c364054aa6ba8292a6538886744d83a83eb0887f55407f836e1d4a402cc7a41576594bea8100c2eefa26bae212f767a68b2a4db7a709166cbd2  hamlib-3.0.tar.gz"
