# Template file for 'protobuf'
pkgname=protobuf
version=3.6.1
revision=1
build_style=gnu-configure
hostmakedepends="automake libtool pkg-config"
makedepends="zlib-devel"
short_desc="Google's data interchange format"
maintainer="Michael Aldridge <maldridge@voidlinux.eu>"
license="BSD-3-Clause"
homepage="https://developers.google.com/protocol-buffers/"
changelog="https://raw.githubusercontent.com/google/protobuf/master/CHANGES.txt"
distfiles="https://github.com/google/protobuf/archive/v${version}.tar.gz"
checksum=3d4e589d81b2006ca603c1ab712c9715a76227293032d05b26fca603f90b3f5b

CXXFLAGS="-std=c++14"

if [ "$CROSS_BUILD" ]; then
	# needs host protoc
	hostmakedepends+=" protobuf"
	configure_args+=" --with-protoc=/usr/bin/protoc"
fi

case "$XBPS_TARGET_MACHINE" in
	armv[56]*|mips*)
		makedepends+=" libatomic-devel"
		LDFLAGS+=" -latomic"
		;;
esac

pre_configure() {
	autoreconf -fi
}

post_install() {
	vlicense LICENSE
}

protobuf-devel_package() {
	depends="zlib-devel protobuf-${version}_${revision}
	 protobuf-lite-${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove "usr/lib/*.a"
		vmove "usr/lib/*.so"
	}
}

protobuf-lite_package() {
	short_desc+=" - Lite version"
	pkg_install() {
		vmove "usr/lib/libprotobuf-lite.so.*"
	}
}
