# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=anytun
pkgver=0.3.6
pkgrel=5
pkgdesc="Secure anycast tunneling protocol implementation for flexible and fault-tolerant VPNs"
url="http://www.anytun.org"
arch="all"
license="GPL-3.0"
depends=""
depends_dev="libressl-dev boost-dev linux-headers"
makedepends="$depends_dev"
install=""
subpackages="$pkgname-dev $pkgname-doc"
source="http://www.anytun.org/download/$pkgname-$pkgver.tar.gz
	boost-mt.patch
	fix-werror-compile-flags.patch
	fix-iostream.patch
	$pkgname.initd"

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

build() {
	cd "$_builddir"
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		--use-ssl-crypto \
		--examplesdir=/usr/share/docs || return 1
	make || return 1
}

package() {
	cd "$_builddir"
	mkdir -p ${pkgdir}/var/run/anytun  ${pkgdir}/var/run/anytun-controld  &>/dev/null
	make install DESTDIR="${pkgdir}"
	rm "${pkgdir}"/etc/init.d/$pkgname
	install -Dm 755 "$srcdir"/$pkgname.initd "${pkgdir}"/etc/init.d/$pkgname
}

sha512sums="470bec0ed96fd8cd7921d8a110272578020b666e8852c9e52a88da9957b2d641cd2b43cc8c9e453331a9f848282ea4516e304d71add6fea71a7ce3e6d76117b1  anytun-0.3.6.tar.gz
e19522a26529bb16591ed724d499c3b7fd7060e937eadc93f7719c29aaa604b953c59b94024efe2227331741ba5bbde084619dd42071cf086ef803906e6678a7  boost-mt.patch
e2f23ed7183f7636716946458b108a7055beb190a89d462d815d164f61a5c52b268620f053e5bb169c48d4e9cd56ad2f1d3d65a23a202375ef13998c29f4fdf6  fix-werror-compile-flags.patch
4d1115733f8d3d467bdd6348df451dfb60bff45685406792514717d27a567e323f76b12b4406a6d784f20716c08b596d6c09842c60e81c67fdaf8b0eed9b7530  fix-iostream.patch
a31455058e0ac60ed9457c79eea789ce19ba49abc200b59c0d8390eb0c3b6f09813177f9b679fb8ac69ac7b0be862e4604d19298ae4cd79925511fff3963e93d  anytun.initd"
