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

name                rogue
version             5.4.4
revision            4
categories          games
maintainers         nomaintainer
license             BSD

description         Rogue is a popular dungeon exploring adventure game

long_description    Rogue is a popular dungeon exploring adventure game. It is \
                    one of the earliest (early 1980s) dungeon crawl games, and \
                    is an ancestor of games like Diablo. Version 5.4 is the \
                    last iteration of the original Rogue by Toy, Arnold, and \
                    Wichman developed for UNIX.

homepage            http://rogue.rogueforge.net
master_sites        ${homepage}/files/rogue5.4/

checksums           sha256  7d37a61fc098bda0e6fac30799da347294067e8e079e4b40d6c781468e08e8a1 \
                    rmd160  5988b9425c2ba42e82d8d8f961001378554032f6 \
                    size    209839


distname            ${name}${version}-src

worksrcdir          ${name}${version}

depends_lib-append  port:ncurses

patch.pre_args-replace  -p0 -p1
patchfiles          ncurses-compat-fix.patch

configure.args-append       --with-ncurses
configure.cflags-append     -I${prefix}/include/ncurses
configure.cppflags-append   -I${prefix}/include/ncurses
build.env-append            LDFLAGS=-L${prefix}/lib

variant singleuser description {Disables system-wide scoreboards and allows local user installation without root privileges} {}

pre-configure {
    if {![variant_isset singleuser]} {
        addgroup games
    }
}

post-configure {
    reinplace "s|rogue.scr|${prefix}/var/games/rogue/rogue.scr|" ${worksrcpath}/config.h
    reinplace "s|rogue.lck|${prefix}/var/games/rogue/rogue.lck|" ${worksrcpath}/config.h
    file delete ${workpath}/.CC_PRINT_OPTIONS
}

build.target
build.cmd           make

destroot.keepdirs   ${destroot}${prefix}/var/games/rogue
destroot {
    if {![variant_isset singleuser]} {
        xinstall -m 2755 -g games ${worksrcpath}/rogue ${destroot}${prefix}/bin/
        xinstall -m 775 -g games -d ${destroot}${prefix}/var/games/rogue
    } else {
        xinstall -m 755 ${worksrcpath}/rogue ${destroot}${prefix}/bin/
        xinstall -m 775 -d ${destroot}${prefix}/var/games/rogue
    }

    xinstall -m 644 ${worksrcpath}/rogue.6 ${destroot}${prefix}/share/man/man6/

    set docdir ${prefix}/share/doc/${subport}
    xinstall -d ${destroot}${docdir}
    xinstall -m 644 -W ${worksrcpath} LICENSE.TXT rogue.cat rogue.doc rogue.html rogue.me ${destroot}${docdir}
}

livecheck.url       ${homepage}/rogue-5-4/
livecheck.regex     ${name}(\[0-9.]\+)-src[quotemeta ${extract.suffix}]