# -*- 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                frotz
version             2.55
categories          games
maintainers         nomaintainer
license             GPL-2+

description         interpreter for Infocom Z-Code games
long_description    Frotz provides a portable implementation of the zcode \
    virtual machine used for all Infocom text adventures and many of those \
    written by other authors.
homepage            https://davidgriffith.gitlab.io/frotz/
master_sites        http://www.ifarchive.org/if-archive/infocom/interpreters/frotz/

checksums           rmd160 a2c4210175d26098fe8f07fcf7c61eaf41fa7839 \
                    sha256 e3d6912ff94bca724759fe59aa222c1ee23aa4d35ffa15a0b40f72f97887d871 \
                    size   445102

depends_build       path:bin/pkg-config:pkgconfig
patchfiles          Makefile.patch

use_configure       no

variant universal   {}

build.env           PREFIX=${prefix} \
                    SYSCONFDIR=${prefix}/etc \
                    CC=${configure.cc} \
                    CFLAGS=[get_canonical_archflags cc] \
                    NO_UCONTEXT_H=1

if {${os.platform} eq "darwin" && ${os.major} <= 10} {
    build.env-append    NO_STRNDUP=yes
}

if {$subport eq $name} {
    long_description-append This port installs Frotz with a \
                            curses-based text interface.
    depends_lib     port:ncurses
    build.target    curses
    variant sound description {Enable sound support} {
        depends_lib-append  port:libao \
                            port:libmodplug \
                            port:libsamplerate \
                            port:libsndfile \
                            port:libvorbis
    }
    default_variants    +sound
    if {![variant_isset sound]} {
        build.env-append    SOUND_TYPE=none
    }
}

subport frotz-sdl {
    description-append (SDL GUI)
    long_description-append This port installs Frotz with an \
                            SDL-based GUI.
    depends_lib-append  port:freetype \
                        path:include/turbojpeg.h:libjpeg-turbo \
                        port:libpng \
                        port:libsdl2 \
                        port:libsdl2_mixer \
                        port:zlib
    patchfiles-append   sdl_Makefile.patch
    build.target    sdl
    destroot.target install-sdl
}

destroot.env        {*}${build.env}
post-destroot {
    xinstall -d ${destroot}${prefix}/share/doc/${subport}
    xinstall -W ${worksrcpath} -m 644 AUTHORS CONTRIBUTORS COPYING \
        ChangeLog HOW_TO_PLAY README \
        ${destroot}${prefix}/share/doc/${subport}
}

livecheck.regex [string cat ${name}- {([\d.]+)} [quotemeta ${extract.suffix}]]
