# Template file for 'capnproto'
pkgname=capnproto
version=0.10.2
revision=1
build_style=gnu-configure
short_desc="Cap'n Proto serialization/RPC system"
maintainer="eater <hello@eaterofco.de>"
license="MIT"
homepage="https://capnproto.org"
distfiles="https://capnproto.org/capnproto-c++-${version}.tar.gz"
checksum=7cd91a244cb330cda5b41f4904f94b61f39ba112835b31fa8c3764cedbed819f

if [ "$CROSS_BUILD" ]; then
	hostmakedepends+=" capnproto-devel"
	configure_args+=" --with-external-capnp"
fi

if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
	makedepends+=" libatomic-devel"
	LDFLAGS+=" -latomic"
fi

if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
	# fibers require ucontext and it'd be better to avoid libucontext dependencies
	CPPFLAGS="-DKJ_USE_FIBERS=0"
fi

post_install() {
	 vlicense LICENSE.txt
}

capnproto-devel_package() {
	short_desc+=" - development files"
	depends="${sourcepkg}>=${version}_${revision}"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/*.a
		vmove usr/lib/*.la
		vmove usr/lib/libkj.so
		vmove usr/lib/libkj-test.so
		vmove usr/lib/libkj-http.so
		vmove usr/lib/libkj-async.so
		vmove usr/lib/libcapnpc.so
		vmove usr/lib/libcapnp.so
		vmove usr/lib/libcapnp-rpc.so
		vmove usr/lib/libcapnp-json.so
		vmove usr/lib/libcapnp-websocket.so
		vmove usr/lib/pkgconfig
		vmove usr/lib/cmake
	}
}
