# Template file for 'zerotier'
pkgname=zerotier-one
version=1.1.12
revision=1
wrksrc=ZeroTierOne-${version}
build_style=gnu-makefile
hostmakedepends="nodejs"
makedepends="sqlite-devel"
short_desc="Network Virtualization Everywhere"
maintainer="Michael Aldridge <aldridge.mac@gmail.com>"
license="GPL-3"
homepage="https://www.zerotier.com/"
distfiles="https://github.com/zerotier/ZeroTierOne/archive/${version}.tar.gz"
checksum=95258398c81f3515d7bf2a0ba0cce6c10af3dbdde4bbbf6115be6fd9eb325156

pre_build() {
	sed -i 's:#include <sys/sysctl.h>::' osdep/BSDEthernetTap.cpp \
		attic/OSXEthernetTap.cpp.pcap-with-bridge-test \
		ext/libnatpmp/getgateway.c  osdep/ManagedRoute.cpp  \
		attic/OSXEthernetTap.cpp.utun-work-in-progress osdep/OSXEthernetTap.cpp
}

do_build() {
	make all ZT_\ENABLE_\NETWORK_\CONTROLLER=1
}

pre_install() {
	sed -i 's/sbin/bin/g' make-linux.mk
}

post_install() {
	vsv zerotier
}

# REMARKS:
# Variable has backslashes in do_build. Upstream does it this way, don't know why.
# pre_build() fixes PRed by the-maldridge to upstream. Shouldn't be necessary
# after next release.
# One release later, upstream has not merged or commented on the PR.
