# Template file for 'tbb'
pkgname=tbb
version=2021.11.0
revision=1
build_style=cmake
configure_args="-DTBB_STRICT=OFF -DTBB_TEST=OFF"
makedepends="libgomp-devel libhwloc-devel"
short_desc="Intel Threading Building Blocks"
maintainer="Andrea Brancaleoni <abc@pompel.me>"
license="Apache-2.0"
homepage="https://oneapi-src.github.io/oneTBB/"
changelog="https://raw.githubusercontent.com/oneapi-src/oneTBB/v${version}/RELEASE_NOTES.md"
distfiles="https://github.com/oneapi-src/oneTBB/archive/refs/tags/v${version}.tar.gz"
checksum=782ce0cab62df9ea125cdea253a50534862b563f1d85d4cda7ad4e77550ac363
make_check=no  # checks fail upstream on i686

case "$XBPS_TARGET_MACHINE" in
	x86_64*|aarch64*)
		build_options_default+=" -DTBB4PY_BUILD=ON"
		hostmakedepends+=" python3-devel python3-distutils-extra swig"
		makedepends+=" python3-devel"
	;;
esac

if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
	makedepends+=" libucontext-devel"
	configure_args+=" -DCMAKE_CXX_STANDARD_LIBRARIES=-lucontext"
fi

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

post_extract() {

	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
		vsed -e "s@#define MALLOC_UNIXLIKE_OVERLOAD_ENABLED __linux__@@" \
		  -i src/tbbmalloc_proxy/proxy.h
	fi
}

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