# -*- 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.0.3
categories-append     devel multimedia graphics
platforms       darwin
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        http://www.pygame.org/

python.rootname pygame
checksums       md5 04e082d216b3b771b8d52769597b2fb2 \
                rmd160 03970781db89e80b3378119247e6e1ea7b69924a \
                sha256 d097f2802a9d0d7fb40c49c789af2984b202baa8fd32701082598755f5973f51

python.versions 27 35 36 37 38 39 310

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

    depends_build   port: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
    }

    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]} {
        depends_lib-append  port:libsdl2_mixer \
                            port:libsdl2_image \
                            port:libsdl2_ttf
    } else {
        configure.args-append   -sdl1
        depends_lib-append  port:libsdl_mixer \
                            port:libsdl_image \
                            port:libsdl_ttf
    }

    livecheck.type  none
}
