# Template file for 'cross-x86_64-linux-musl'
_binutils_version=2.39
_gcc_version=12.2.0
_musl_version=1.1.24
_linux_version=5.10.4
_libucontext_version=1.0
pkgname=cross-x86_64-linux-musl
version=0.35
revision=3
build_style=void-cross
hostmakedepends="texinfo tar gcc-objc gcc-go flex perl python3"
makedepends="isl15-devel libmpc-devel gmp-devel mpfr-devel
 zlib-devel libzstd-devel"
depends="${pkgname}-libc-${version}_${revision}"
short_desc="Void cross toolchain for ${pkgname/cross-}"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-2.0-or-later, GPL-3.0-or-later, MIT"
homepage="https://www.voidlinux.org/"
distfiles="
 ${GNU_SITE}/binutils/binutils-${_binutils_version}.tar.xz
 ${GNU_SITE}/gcc/gcc-${_gcc_version}/gcc-${_gcc_version}.tar.xz
 https://musl.libc.org/releases/musl-${_musl_version}.tar.gz
 ${KERNEL_SITE}/kernel/v5.x/linux-${_linux_version}.tar.xz
 https://github.com/kaniini/libucontext/archive/libucontext-${_libucontext_version}.tar.gz"
checksum="645c25f563b8adc0a81dbd6a41cffbf4d37083a382e02d5d3df4f65c09516d00
 e549cf9cf3594a00e27b6589d4322d70e0720cdd213f39beb4181e06926230ff
 1370c9a812b2cf2a7d92802510cca0058cc37e66a7bedd70051f0a34015022a3
 904e396c26e9992a16cd1cc989460171536bed7739bf36049f6eb020ee5d56ec
 23714e99a87f6dea82e8a073c526325161dd65462459820b16a6162be91955bb"
nocross=yes

# explicitly enable for final gcc, gfortran does not build without on x86
cross_gcc_configure_args="--enable-libquadmath"
cross_musl_cflags="-O2"

if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
	broken="Can't build crosstoolchain to itself"
fi

case "$XBPS_MACHINE" in
	ppc64*) ;;
	ppc*|mips*) broken="no gccgo support";;
esac

cross-x86_64-linux-musl-libc_package() {
	short_desc+=" - libc files"
	nostrip=yes
	noverifyrdeps=yes
	noshlibprovides=yes

	pkg_install() {
		vmove usr/${sourcepkg/cross-}
	}
}
