# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem      1.0
PortGroup       python 1.0

name            py-game
version         2.6.1
categories-append     devel multimedia graphics
license         LGPL-2.1+
maintainers     {jmr @jmroot} openmaintainer
description     pygame, python modules for writing games
long_description    Pygame is a set of Python modules designed for \
            writing games. It is written on top of the excellent \
            SDL library. This allows you to create fully featured \
            games and multimedia programs in the python language. \
            Pygame is highly portable and runs on nearly every \
            platform and operating system.
homepage        https://www.pygame.org/

python.rootname pygame
checksums       md5 cb6bf42a449b0bb1f53c534bcbcc220c \
                rmd160 7edb3cc722a0399eedb9f8e33d7d4b813033d57d \
                sha256 56fb02ead529cee00d415c3e007f75e0780c655909aaa8e8bf616ee09c9feb1f

python.versions 27 310 311 312 313 314

if {$subport ne $name} {
    patchfiles  patch-config_darwin.py.diff \
                patch-disable_portmidi.diff

    depends_build   path:bin/pkg-config:pkgconfig \
                    port:py${python.version}-setuptools
    depends_lib port:py${python.version}-numpy \
                path:include/turbojpeg.h:libjpeg-turbo \
                port:libpng

    use_configure   yes
    configure.env-append LOCALBASE=${prefix}
    configure.cmd   ${python.bin} setup.py
    configure.args  -config

    post-destroot   {
        copy {*}[glob ${worksrcpath}/docs/*] ${destroot}${prefix}/share/doc/${subport}
        xinstall -m 644 -W ${worksrcpath} README.rst \
            ${destroot}${prefix}/share/doc/${subport}
    }

    variant portmidi description {Enable MIDI support using portmidi} {
        depends_lib-append port:portmidi
        patchfiles-delete patch-disable_portmidi.diff
    }

    if {${python.version} == 27} {
        version     2.0.3
        revision    0
        checksums   md5 04e082d216b3b771b8d52769597b2fb2 \
                    rmd160 03970781db89e80b3378119247e6e1ea7b69924a \
                    sha256 d097f2802a9d0d7fb40c49c789af2984b202baa8fd32701082598755f5973f51

        patchfiles-replace  patch-config_darwin.py.diff \
                            patch-config_darwin.py-27.diff

        variant sdl2 description {Use SDL 2} {
            configure.args-append   -sdl2
        }

        if {!(${os.platform} eq "darwin" && ${os.major} <= 10)} {
            default_variants    +sdl2
        }

        if {![variant_isset sdl2]} {
            configure.args-append   -sdl1
            depends_lib-append  port:libsdl_mixer \
                                port:libsdl_image \
                                port:libsdl_ttf
        }
    }
    if {${python.version} != 27 || [variant_isset sdl2]} {
        depends_lib-append  port:libsdl2_mixer \
                            port:libsdl2_image \
                            port:libsdl2_ttf
    }

    livecheck.type  none
}
