# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=anytun
pkgver=0.3.6
pkgrel=4
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
	$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
}

md5sums="90683b03a3f438639c5f2de0730dcf5e  anytun-0.3.6.tar.gz
d7220eae296c814ee100d8ca1f5cf19a  boost-mt.patch
3122d09abb4d8f24043e11bdbf5b8229  fix-werror-compile-flags.patch
d429ba9feaaf15bb268b811eccc71862  anytun.initd"
sha256sums="afef9ba3002df9d1bd2eba2ec2ab9a9551a0822bfa9664bfbc3c97a6e2e313a8  anytun-0.3.6.tar.gz
31dca9b29da41ed338d12ff96171b1f2a84013f689af0965c2d97f2fbcf0b499  boost-mt.patch
a07966d0866dc18b88682fffa3892535ed6422cb1200c7bdbeec2a019a8a34b4  fix-werror-compile-flags.patch
f2390be3b27d2a208e4d77bf776d62c2dd9a92a79a30e5394188b82af6f55037  anytun.initd"
sha512sums="470bec0ed96fd8cd7921d8a110272578020b666e8852c9e52a88da9957b2d641cd2b43cc8c9e453331a9f848282ea4516e304d71add6fea71a7ce3e6d76117b1  anytun-0.3.6.tar.gz
e19522a26529bb16591ed724d499c3b7fd7060e937eadc93f7719c29aaa604b953c59b94024efe2227331741ba5bbde084619dd42071cf086ef803906e6678a7  boost-mt.patch
f9705cf1879a8f50bc53fae04b48a88baa9aa5f7f1035b0ec737bdacaa21007da76b8985e1b9cba05936c9dc94200cb3c4ff39492755c8f219e42ee73ecf1431  fix-werror-compile-flags.patch
a31455058e0ac60ed9457c79eea789ce19ba49abc200b59c0d8390eb0c3b6f09813177f9b679fb8ac69ac7b0be862e4604d19298ae4cd79925511fff3963e93d  anytun.initd"
