# Template file for 'lc0'
pkgname=lc0
version=0.29.0
revision=1
archs="x86_64* i686* aarch64* armv[67]l* ppc64le*"
create_wrksrc=yes
build_style=meson
configure_args="-Dgtest=false"
_lczero_commit=4dfa4ce8339357819f7de01517e6297d4c768cdf
hostmakedepends="pkg-config"
makedepends="protobuf-devel zlib-devel eigen $(vopt_if openblas openblas-devel)
 $(vopt_if opencl ocl-icd-devel)"
short_desc="UCI chess engine designed to play via neural network"
maintainer="shtayerc <david.murko@mailbox.org>"
license="GPL-3.0-only"
homepage="https://lczero.org"
distfiles="https://github.com/LeelaChessZero/lc0/archive/v${version}.tar.gz
 https://github.com/LeelaChessZero/lczero-common/archive/${_lczero_commit}.tar.gz"
checksum="3d3cd99bc5a82c5da2b8985ee6db4e1a2ff179e012da777319257d48c8a7c59d
 d2a4bd614c01e639b70cbf14cb7d3b732f157ae6bc4865d49697e89837af8d82"

build_options="openblas opencl"
build_options_default="openblas"
vopt_conflict openblas opencl

if [ "$CROSS_BUILD" ] && [ "$build_option_openblas" ]; then
	configure_args+=" -Dopenblas_include=${XBPS_CROSS_BASE}/usr/include/openblas/"
fi

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

case "$XBPS_TARGET_MACHINE" in
	ppc*) export CXXFLAGS+=" -DNO_WARN_X86_INTRINSICS";;
esac

post_extract() {
	mv lc0-$version/* .
	rmdir libs/lczero-common
	mv lczero-common-${_lczero_commit} libs/lczero-common
}
