makedepends=(sqlite freetype spatialindex openal libvorbis curl hicolor-icon-theme cmake mesa libjpeg-turbo2 libglvnd xorg-libxi git sdl2-compat)
run=(alsa-plugins libdecor)

description="Luanti (Formerly Minetest) - Multiplayer infinite-world block sandbox game - Client/Server"
url="https://www.luanti.org/"

packager="Great-OS Team"
maintainer="Great-OS Team"

name=luanti
version=5.15.0
release=7

source=(https://github.com/luanti-org/luanti/archive/$version.tar.gz)

build() {
  mkdir build && cd build
  cmake -G Ninja \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DBUILD_CLIENT=1            \
    -DENABLE_GETTEXT=1          \
    -DBUILD_SERVER=0            \
    -DENABLE_LEVELDB=0          \
    -DENABLE_POSTGRESQL=0       \
    -DENABLE_SPATIAL=1          \
    -DENABLE_REDIS=0            \
    -DENABLE_GLES2=1            \
    -DENABLE_OPENGL=1           \
    -DENABLE_WEBGL1=1           \
    ../$name-$version
  ninja
  DESTDIR="$PKG" ninja install

  install -d "${PKG}"/usr/share/luanti
  cp -r $SRC/$name-$version/games $SRC/$name-$version/builtin $SRC/$name-$version/client $SRC/$name-$version/fonts $SRC/$name-$version/textures "${PKG}"/usr/share/luanti/
  cp -r locale "${PKG}"/usr/share/luanti/
  for file in $SRC/$name-$version/doc/{fst_api.txt,lua_api.md,menu_lua_api.md,protocol.txt,world_format.md}; do
    install -Dm644 $file "${PKG}"/usr/share/luanti/doc/$(basename $file)
  done
}
