# -*- 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           app 1.0

name                ship84
version             1.3.3.7
revision            2
categories          games
platforms           darwin
maintainers         nomaintainer
license             GPL-2+
installs_libs       no

# Compiles ok for x86_64 but crashes on launch after showing main window
supported_archs     i386 ppc

description         space invaders clone using SDL

long_description    The Angryfez Army and their minions have pointed the \
                    ultimate battle at earth! Only Happyfez can save the \
                    day!

homepage            http://sourceforge.net/projects/ship84/
master_sites        sourceforge:project/ship84/Shippy1984%20UNIX/Shippy1984%20v${version}

distname            shipv${version}UNIX
use_zip             yes

checksums           md5     06df2ae060fe4a076d7fa17a57205348

depends_lib         port:libsdl \
                    port:libsdl_mixer

extract.mkdir       yes

post-extract {
    # DOS to UNIX line endings so we can patch properly.
    fs-traverse file ${worksrcpath} {
        switch [file extension ${file}] {
            .c -
            .h -
            .txt {
                reinplace "s|\r||g" ${file}
            }
        }
    }
}

patchfiles          patch-GNUmakefile.diff \
                    patch-shipsdl.c.diff \
                    patch-shippy.c.diff

post-patch {
    reinplace "s|data/|${prefix}/share/games/${name}/|g" \
        ${worksrcpath}/shipall.c \
        ${worksrcpath}/shippy.c \
        ${worksrcpath}/shipsdl.c
}

use_configure       no

variant universal {}

build.args          CC="${configure.cc} [get_canonical_archflags]"

destroot {
    xinstall -m 755 -d ${destroot}${prefix}/bin \
        ${destroot}${prefix}/share/games
    xinstall -m 755 -s ${worksrcpath}/shippy ${destroot}${prefix}/bin
    file copy ${worksrcpath}/data ${destroot}${prefix}/share/games/${name}
}

app.name            Shippy1984
app.executable      shippy
app.identifier      net.sourceforge.ship84.Shippy1984

livecheck.type      sourceforge
livecheck.regex     /shipv(\[0-9.\]+)UNIX${extract.suffix}
