# Template file for 'libcxxabi'
pkgname=libcxxabi
version=11.0.0
revision=1
wrksrc="${pkgname}-${version}.src"
build_style=cmake
configure_args="-DLIBCXXABI_LIBCXX_INCLUDES=../../libcxx/include
 -DLIBCXXABI_USE_LLVM_UNWINDER=1
 -DLLVM_DEFAULT_TARGET_TRIPLE=${XBPS_CROSS_TRIPLET:-$XBPS_TRIPLET}"
hostmakedepends="clang-tools-extra llvm11"
makedepends="llvm11 llvm-libunwind-devel"
short_desc="Low-level support for libc++ standard library"
maintainer="Orphaned <orphan@voidlinux.org>"
license="NCSA, MIT"
homepage="https://libcxxabi.llvm.org"
distfiles="https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/libcxxabi-${version}.src.tar.xz
 https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/libcxx-${version}.src.tar.xz"
checksum="58697d4427b7a854ec7529337477eb4fba16407222390ad81a40d125673e4c15
 6c1ee6690122f2711a77bc19241834a9219dda5036e1597bfa397f341a9b8b7a"

case "$XBPS_TARGET_MACHINE" in
	armv[67]l)
		broken="invalid operands of types 'char [8]' and 'const uint64_t' to binary 'operator&'"
	;;
esac

post_extract() {
	# Since llvm 11, libcxx needs to be present next to the libcxxabi root
	mv ../libcxx-${version}.src ../libcxx
}

post_patch() {
	case "$XBPS_TARGET_MACHINE" in
		i686-musl|ppc-musl) ;;
		*) return 0 ;;
	esac
	vsed -i 's,^# Setup flags.$,add_library_flags(ssp_nonshared),' src/CMakeLists.txt
}

post_install() {
	vmkdir usr/include
	vcopy include/* usr/include
	vlicense LICENSE.TXT
}

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