PortSystem              1.0
PortGroup               app 1.0

name                    2Pong
version                 1.0.1a
categories              games
platforms               darwin
maintainers             nomaintainer
license                 GPL-2
installs_libs           no

description             Pong game with 2 balls, 2 and 4 player support
long_description        ${description}

homepage                http://twopong.sourceforge.net/
master_sites            sourceforge:project/twopong/2Pong/2Pong-${version}
distname                2pong-src-${version}
worksrcdir              2Pong-Source

checksums               rmd160  43e0cde2485a3b89a4009db80118dda4a14aa82c \
                        sha256  4075bf686126f785e10f3ff9dcaa7febc05291ad6ddf7a84bf2dd2890382a87b

depends_lib             port:libsdl \
                        port:libsdl_net \
                        port:libsdl_mixer \
                        port:libiconv \
                        port:zlib \
                        port:libxml2

if {${os.platform} eq "darwin" && ${os.major} >= 18} {
    # Builds but fails to run on 10.14+
    # "Unable to obtain graphics context for NSWindow (Mojave behavior)"
    pre-fetch {
        return -code error "$name does not work on macOS 10.14 and later"
    }
    known_fail  yes
}

post-extract {
    copy ${filespath}/${name}.in ${workpath}/${name}
}

patchfiles              patch-Makefile.diff \
                        patch-defs.h.diff \
                        net.cpp.diff

post-patch {
    reinplace "s|@PREFIX@|${prefix}|g" ${workpath}/${name}
}

use_configure           no

variant universal {}

build.dir               ${worksrcpath}/src
build.args              CC="${configure.cc} [get_canonical_archflags]" \
                        CPPFLAGS="${configure.cppflags}" \
                        CXX="${configure.cxx} [get_canonical_archflags]" \
                        LINK="${configure.cxx} [get_canonical_archflags]"

destroot {
    xinstall ${workpath}/${name} ${destroot}${prefix}/bin
    xinstall -d ${destroot}${prefix}/share/${name}/src ${destroot}${prefix}/libexec/${name}
    xinstall ${worksrcpath}/2pong ${destroot}${prefix}/libexec/${name}/${name}
    copy ${worksrcpath}/conf.xml ${destroot}${prefix}/share/${name}
    copy ${worksrcpath}/src/data ${destroot}${prefix}/share/${name}/src
}

app.icon                src/icon.bmp

livecheck.regex         /2pong-src-(\[0-9a-z.\]+)${extract.suffix}
