# $Id: PKGBUILD 111094 2014-05-13 15:32:11Z speps $
# Maintainer: speps <speps at aur dot archlinux dot org>

pkgbase=qupzilla
pkgname=(qupzilla qupzilla-qt4)
pkgver=1.6.6
pkgrel=1
pkgdesc="Cross-platform QtWebKit browser"
arch=(i686 x86_64)
url="http://www.qupzilla.com/"
license=('GPL3')
makedepends=('qtwebkit' 'qt5-webkit' 'qt5-script' 'hunspell' 'kdelibs' 'libgnome-keyring')
optdepends=('bash-completion: bash completion support')
install="$pkgbase.install"
source=("$pkgbase-$pkgver.tar.gz::https://github.com/QupZilla/qupzilla/archive/v$pkgver.tar.gz")
noextract=("$pkgbase-$pkgver.tar.gz")
md5sums=('daad78e47a0956dcc99c0cba9ae6e462')

prepare() {
  # extract
  mkdir -p qt{4,5}
  bsdtar --strip-components 1 -zxf $pkgbase-$pkgver.tar.gz -C qt4
  bsdtar --strip-components 1 -zxf $pkgbase-$pkgver.tar.gz -C qt5

  # configure
  export USE_WEBGL=true \
         QUPZILLA_PREFIX=/usr/ \
         KDE_INTEGRATION=true \
         GNOME_INTEGRATION=true
}

build() {
  cd qt4
  qmake-qt4
  make

  cd ../qt5
  qmake
  make
}

package_qupzilla() {
  pkgdesc+=" (Qt5)"
  depends=('qt5-webkit' 'qt5-script' 'hunspell' 'desktop-file-utils' 'hicolor-icon-theme')
  optdepends=('libgnome-keyring: gnome keyring integration')
  provides=('qupzilla-qt5')
  conflicts=('qupzilla-qt5')
  replaces=('qupzilla-qt5')

  cd qt5
  make INSTALL_ROOT="$pkgdir/" install

  # zsh completion
  install -Dm644 linux/completion/_$pkgbase \
    "$pkgdir/usr/share/zsh/site-functions/_$pkgbase"
}

package_qupzilla-qt4() {
  pkgdesc+=" (Qt4)"
  depends=('qtwebkit' 'hunspell')
  optdepends=('kdelibs: kwallet integration'
              'libgnome-keyring: gnome keyring integration')
  provides=('qupzilla')
  conflicts=('qupzilla')

  cd qt4
  make INSTALL_ROOT="$pkgdir/" install

  # zsh completion
  install -Dm644 linux/completion/_$pkgbase \
    "$pkgdir/usr/share/zsh/site-functions/_$pkgbase"
}

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