# Copyright 2026 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit toolchain-funcs

DESCRIPTION="Serve Unix files to Plan 9 machines using the 9P protocol"
HOMEPAGE="https://bitbucket.org/plan9-from-bell-labs/u9fs"
EGIT_COMMIT="d65923fd17e8"
SRC_URI="https://bitbucket.org/plan9-from-bell-labs/u9fs/get/${EGIT_COMMIT}.tar.gz -> ${PN}-${EGIT_COMMIT}.tar.gz"
S="${WORKDIR}/plan9-from-bell-labs-u9fs-${EGIT_COMMIT}/"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"

src_prepare() {
	default

	use elibc_musl && eapply "${FILESDIR}/u9fs-0_p20210125-remove-authrhosts.diff"
}

src_compile() {
	tc-export CC


	emake \
		CFLAGS="-I. ${CFLAGS}" \
		LD="$CC" \
		LDFLAGS="${LDFLAGS}"
}

src_install() {
	einstalldocs

	dobin u9fs
	newman u9fs.man u9fs.1
}