# Maintainer: Jaroslav Lichtblau <svetlemodry@archlinux.org>
# Contributor: m0rph <m0rph.mailbox@gmail.com>

pkgname=goldendict
pkgver=1.5.0RC2
pkgrel=9
pkgdesc="Feature-rich dictionary lookup program"
arch=('x86_64')
url="http://goldendict.org"
license=('GPL3')
depends=('hunspell' 'libxtst' 'libzip' 'libao' 'qt5-webkit' 'qt5-svg'
         'qt5-x11extras' 'qt5-tools' 'phonon-qt5' 'ffmpeg')
provides=('stardict')
changelog=$pkgname.changelog
source=($pkgname-$pkgver.tar.gz::https://github.com/$pkgname/$pkgname/archive/1.5.0-RC2.tar.gz
        goldendict-qt-5.11-1.patch::"https://github.com/goldendict/goldendict/commit/3d4a468b.patch"
        goldendict-qt-5.11-2.patch::"https://github.com/goldendict/goldendict/commit/a6596780.patch"
        goldendict-ffmpeg4.patch::"https://github.com/goldendict/goldendict/commit/03bbe01b.patch")
sha256sums=('bccee0a3d3902f8fa31e439e220a405065fff774e5f8c581be2b0743d3f83fde'
            'dbcd8f40c8a6d35bf00fdb80cd559e22068ea4a57633d3feed711babae8af8d4'
            '628eeec6b50a1f027347f799c2b06e01300412b94452bd72a611b3735e62bb98'
            'c09649081dff26b7a4eb5d6828a077089eaedf0d8cc392d5bb8232fc64e2537f')

prepare() {
  cd $pkgname-1.5.0-RC2
  patch -p1 -i ../goldendict-qt-5.11-1.patch # Fix build with Qt 5.11
  patch -p1 -i ../goldendict-qt-5.11-2.patch # Follow-up to the above
  patch -p1 -i ../goldendict-ffmpeg4.patch # Fix build with ffmpeg 4
}

build(){
  cd "${srcdir}"/$pkgname-1.5.0-RC2

  qmake-qt5 "CONFIG+=no_epwing_support" PREFIX="/usr" 
  make
}

package() {
  cd "${srcdir}"/$pkgname-1.5.0-RC2

  make INSTALL_ROOT="${pkgdir}" install

# languages
  install -d "${pkgdir}"/usr/share/$pkgname/locale
  install -m644 locale/*.qm -t "${pkgdir}"/usr/share/$pkgname/locale

# removing unneeded
  rm -rf "${pkgdir}"/usr/share/app-install
}
