# -*- 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           github 1.0
PortGroup           openssl 1.0

github.setup        luanti-org luanti 5.15.2
github.tarball_from archive
revision            0

checksums           rmd160  7fa900016e3bac0b27dd1d4b59240e8de50c86bd \
                    sha256  1fdfa8b973968f8fcf5a264ce3fb3a170c3882105f953498a64d6415eff83471 \
                    size    12332073

compiler.cxx_standard 2017
compiler.thread_local_storage yes

categories          games
license             LGPL-2.1+
maintainers         {@fvhovell gmail.com:triggered} openmaintainer

description         open source infinite-world block sandbox game with survival and crafting
long_description    {*}${description} - Find more Luanti mods at <https://content.luanti.org/> and have fun.

homepage            https://www.luanti.org

depends_build-append \
                    path:bin/doxygen:doxygen \
                    port:gettext

depends_lib-append  port:curl \
                    port:freetype \
                    port:gettext-runtime \
                    port:gmp \
                    port:jsoncpp \
                    path:include/turbojpeg.h:libjpeg-turbo \
                    port:libogg \
                    port:libpng \
                    port:libiconv \
                    port:libvorbis \
                    path:lib/libluajit-5.1.dylib:luajit \
                    port:libsdl2 \
                    port:leveldb \
                    port:ncurses \
                    port:spatialindex \
                    port:sqlite3 \
                    port:xorg-libX11 \
                    port:xorg-libXxf86vm \
                    port:zlib \
                    port:zstd

conflicts           irrlichtmt

universal_variant   no
supported_archs     arm64 i386 x86_64

# 001. the original build calls fixup_bundle to move all the deps into the app bundle.
#      this doesn't work correctly with MacPorts' destrooting and isn't necessary
patchfiles-append   001-patch-src-CMakeLists-disable-bundlefixup.diff

# 002. patch to get the luajit include headers ahead of the system includes, or the build finds the
#      wrong lua headers if you have a newer version of lua installed
patchfiles-append   002-patch-cmake-Modules-FindLua-include-LUADIR-before-system.diff

cmake.build_type    Release
cmake.install_prefix ${applications_dir}

configure.args-append \
                    -DCMAKE_FIND_FRAMEWORK=FIRST \
                    -DBUILD_UNITTESTS=OFF \
                    -DENABLE_UPDATE_CHECKER=OFF \
                    -DBUILD_CLIENT=ON \
                    -DBUILD_SERVER=ON \
                    -DENABLE_SOUND=ON \
                    -DUSE_SDL2=ON \
                    -DENABLE_GLES2=OFF \
                    -DENABLE_OPENGL=ON \
                    -DENABLE_OPENGL3=ON \
                    -DENABLE_REDIS=OFF \
                    -DENABLE_POSTGRESQL=OFF \
                    -DENABLE_LEVELDB=ON \
                    -DENABLE_CURL=ON \
                    -DENABLE_GETTEXT=ON \
                    -DENABLE_SPATIAL=ON \
                    -DENABLE_SYSTEM_GMP=ON \
                    -DENABLE_SYSTEM_JSONCPP=ON \
                    -DENABLE_LUAJIT=ON \
                    -DINSTALL_DEVTEST=ON \
                    -DVERSION_EXTRA=MacPorts-rev${revision}
