SUMMARY="A popular game development module for python"
DESCRIPTION="PyGame - python bindings to sdl and other libs that facilitate \
game production."
HOMEPAGE="https://www.pygame.org/"
COPYRIGHT="2000-2004, 2007 Pete Shinners
	2004 Takafumi Mizuno
	2006-2007 Rene Dudfield
	2007 Richard Goedeken
	2007-2008 Marcus von Appen"
LICENSE="GNU LGPL v2.1"
REVISION="1"
SOURCE_URI="https://files.pythonhosted.org/packages/source/p/pygame/pygame-$portVersion.tar.gz"
CHECKSUM_SHA256="63b038da116a643046181b02173fd894d87d2f85ecfd6aa7d5ece73c6ef501e9"
SOURCE_DIR="pygame-$portVersion"
PATCHES="pygame-$portVersion.patchset"

ARCHITECTURES="all !x86_gcc2 ?x86"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	pygame$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	cmd:cython3$secondaryArchSuffix
	cmd:f2py3
	cmd:python3
	lib:libfreetype$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libSDL_1.2$secondaryArchSuffix
	lib:libSDL_gfx$secondaryArchSuffix
	lib:libSDL_image_1.2$secondaryArchSuffix
	lib:libSDL_mixer_1.2$secondaryArchSuffix
	lib:libSDL_ttf_2.0$secondaryArchSuffix
#	lib:libSDL2_2.0$secondaryArchSuffix
#	lib:libSDL2_gfx_1.0$secondaryArchSuffix
#	lib:libSDL2_image_2.0$secondaryArchSuffix
#	lib:libSDL2_mixer_2.0$secondaryArchSuffix
#	lib:libSDL2_ttf_2.0$secondaryArchSuffix
	lib:libsmpeg_0.4
	"
#	portmidi
#	portmap

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	setuptools_python3
	devel:libfreetype$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libSDL_1.2$secondaryArchSuffix
	devel:libSDL_gfx$secondaryArchSuffix
	devel:libSDL_image_1.2$secondaryArchSuffix
	devel:libSDL_mixer_1.2$secondaryArchSuffix
	devel:libSDL_ttf_2.0$secondaryArchSuffix
#	devel:libSDL2_2.0$secondaryArchSuffix
#	devel:libSDL2_gfx_1.0$secondaryArchSuffix
#	devel:libSDL2_image_2.0$secondaryArchSuffix
#	devel:libSDL2_mixer_2.0$secondaryArchSuffix
#	devel:libSDL2_ttf_2.0$secondaryArchSuffix
	devel:libsmpeg_0.4
	"
BUILD_PREREQUIRES="
	cmd:cython3$secondaryArchSuffix
	cmd:freetype_config$secondaryArchSuffix
	cmd:gcc$secondaryArchSuffix
	cmd:python3
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
#   don't build without features
#	to build against SDL2 remove -sdl1 from the next line
	echo "y" | $portPackageLinksDir/cmd~python3/bin/python3 setup.py build -auto -sdl1 || exit 1
}

INSTALL()
{
	# GENERIC: all python_setuptools-based installs need this
	python=$portPackageLinksDir/cmd~python3/bin/python3
	pythonVersion=$($python --version 2>&1 | sed 's/Python //' | head -c3)
	installLocation=$prefix/lib/python$pythonVersion/vendor-packages/
	export PYTHONPATH=$installLocation:$PYTHONPATH
	mkdir -p $installLocation

	echo "y" | $portPackageLinksDir/cmd~python3/bin/python3 setup.py \
		build install --prefix $prefix || exit 1
}
