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

github.setup        angband angband 4.2.5
github.tarball_from archive
checksums           rmd160  3c667f7b154d0b510083ceb66e809bf68809238e \
                    sha256  2a27ce296310c4cbf960e2eb41ef55d383e546f24533446cf224119498a99651 \
                    size    25801900

categories          games
license             Noncommercial

maintainers         nomaintainer

description         a rogue-like dungeon exploration game (curses-based)
long_description    Angband is a freeware computer dungeon exploration game \
based (loosely) on the books of J.R.R.Tolkien. You explore a very deep \
dungeon, kill monsters, try to equip yourself with the best weapons and \
armor you can find, and finally face Morgoth - The Dark Enemy.

homepage            https://rephial.org/

patchfiles-append   patch-makefile-osx.diff

notes "
If you receive the error 'Angband requires UTF-8 support', you need to set\
LANG to a valid UTF-8 language such as:

export LANG=en_US.UTF-8
"

variant x11 conflicts aqua {
    depends_lib-append      port:ncurses \
                            port:xorg-libXaw

    configure.args-replace  --without-x --with-x
}

if {${os.platform} ne "darwin"} {
    default_variants +x11
}

platform darwin {
    variant aqua conflicts x11 description {Build the Cocoa front-end} {
        use_configure       no

        build.dir           ${worksrcpath}/src
        build.args          -f Makefile.osx \
                            ARCHS="[get_canonical_archs]" \
                            CC="${configure.cc}" \
                            OPT="${configure.optflags}" \
                            VERSION="${version}"

        destroot.keepdirs   ${destroot}${applications_dir}/Angband.app/Contents/Resources/lib/info
        destroot {
            copy ${worksrcpath}/Angband.app ${destroot}${applications_dir}
        }
    }

    if {![variant_isset x11]} {
        default_variants +aqua
    }
}

if {![variant_exists aqua] || ![variant_isset aqua]} {
    depends_build-append \
                    port:autoconf \
                    port:automake \
                    port:libtool

    post-patch {
        addgroup games
    }

    use_autoreconf  yes
    autoreconf.cmd  ./autogen.sh

    configure.args-append \
                    --bindir=${prefix}/bin \
                    --with-setgid=games \
                    --without-x
}

livecheck.url       ${homepage}
livecheck.regex     ${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}
