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

name                freeciv
github.setup        freeciv freeciv 3_2_7 R
github.tarball_from tarball
version             [string map {_ .} ${version}]
# Note: separate revisions maintained per subport, later in port

categories          games
license             GPL-2+
maintainers         nomaintainer
description         An empire-building strategy game
long_description \
   Freeciv is a Free and Open Source empire-building strategy game inspired \
   by the history of human civilization. The game commences in prehistory \
   and your mission is to lead your tribe from the stone age to the space \
   age...

checksums           rmd160  66ab098065d977a008d1ee74e1b14b74db799669 \
                    sha256  3987f026dc238e9eecc02051b9c68ad697c9e3e2bc7afd9cde5fb735e2e34f69 \
                    size    142405037

depends_build-append \
                    port:gettext \
                    path:bin/pkg-config:pkgconfig

depends_lib-append \
                    port:bzip2 \
                    port:curl \
                    port:gettext-runtime \
                    port:icu \
                    port:imagemagick \
                    port:libiconv \
                    port:lua54 \
                    port:lzma \
                    port:readline \
                    port:sqlite3 \
                    port:xz \
                    port:zlib \
                    port:zstd

compiler.c_standard   2023
compiler.cxx_standard 2020

use_autoreconf      yes
autoreconf.args     -fvi

configure.args-append \
                    --disable-gtktest \
                    --disable-sdltest \
                    --disable-sdl2framework \
                    --disable-sdl2test \
                    --disable-silent-rules \
                    --enable-fcdb=sqlite3 \
                    --with-readline

if {${os.major} > 10} {
    depends_lib-append \
                    port:libsdl2_mixer
    configure.args-append \
                    --enable-sdl-mixer
} else {
    depends_lib-append \
                    port:libsdl_mixer
    configure.args-append \
                    --enable-sdl-mixer=sdl1.2
}

if {${name} eq ${subport}} {
    PortGroup               app 1.1

    revision                0
    platforms               macosx
    conflicts               freeciv-x11

    depends_lib-append      port:freetype

    configure.args-append   --enable-fcmp=cli

    if {${os.major} > 10} {
        # SDL2 support is said to be still experimental, but SDL1
        # doesn't work properly on newer OS versions (window contents
        # are just completely white).
        depends_lib-append \
                            port:libsdl2 \
                            port:libsdl2_gfx \
                            port:libsdl2_image \
                            port:libsdl2_ttf

        configure.args-append \
                            --enable-client=sdl2

        app.executable      freeciv-sdl2
    } else {
        depends_lib-append \
                            port:libsdl \
                            port:libsdl_gfx \
                            port:libsdl_image \
                            port:libsdl_ttf

        configure.args-append \
                            --enable-client=sdl

        app.executable      freeciv-sdl
    }

    app.icon                data/icons/128x128/freeciv-client.png
}

subport freeciv-x11 {
    revision                0
    conflicts               freeciv

    depends_lib-append \
                            path:lib/pkgconfig/gtk4.pc:gtk4

    configure.args-append \
                            --enable-client=gtk4 \
                            --enable-fcmp=gtk4

    livecheck.type          none
}

github.livecheck.regex      {([0-9_]+)}
