PortSystem          1.0

name                scummvm
platforms           darwin
categories          emulators games
maintainers         {kencu @kencu} openmaintainer
license             {GPL-2 BSD}
description         cross-platform interpreter for several adventure engines
long_description    \
    ScummVM is a cross-platform interpreter for several point-and-click \
    adventure engines. A current list of playable games is available at \
    <https://www.scummvm.org/compatibility/>.

homepage            https://scummvm.org/

subport             ${name}-devel {}

if {${subport} eq ${name}} {

    # release
    conflicts           ${name}-devel
    long_description ${description}: \
        This port follows the release version of ${name}, which is typically updated every \
        6 months. If for some reason this port does not build or function as desired, try \
        the ${name}-devel port.

    version             2.0.0
    revision            4
    master_sites        http://scummvm.org/frs/${name}/${version}
    use_bzip2           yes
    checksums           sha256  46482e9f4eccd8590a86c70b024bdd0b319af8cbe8b7abaef592a9c52abbe1dc \
                        rmd160  669f1e8c342e874d2478593898cb6840531eff01

    livecheck.url       https://github.com/scummvm/scummvm/releases
    livecheck.regex     v(\[0-9.\]+).tar.gz

} else {

    # devel
    conflicts           ${name}
    long_description ${description}: \
        This port follows the master version of ${name}, which is typically updated every few weeks.

    PortGroup           github 1.0
    github.setup        scummvm scummvm 0a9ad229a89a04b2fe437597584684f43479ca14
    version             20190122
    revision            1
    checksums           rmd160  b4cf1bcca4163092e87a77efdb052f0ea5dbacf8 \
                        sha256  7d75f4adaa5f2d7ccd4afb2cdb3f764034c09cb0bfdbbbcda6fb7f3edc257676 \
                        size    37817083
                        
    livecheck.type      none

}

patchfiles-append   patch-scummvm-sdl2indet.diff

depends_lib-append  port:libsdl2 \
                    port:libsdl2_net \
                    port:libmad \
                    port:libogg \
                    port:libvorbis \
                    port:libpng \
                    port:flac \
                    port:libtheora \
                    port:fluidsynth \
                    port:faad2 \
                    port:jpeg \
                    port:freetype \
                    port:bzip2 \
                    port:curl \
                    port:expat \
                    port:gettext \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:libedit \
                    port:libffi \
                    port:libiconv \
                    port:libsndfile \
                    port:ncurses \
                    port:pcre \
                    port:portaudio \
                    port:readline \
                    port:zlib

configure.args-append  \
                    --enable-release \
                    --enable-plugins \
                    --default-dynamic \
                    --enable-sdlnet \
                    --enable-cloud \
                    --enable-libcurl \
                    --enable-theoradec \
                    --enable-jpeg \
                    --enable-readline \
                    --enable-all-engines \
                    --enable-verbose-build

if {${subport} eq "${name}-devel"} {
    # disable this engine, which doesn't build on macOS as of 20190122
    configure.args-append  \
                     --disable-engine=glk
}

# libcurl needs --enable-cloud as well otherwise link errors
# also connected to --enable-sdlnet

variant cxx11 description {build with c++11} {
     # scummvm builds fine without c++11
     # I'm not sure if there is any advantage to enabling c++11 support at present
     # but keep it here as a variant in case someone finds there is
     PortGroup cxx11 1.1
     configure.args-append \
                    --enable-c++11
}

variant mpeg2 description {add mpeg2 support - has many dependencies} {
     # this builds fine, but libmpeg2 is old (2008) and pulls in a lot of deps
     # and I'm not sure if any games actually use this - make it optional
     configure.args-append \
                    --enable-mpeg2
     depends_lib-append    \
                    port:libmpeg2 \
                    port:db48 \
                    port:libsdl \
                    port:libxml2 \
                    path:lib/libssl.dylib:openssl \
                    port:python27 \
                    port:python2_select \
                    port:python_select \
                    port:sqlite3 \
                    port:xorg-xorgproto \
                    port:xorg-libX11 \
                    port:xorg-libXau \
                    port:xorg-libXdmcp \
                    port:xorg-libXext \
                    port:xorg-libXrandr \
                    port:xorg-libXv \
                    port:xorg-libice \
                    port:xorg-libpthread-stubs \
                    port:xorg-libsm \
                    port:xorg-libxcb \
                    port:xorg-xcb-proto \
                    port:xrender \
                    port:xz

}