# Maintainer: Maxime Gauduin <alucryd@archlinux.org>

pkgname=libretro-citra
pkgver=6981
pkgrel=1
pkgdesc='Nintendo 3DS core'
arch=(x86_64)
url=https://github.com/libretro/citra
license=(GPL2)
groups=(libretro)
depends=(
  libretro-core-info
  sdl2
)
makedepends=(
  cmake
  git
  ninja
)
_commit=b1959d07a340bfd9af65ad464fd19eb6799a96ef
source=(
  libretro-citra::git+https://github.com/libretro/citra.git#commit=${_commit}
  citra-boost::git+https://github.com/citra-emu/ext-boost.git
  git+https://github.com/philsquared/Catch.git
  git+https://github.com/zeromq/cppzmq.git
  git+https://github.com/kinetiknz/cubeb.git
  git+https://github.com/discordapp/discord-rpc.git
  git+https://github.com/weidai11/cryptopp.git
  git+https://github.com/MerryMage/dynarmic.git
  git+https://github.com/lsalzman/enet.git
  git+https://github.com/fmtlib/fmt.git
  git+https://github.com/benhoyt/inih.git
  citra-libressl::git+https://github.com/citra-emu/ext-libressl-portable.git
  git+https://github.com/zeromq/libzmq.git
  git+https://github.com/neobrain/nihstro.git
  citra-soundtouch::git+https://github.com/citra-emu/ext-soundtouch.git
  git+https://github.com/herumi/xbyak.git
)
b2sums=(
  SKIP
  SKIP
  SKIP
  SKIP
  SKIP
  SKIP
  SKIP
  SKIP
  SKIP
  SKIP
  SKIP
  SKIP
  SKIP
  SKIP
  SKIP
  SKIP
)

prepare() {
  cd libretro-citra
  for submodule in externals/{catch,cppzmq,cryptopp/cryptopp,cubeb,discord-rpc,dynarmic,enet,fmt,inih/inih,libressl,libzmq,nihstro,xbyak}; do
    git submodule init ${submodule}
    git config submodule.${submodule}.url ../${submodule##*/}
    git submodule update
  done
  for submodule in externals/{boost,soundtouch}; do
    git submodule init ${submodule}
    git config submodule.${submodule}.url ../citra-${submodule##*/}
    git submodule update
  done
}

pkgver() {
  cd libretro-citra
  git rev-list --count HEAD
}

build() {
  cmake -S libretro-citra -B build -G Ninja \
    -DCMAKE_BUILD_TYPE=None \
    -DENABLE_LIBRETRO=ON \
    -DENABLE_QT=OFF \
    -DENABLE_SDL2=ON \
    -DENABLE_WEB_SERVICE=OFF \
    -Wno-dev
  cmake --build build
}

package() {
  install -Dm 644 build/src/citra_libretro/citra_libretro.so -t "${pkgdir}"/usr/lib/libretro/
}

# vim: ts=2 sw=2 et:
