# -*- Mode: Tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:et:sw=4:ts=4:sts=4

PortSystem                   1.0
PortGroup           github   1.0
PortGroup           makefile 1.0
PortGroup           boost    1.0

github.setup        fph bastet 1b3e6922c1f7d72e87640ea4a58a52e1d36f01e1
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
version             0.43.2
revision            2
categories          games
maintainers         {ryandesign @ryandesign} openmaintainer
license             GPL-3+

description         Bastard Tetris is an antagonistic Tetris clone
long_description \
  Bastet stands for bastard tetris, and is a Tetris(R) \
  clone which, instead of choosing your next brick at \
  random, expressly checks to see which one causes you \
  the most trouble. Playing Bastet can be a painful \
  experience.

homepage            http://fph.altervista.org/prog/bastet.html

checksums           rmd160  9744b8efe4786c0e448ccb4b5e1a93b95778670c \
                    sha256  e5f89dce9cef664f3ceabff6214b3d4a3e371273fadbba108d155faa2341ad57 \
                    size    87496

depends_lib-append  port:ncurses

set scoredir        ${prefix}/var/games/${name}
set scorefile       ${scoredir}/bastet.scores2

post-patch {
    reinplace "s|/var/games|${scoredir}|g" ${worksrcpath}/bastet.6 ${worksrcpath}/Config.cpp
}

use_configure       no

if {[string match *clang* ${configure.cxx}] && ${configure.cxx_stdlib} ne ""} {
    configure.ldflags-append -stdlib=${configure.cxx_stdlib}
}

variant universal {}
pre-build {
    build.env-append BOOST_PO=-lboost_program_options-mt
}

destroot.keepdirs   ${scoredir}

destroot {
  xinstall -m 755 ${worksrcpath}/bastet ${destroot}${prefix}/bin/

    set docdir ${prefix}/share/doc/${subport}
    xinstall -m 755 -d ${destroot}${docdir}
    xinstall -m 644 -W ${worksrcpath} AUTHORS LICENSE NEWS README \
        ${destroot}${docdir}
}

post-activate {
    if {![file exists ${scorefile}]} {
        touch ${scorefile}
        file attributes ${scorefile} -permissions 0666
    }
    # Fix incorrect permissions set by previous versions of this port.
    if {[file attributes ${scorefile} -permissions] == 666} {
        file attributes ${scorefile} -permissions 0666
    }
}
