# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit autotools

JERASURE_COMMIT="de1739cc8483696506829b52e7fda4f6bb195e6a"
DESCRIPTION="Library in C facilitating Erasure Coding for storage applications"
HOMEPAGE="http://jerasure.org https://web.eecs.utk.edu/~jplank/plank/www/software.html"
SRC_URI="https://github.com/ceph/jerasure/archive/${JERASURE_COMMIT}.tar.gz -> ${P}.tar.gz"
S="${WORKDIR}"/${PN}-${JERASURE_COMMIT}

LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~x86"
IUSE="test"
RESTRICT="!test? ( test )"

DEPEND="dev-libs/gf-complete"
RDEPEND="${DEPEND}"
BDEPEND="test? ( dev-libs/gf-complete )"

DOCS=( Manual.pdf README )

src_prepare() {
	default
	# Avoid adding '-march=native'-like flags
	sed -i -e 's/ $(SIMD_FLAGS)//g' src/Makefile.am Examples/Makefile.am || die
	eautoreconf
}

src_test() {
	# encode_decode.sh fails w/ _FORTIFY_SOURCE(=3?) but the test
	# is new in the snapshot we're taking (there were no tests before),
	# and upstream development is over, so let's skip the one test unless
	# someone really wants to investigate it (so we can have unrestricted
	# tests rather than none running).
	emake GF_COMPLETE_DIR="${BROOT}"/usr/bin check XFAIL_TESTS="encode_decode.sh"
}

src_install() {
	default
	find "${D}" -name '*.la' -delete || die
}