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

pkgbase=libretro-beetle-psx
pkgname=(
  libretro-beetle-psx
  libretro-beetle-psx-hw
)
pkgver=2777
pkgrel=1
pkgdesc='Sony PlayStation core'
arch=(x86_64)
url=https://github.com/libretro/beetle-psx-libretro
license=(GPL2)
groups=(libretro)
depends=(
  libretro-core-info
  zlib
)
makedepends=(
  git
  libglvnd
  mesa
  vulkan-icd-loader
)
_commit=1e42a9076ab1ec5756d3f72e6d61923080fb2128
source=(libretro-beetle-psx::git+https://github.com/libretro/beetle-psx-libretro.git#commit=${_commit})
sha256sums=('51191b8dc6324e67913df499ed31e5aa7f67db90da159391848d001e4f63fda3')

pkgver() {
  cd libretro-beetle-psx

  git rev-list --count HEAD
}

prepare() {
  cp -r libretro-beetle-psx{,-hw}
}

build() {
  make \
    HAVE_LIGHTREC=1 \
    SYSTEM_LIBCHDR=0 \
    SYSTEM_ZLIB=1 \
    -C libretro-beetle-psx
  make \
    HAVE_HW=1 \
    HAVE_LIGHTREC=1 \
    SYSTEM_LIBCHDR=0 \
    SYSTEM_ZLIB=1 \
    -C libretro-beetle-psx-hw
}

package_libretro-beetle-psx() {
  install -Dm 644 libretro-beetle-psx/mednafen_psx_libretro.so -t "${pkgdir}"/usr/lib/libretro/
}

package_libretro-beetle-psx-hw() {
  depends+=(libgl)

  install -Dm 644 libretro-beetle-psx-hw/mednafen_psx_hw_libretro.so -t "${pkgdir}"/usr/lib/libretro/
}

# vim: ts=2 sw=2 et:
