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

EAPI=8

# ebuild generated by hackport 0.9.0.0.9999
#hackport: flags: -usenativewindowslibraries,buildexamples:examples

CABAL_HACKAGE_REVISION=3
CABAL_PN="GLUT"

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

DESCRIPTION="A binding for the OpenGL Utility Toolkit"
HOMEPAGE="https://www.haskell.org/haskellwiki/Opengl"

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

RDEPEND=">=dev-haskell/opengl-2.12:=[profile?] <dev-haskell/opengl-3.1:=[profile?]
	>=dev-haskell/statevar-1.1:=[profile?] <dev-haskell/statevar-1.3:=[profile?]
	>=dev-lang/ghc-9.0.2:=
	examples? ( >=dev-haskell/openglraw-1.0:=[profile?] <dev-haskell/openglraw-3.4:=[profile?]
			>=dev-haskell/random-1.0:=[profile?] <dev-haskell/random-1.3:=[profile?] )
"
DEPEND="${RDEPEND}
	>=dev-haskell/cabal-3.4.1.0
"

src_prepare() {
	if use examples; then
		export CABAL_CHBINS=()
		example_exes=(
			'BOGLGP01-OnYourOwn1'
			'BOGLGP01-Simple'
			'BOGLGP02-OnYourOwn1.hs'
			'BOGLGP02-OpenGLApplication.hs'
			'BOGLGP03-Lines'
			'BOGLGP03-OnYourOwn1'
			'BOGLGP03-Points'
			'BOGLGP03-Polygons'
			'BOGLGP03-TrianglesQuads'
			'Misc-ARBOcclude'
			'Misc-ColorTriangle'
			'Misc-ExtractContours'
			'Misc-Gears'
			'Misc-Pitfall14'
			'Misc-SmoothOpenGL3'
			'Misc-Triangulate'
			'OrangeBook-Brick'
			'RedBook4-AAIndex'
			'RedBook4-AARGB'
			'RedBook4-AccAnti'
			'RedBook4-AccPersp'
			'RedBook4-Alpha3D'
			'RedBook4-Alpha'
			'RedBook4-BezCurve'
			'RedBook4-BezMesh'
			'RedBook4-BezSurf'
			'RedBook4-BlendEqn'
			'RedBook4-Checker'
			'RedBook4-Clip'
			'RedBook4-ColorMatrix'
			'RedBook4-ColorMat'
			'RedBook4-ColorTable'
			'RedBook4-Combiner'
			'RedBook4-Convolution'
			'RedBook4-CubeMap'
			'RedBook4-Cube'
			'RedBook4-DList'
			'RedBook4-DOF'
			'RedBook4-Double'
			'RedBook4-DrawF'
			'RedBook4-Feedback'
			'RedBook4-FogCoord'
			'RedBook4-FogIndex'
			'RedBook4-Fog'
			'RedBook4-Font'
			'RedBook4-Hello'
			'RedBook4-Histogram'
			'RedBook4-Image'
			'RedBook4-Light'
			'RedBook4-Lines'
			'RedBook4-MVArray'
			'RedBook4-Material'
			'RedBook4-Minmax'
			'RedBook4-Mipmap'
			'RedBook4-Model'
			'RedBook4-MoveLight'
			'RedBook4-MultiTex'
			'RedBook4-Multisamp'
			'RedBook4-PickDepth'
			'RedBook4-PickSquare'
			'RedBook4-Planet'
			'RedBook4-PointP'
			'RedBook4-PolyOff'
			'RedBook4-Polys'
			'RedBook4-Quadric'
			'RedBook4-Robot'
			'RedBook4-Scene'
			'RedBook4-Select'
			'RedBook4-ShadowMap'
			'RedBook4-Smooth'
			'RedBook4-Stencil'
			'RedBook4-Stroke'
			'RedBook4-SurfPoints'
			'RedBook4-Surface'
			'RedBook4-Teapots'
			'RedBook4-TessWind'
			'RedBook4-Tess'
			'RedBook4-TexBind'
			'RedBook4-TexGen'
			'RedBook4-TexProx'
			'RedBook4-TexSub'
			'RedBook4-Texture3D'
			'RedBook4-TextureSurf'
			'RedBook4-Torus'
			'RedBook4-Trim'
			'RedBook4-UnProject'
			'RedBook4-VArray'
			'RedBook4-Wrap'
			'RedBook8-Triangles'
		)

		for e in "${example_exes[@]}"; do
			export CABAL_CHBINS+=("${e}" "haskell-glut-examples-${e}")
		done
	fi

	haskell-cabal_src_prepare
}

src_configure() {
	haskell-cabal_src_configure \
		$(cabal_flag examples buildexamples) \
		--flag=-usenativewindowslibraries
}