# Template file for 'grpc'
pkgname=grpc
version=1.49.1
revision=1
build_style=cmake
configure_args="-DBUILD_SHARED_LIBS=ON
 -DgRPC_CARES_PROVIDER=package -DgRPC_PROTOBUF_PROVIDER=package
 -DgRPC_SSL_PROVIDER=package -DgRPC_ZLIB_PROVIDER=package
 -DgRPC_ABSL_PROVIDER=package -D_gRPC_RE2_LIBRARIES=-lre2
 -D_gRPC_RE2_INCLUDE_DIR=${XBPS_CROSS_BASE}/usr/include"
hostmakedepends="which protobuf"
_devel_depends="c-ares-devel re2-devel zlib-devel openssl-devel abseil-cpp-devel"
makedepends="libprotoc-devel protobuf-devel gperftools-devel ${_devel_depends}"
short_desc="High performance, open source, general RPC framework"
maintainer="Orphaned <orphan@voidlinux.org>"
license="Apache-2.0"
homepage="https://github.com/grpc/grpc"
distfiles="${homepage}/archive/v${version}/${pkgname}-${version}.tar.gz"
checksum=5071b630e2a14707ad060636990f1b25b0984bd168c7ea1ab95e48a3bdc0081f

if [ "$CROSS_BUILD" ]; then
	# need host grpc_cpp_plugin
	hostmakedepends+=" grpc"
fi

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

libgrpc_package() {
	short_desc+=" - libraries"
	pkg_install() {
		vmove "usr/lib/*.so.*"
		vmove usr/share
	}
}

grpc-devel_package() {
	short_desc+=" - development files"
	depends="${sourcepkg}>=${version}_${revision} ${_devel_depends}"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/*.so
		vmove usr/lib/cmake
		vmove usr/lib/pkgconfig
	}
}
