# -*- 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           cmake 1.1
PortGroup           boost 1.0
PortGroup           github 1.0
PortGroup           app 1.0

cmake.build_type    Release

name                widelands
categories          games
platforms           {darwin != 11.*}
maintainers         nomaintainer
license             GPL-2+
homepage            https://widelands.org/
description         open-source real-time strategy game inspired by Settlers

# https://trac.macports.org/ticket/61029
depends_build-append port:cctools

depends_lib         port:libsdl2 \
                    port:libsdl2_image \
                    port:libsdl2_mixer \
                    port:libsdl2_ttf \
                    path:bin/doxygen:doxygen \
                    port:gettext \
                    path:lib/pkgconfig/icu-uc.pc:icu \
                    port:libpng \
                    port:glew \
                    port:lua \
                    port:asio \
                    port:zlib

subport             ${name}-devel {}

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

    # release
    github.setup        widelands widelands 1.2.1 v
    revision            1
    checksums           rmd160  b30a8587648903edf58ccc5df869630f3c320ab2 \
                        sha256  f80c2c967f87607d8600360df0aeca2ae8496f6ffb9e15f63026fc2aacb49913 \
                        size    457855557
    conflicts           ${name}-devel

    long_description ${description}: \
        Widelands is a real-time strategy game with singleplayer campaigns and a multiplayer mode. The game was inspired by Settlers II™ (© Bluebyte) but has significantly more variety and depth to it.
} else {

    # devel
    github.setup        widelands widelands 91330ae84c4851c109b2f4007b0059dccffb7754
    version             20241214
    revision            1
    checksums           rmd160  ad3f1445e0e8892f4a9407e31abfb7439192ad2d \
                        sha256  104853a41118e98bc06f5613a467f8442bd558bf8ff107f5644e85ce994a8a26 \
                        size    456938874

    conflicts           ${name}

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

# ensure mesa isn't picked up by the build
patchfiles          patch-fix-opengl.diff

compiler.cxx_standard   2017

# use the opengl framework over mesa
configure.pre_args-delete   -DCMAKE_FIND_FRAMEWORK=LAST

configure.args-append   -DCMAKE_INSTALL_PREFIX:PATH="${applications_dir}/Widelands.app/Contents/MacOS" \
                        -DWL_INSTALL_DATADIR:PATH="${applications_dir}/Widelands.app/Contents/Resources"

# Note that case-sensitive filesystems may end up with an extra copy
# of the widelands binary (widelands and Widelands). But it's only 12MB
# out 1GB of installed files.
app.name            Widelands
app.icon            ${worksrcpath}/data/images/logos/widelands.icns
app.identifier      org.widelands.wl
app.executable      ${workpath}/build/src/widelands
