# Maintainer (arch): Sven-Hendrik Haase <svenstaro@archlinux.org>
# Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>
# Contributor: Márcio Silva <coadde@hyperbola.info>

# parabola changes and rationale:
#  - not building ogre-docs
#  - removed nonfree samples and tests
#  - removed nonfree files and references
#  - added imgui.tar.gz to sources instead of downloading at build time

pkgname=ogre
pkgver=13.2.4
pkgrel=1
pkgrel+=.parabola1
pkgdesc='Scene-oriented, flexible 3D engine written in C++'
pkgdesc+=', without nonfree software support and files'
arch=('x86_64')
arch+=('i686' 'armv7h')
url='http://www.ogre3d.org'
license=('custom:MIT')
depends=('freeimage' 'freetype2' 'libxaw' 'libxrandr' 'sdl2' 'glu' 'pugixml' 'zlib')
makedepends=('cmake' 'doxygen' 'graphviz' 'ttf-dejavu' 'mesa' 'python' 'ninja' 'cppunit')
install=ogre.install
source=("$pkgname-$pkgver.tar.gz::https://github.com/OGRECave/ogre/archive/v${pkgver}.tar.gz")
source+=("imgui-1.85.tar.gz::https://github.com/ocornut/imgui/archive/v1.85.tar.gz"
         libre.patch)
sha512sums=('6a07f919fb050d6863fcb2b6ab7aea54b279a1cc98377a5b8c9d773c74d7126a78ce0c23c1c4f62ef6a64bad5b2f039a15aa06ec4bcf06c232d0e9e466d82407'
            '830ff36681a661d77754fb7818bb13cc63da58a293d343a8d6847a586f00c6e0bfc3ffe51cdf882849e5083d4ddca52cdbdc1b3abc9b794a96f89ae7628f1fc2'
            '62e5f660a127f02d0a41852f426d52ea14d1043781b4b1b7390f2e424c57a88e75716615731cb9176dce6e6932e9646561425bd06a6833ce4c582e23b8d7ff59')

prepare() {
  cd ogre-${pkgver}

  # install imgui to build dir
  mkdir -p build
  cp -r "$srcdir"/imgui-1.85 build/

  # remove nonfree references
  patch -Np1 -i $srcdir/libre.patch
}

build() {
  cd ogre-${pkgver}

  cmake \
    -Bbuild \
    -GNinja \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DOGRE_BUILD_TESTS=OFF \
    -DOGRE_BUILD_DEPENDENCIES=OFF \
    -DOGRE_INSTALL_SAMPLES=OFF \
    -DOGRE_INSTALL_DOCS=OFF \
    -DOGRE_INSTALL_SAMPLES_SOURCE=OFF \
    -DOGRE_BUILD_RENDERSYSTEM_GL=OFF \
    -DOGRE_BUILD_RENDERSYSTEM_GLES=OFF \
    -DOGRE_BUILD_RENDERSYSTEM_GLES2=OFF \
    -DOGRE_BUILD_SAMPLES=OFF

  ninja -C build
}

package() {
  cd ogre-${pkgver}

  DESTDIR="${pkgdir}" ninja -C build install

  install -Dm644 LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}

# vim:set ts=2 sw=2 et:
