# Template file for 'cross-arm-linux-musleabi'
_binutils_version=2.44
_gcc_version=14.2.1+20250405
_musl_version=1.1.24
_linux_version=6.14
_libucontext_version=1.3.3
pkgname=cross-arm-linux-musleabi
version=0.37
revision=4
build_style=void-cross
configure_args="--with-arch=armv5te --with-float=soft
 --enable-autolink-libatomic"
hostmakedepends="texinfo tar gcc-objc gcc-go gcc-gdc flex perl python3 pkg-config"
makedepends="isl-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/"
case "${_gcc_version}" in
	*+*) distfiles="https://gcc.gnu.org/pub/gcc/snapshots/${_gcc_version%%.*}-${_gcc_version#*+}/gcc-${_gcc_version%%.*}-${_gcc_version#*+}.tar.xz" ;;
	*) distfiles="${GNU_SITE}/gcc/gcc-${_gcc_version}/gcc-${_gcc_version}.tar.xz" ;;
esac
distfiles+="
 ${GNU_SITE}/binutils/binutils-${_binutils_version}.tar.xz
 https://musl.libc.org/releases/musl-${_musl_version}.tar.gz
 ${KERNEL_SITE}/kernel/v${_linux_version%%.*}.x/linux-${_linux_version}.tar.xz
 https://github.com/kaniini/libucontext/archive/libucontext-${_libucontext_version}.tar.gz"
checksum="9a84b0947d8fb18197eef3fce8e255e30a61f7f382cebb961b1705c1d99214a3
 ce2017e059d63e67ddb9240e9d4ec49c2893605035cd60e92ad53177f4377237
 1370c9a812b2cf2a7d92802510cca0058cc37e66a7bedd70051f0a34015022a3
 a294b683e7b161bb0517bb32ec7ed1d2ea7603dfbabad135170ed12d00c47670
 06fca63bc00a236ea7e2ce4fe984d7203b1f9ea046f5c8c815d280da4ea281e3"
nocross=yes

cross_binutils_configure_args="--without-fp"
cross_musl_cflags="-Os -march=armv5te -msoft-float -mfloat-abi=soft"

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

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

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

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