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

EAPI=8

# ebuild generated by hackport 0.8.0.0.9999

CABAL_HACKAGE_REVISION=1

CABAL_FEATURES="lib profile haddock hoogle hscolour test-suite"
inherit haskell-cabal

DESCRIPTION="Perform refactorings specified by the refact library"
HOMEPAGE="https://github.com/mpickering/apply-refact"

LICENSE="BSD"
SLOT="0/${PV}"
KEYWORDS="~amd64"
IUSE="executable"

PATCHES=( "${FILESDIR}/${PN}-0.9.2.0-add-executable-flag.patch" )

RDEPEND="
	>=dev-haskell/extra-1.7.3:=[profile?]
	>=dev-haskell/filemanip-0.3.6.3:=[profile?] <dev-haskell/filemanip-0.4:=[profile?]
	>=dev-haskell/ghc-exactprint-0.6.4:=[profile?]
	|| ( dev-lang/ghc >=dev-haskell/process-1.6[profile?] )
	>=dev-haskell/refact-0.2:=[profile?]
	>=dev-haskell/syb-0.7.1:=[profile?]
	>=dev-haskell/uniplate-1.6.13:=[profile?]
	>=dev-haskell/unix-compat-0.5.2:=[profile?]
	>=dev-lang/ghc-8.6.5:=
	executable? (
		>=dev-haskell/optparse-applicative-0.15.1.0:=[profile?]
	)
"
DEPEND="${RDEPEND}
	>=dev-haskell/cabal-2.4.0.1
	test? (
		dev-haskell/optparse-applicative
		dev-haskell/silently
		dev-haskell/tasty
		dev-haskell/tasty-expected-failure
		dev-haskell/tasty-golden
	)
"

src_configure() {
	haskell-cabal_src_configure \
		$(cabal_flag executable executable)
}

pkg_postinst() {
	if use executable; then
		elog "The executable installed with this package (normally named 'refactor')"
		elog "has been renamed to 'apply-refactor' to help prevent name collisions."
	fi

	haskell-cabal_pkg_postinst
}