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

EAPI=8

MAIN_PH=4d63ec069c0ecea70a195f2065a26a1ffdbf44fd
AUX_PH=8a37fdf62c405108d7892a143b05f9be5d2cf85c

inherit racket

DESCRIPTION="SRFI 110 implementation and moreuse with #lang SRFI-110"
HOMEPAGE="https://pkgs.racket-lang.org/package/SRFI-110-for-Racket"
SRC_URI="https://github.com/damien-mattei/SRFI-110-for-Racket/archive/${MAIN_PH}.tar.gz -> ${P}.tar.gz
	https://github.com/damien-mattei/Scheme-PLUS-for-Racket/archive/${AUX_PH}.tar.gz -> ${PN}_aux_Scheme-PLUS-for-Racket-${PV}.tar.gz"
S="${WORKDIR}/SRFI-110-for-Racket-${MAIN_PH}/"

LICENSE="LGPL-3+"
SLOT="0"
KEYWORDS="~amd64 ~arm ~ppc ~ppc64 ~x86"

RDEPEND="dev-racket/r7rs
	dev-racket/scribble-code-examples"
BDEPEND="${RDEPEND}"
PDEPEND="dev-racket/scheme-plus-for-racket"

src_compile() {
	pushd "${WORKDIR}/Scheme-PLUS-for-Racket-${AUX_PH}/" >/dev/null || die
	raco_bare_install user Scheme-PLUS-for-Racket
	popd >/dev/null || die

	racket_src_compile
}

pkg_prerm() {
	if [[ -z "${REPLACED_BY_VERSION}" ]] && racket-where Scheme-PLUS-for-Racket ; then
		raco_remove "${RACKET_PN}" Scheme-PLUS-for-Racket
	fi
}

pkg_postinst() {
	! racket-where "${RACKET_PN}" && raco_system_install

	has_version dev-racket/scheme-plus-for-racket &&
		raco_system_setup "${RACKET_PN}" Scheme-PLUS-for-Racket
}