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

github.setup    ihhub fheroes2 1.1.11
github.tarball_from \
                archive

categories      games
maintainers     {@oleg-derevenetz gmail.com:oleg.derevenetz} openmaintainer
license         GPL-2

description     Free implementation of Heroes of Might and Magic II game engine
long_description \
                {*}${description}

homepage        https://ihhub.github.io/fheroes2/

checksums       rmd160  dcabe36ea3f00512a8db3181ebed1ded8d8eb27c \
                sha256  e9a70f4cc831231010354cc599c84b626a18e15de1252bc35e4ced720857236c \
                size    12502123

depends_build-append \
                port:gettext

depends_lib     port:libsdl2 \
                port:libsdl2_mixer \
                port:zlib

depends_run     port:innoextract

patchfiles      patch-readme-txt.diff

compiler.cxx_standard \
                2017
compiler.thread_local_storage \
                yes
compiler.blacklist-append \
                {clang < 900}

# On macOS < 10.15 built-in libc++ has no support for std::filesystem
legacysupport.newest_darwin_requires_legacy \
                18
# GCC can be enforced instead of Clang
if {[string match *clang* ${configure.compiler}]} {
    legacysupport.use_mp_libcxx \
                yes
}

post-destroot {
    copy ${destroot}${prefix}/share/doc/fheroes2/demo/download_demo_version.sh ${destroot}${prefix}/bin/fheroes2-install-demo
    copy ${destroot}${prefix}/share/doc/fheroes2/homm2/extract_homm2_resources.sh ${destroot}${prefix}/bin/fheroes2-extract-resources
}

notes "
You will need to have a demo version or the full version of Heroes of Might and
Magic II game to be able to play.

If you do not have the original Heroes of Might and Magic II game, type the
following command:

fheroes2-install-demo

This script will download and install all the necessary files from the demo
version of the original Heroes of Might and Magic II game.

If you have a legally purchased copy of the original game, type the following
command:

fheroes2-extract-resources

This script will extract all the necessary resource files from the original
Heroes of Might and Magic II game.

As an alternative to the previous step, you can manually copy the subdirectories
'ANIM', 'DATA', 'MAPS' and 'MUSIC' (some of them may be missing depending on the
version of the original game) from the original game directory to the '.fheroes2'
subdirectory of your home directory.

When all prerequisites are in place, you can start the game by typing:

fheroes2

Please visit project website:

${homepage}

and read ${prefix}/share/doc/fheroes2/README.txt for more information.
"
