# -*- Mode: Tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:et:sw=4:ts=4:sts=4

PortSystem          1.0

name                freeciv
version             2.6.4
set branch          [join [lrange [split ${version} .] 0 1] .]
categories          games
maintainers         nomaintainer
license             GPL-2+
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...

homepage            http://www.freeciv.org/
master_sites        sourceforge:project/${name}/Freeciv%20${branch}/${version}/ \
                    http://files.freeciv.org/stable/
use_bzip2           yes

checksums           rmd160  3e2b953892f009dfe7786e4a9b4ca0e1a1150095 \
                    sha256  40db957766acbd49c5af15afd1711da996b6681be7abee3352c5f2539c10c1ce \
                    size    52087948

depends_build       port:pkgconfig

depends_lib         port:bzip2 \
                    port:curl \
                    port:gettext \
                    port:libiconv \
                    port:readline \
                    port:sqlite3 \
                    port:xz \
                    port:zlib

patchfiles          utility_randseed.c.patch

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

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}} {
    revision                0
    conflicts               freeciv-x11

    platforms               macosx

    depends_lib-append      port:freetype

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

    PortGroup               app 1.0

    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

    livecheck.type          regex
    livecheck.url           http://www.freeciv.org/download.html
    livecheck.regex         ${name}-(\[0-9.\]+)${extract.suffix}
} else {
    livecheck.type          none
}

subport freeciv-x11 {
    revision                0
    conflicts               freeciv

    platforms               darwin

    depends_lib-append      path:lib/pkgconfig/gtk+-2.0.pc:gtk2

    configure.args-append   --enable-client=gtk2 \
                            --enable-fcmp=gtk2
}
