# Copyright 2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

LUA_COMPAT=( lua5-1 luajit lua5-{3..4} )

inherit lua-single

DESCRIPTION="A formatter for Fennel code"
HOMEPAGE="https://git.sr.ht/~technomancy/fnlfmt"
SRC_URI="https://git.sr.ht/~technomancy/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"
REQUIRED_USE="${LUA_REQUIRED_USE}"
RESTRICT="test"

DEPEND="${LUA_DEPS}"
RDEPEND="${DEPEND}"

pkg_setup() {
	lua-single_pkg_setup

	emakeargs=(
		LUA="${ELUA}"
		PREFIX="/usr"
	)
}

src_compile() {
	emake "${emakeargs[@]}"
}

src_install() {
	emake "${emakeargs[@]}" DESTDIR="${ED}" install
}