# Contributor: Carlo Landmeter <clandmeter@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=ser2net
pkgver=3.4
pkgrel=1
pkgdesc="A proxy that allows telnet/tcp connections to be made to serial ports"
url="https://sourceforge.net/projects/ser2net"
arch="all"
license="GPL"
depends=""
depends_dev=""
makedepends="$depends_dev linux-headers"
install=""
subpackages="$pkgname-doc"
source="https://sourceforge.net/projects/ser2net/files/ser2net/ser2net-$pkgver.tar.gz
	TIOCSRS485.patch
	${pkgname}.confd
	${pkgname}.initd"

_builddir="$srcdir"/ser2net-$pkgver
prepare() {
	local i
	cd "$_builddir"
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
}

build() {
	cd "$_builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		|| return 1
	make || return 1
}

package() {
	cd "$_builddir"
	make DESTDIR="$pkgdir" install || return 1
        install -D -m755 "$srcdir"/ser2net.initd \
		"$pkgdir"/etc/init.d/ser2net
	install -D -m644 "$srcdir"/ser2net.confd \
		"$pkgdir"/etc/conf.d/ser2net
	install -D -m644 ser2net.conf \
		"$pkgdir"/etc/ser2net.conf
}

md5sums="562274d783534276a9feac913b7d8c4e  ser2net-3.4.tar.gz
cfeb58eb6b059e5ff09357062ad0699d  TIOCSRS485.patch
100fc9cc68a766afde182d14a26bfec0  ser2net.confd
59af9bceac660472e368dc7e318ae17d  ser2net.initd"
sha256sums="d846066e27c3072565990745d030357aa0c278f96b7d1d4f59023347c1db8824  ser2net-3.4.tar.gz
444eea3752a3209ccbba87cf2374843011595ebf495b7e4e807e39e0d08412a7  TIOCSRS485.patch
3058368970e77b8b7fcf6fca9f3530b683d9e9c27c431531f8566dde01dab849  ser2net.confd
0d301873d55826095cc6ee3f526e5a797b797c95fdc23ac58166aa5cc3cbf80d  ser2net.initd"
sha512sums="b507ce87106030dc5b46fb384f7ed219d3c20c2303a8db9a3fdc51172ad3c5cb103cc54b0f3ab548f702cfae15ca9f055350b28d167ffff340026ac2778a92e0  ser2net-3.4.tar.gz
c545b47f49857f2a83b7250c0f3d80787e29cc2f4ca2d9b579df9f41f50ba60da26f53ec75659eede712b182cac616e438af60fd6d11c8c4acc006f7827ee9e6  TIOCSRS485.patch
15054f7aa604f93bd5a54c2bb96c9a3168905be5ace50bcd2ebeeaf9dc9ae19426388e6118e9e4850125349090ee29542c24487e64c349593a76366be4a5e501  ser2net.confd
2b8dc01055222743398fc8ea6bf66b3aabc92661522284c8669d8114a32d376c03038e33fc9802c1cf93290a4ac4f07a4ca806056b98d1ecaff3cbc2614d3b7b  ser2net.initd"
