# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
# Contributor: josephgbr <rafael.f.f1@gmail.com>
# Contributor: vEX <vex@niechift.com>

pkgname=pcsx2
pkgver=1.7.0.r1709.9832a935d
pkgrel=1
pkgdesc='A Sony PlayStation 2 emulator'
arch=(x86_64)
url=https://www.pcsx2.net
license=(
  GPL2
  GPL3
  LGPL2.1
  LGPL3
)
depends=(
  gdk-pixbuf2
  glibc
  libaio
  libasound.so
  libfmt.so
  libfreetype.so
  libgdk-3.so
  libgio-2.0.so
  libgl
  libGLEW.so
  libglib-2.0.so
  libgobject-2.0.so
  libgtk-3.so
  libpcap
  libpng
  libportaudio.so
  libpulse.so
  libudev.so
  libx11
  libxcb
  libxml2
  sdl2
  soundtouch
  wxgtk3
  wxgtk-common
  xz
  zlib
)
makedepends=(
  cmake
  git
  ninja
  png++
)
_commit=9832a935d7416fb06efe78922b55417a39949ae1
source=(
  git+https://github.com/PCSX2/pcsx2.git#commit=${_commit}
  git+https://github.com/rtissera/libchdr.git
  git+https://github.com/jbeder/yaml-cpp.git
)
b2sums=(
  SKIP
  SKIP
  SKIP
)

prepare() {
  cd pcsx2/3rdparty
  for submodule in libchdr/libchdr yaml-cpp/yaml-cpp; do
    git submodule init ${submodule}
    git config submodule.${submodule}.url ../../${submodule#*/}
    git submodule update ${submodule}
  done
}

pkgver() {
  cd pcsx2

  git describe --tags | sed 's/^v//; s/-dev//; s/-/.r/; s/-g/./'
}

build() {
  cmake -S pcsx2 -B build -G Ninja \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DDISABLE_ADVANCE_SIMD=ON \
    -DDISABLE_BUILD_DATE=ON \
    -DDISABLE_PCSX2_WRAPPER=ON \
    -DENABLE_TESTS=OFF \
    -DSDL2_API=ON \
    -DPACKAGE_MODE=ON \
    -DREBUILD_SHADER=ON \
    -DUSE_LTO=OFF \
    -DUSE_SYSTEM_YAML=OFF \
    -DUSE_VTUNE=OFF \
    -DXDG_STD=ON \
    -DwxWidgets_CONFIG_EXECUTABLE=/usr/bin/wx-config-gtk3 \
    -Wno-dev
  ninja -C build
}

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

# vim: ts=2 sw=2 et:
