# $Id: PKGBUILD 240297 2015-06-03 10:22:03Z fyan $
# Maintainer (Arch): Felix Yan <felixonmars@archlinux.org>
# Contributor (Arch): Andrea Scarpino <andrea@archlinux.org>

# Maintainer (ALARM): Kevin Mihelich <kevin@archlinuxarm.org>
#  - icu makedepend
#  - patch for soft-float armv5
#  - patch for AArch64 support in qtwebkit

# Maintainer: Isaac David <isacdaavid@at@isacdaavid@dot@info>

pkgname=qt5-webkit-og
_qtver=5.9.0
pkgver=${_qtver/-/}
pkgrel=2
arch=('armv7h')
url='http://qt-project.org/'
license=('GPL3' 'LGPL3' 'FDL' 'custom')
pkgdesc='Classes for a WebKit2 based implementation and a new QML API'
depends=('qt5-location' 'qt5-sensors' 'qt5-webchannel' 'libwebp' 'libxslt' 'libxcomposite' 'gst-plugins-base')
makedepends=('ruby' 'gperf' 'python' 'icu' 'qt5-doc' 'qt5-tools')
optdepends=('gst-plugins-good: Webm codec support')
provides=('qt5-webkit')
conflicts=('qt5-webkit' 'qt')
groups=('qt' 'qt5')
_pkgfqn="qtwebkit-opensource-src-${_qtver}"
source=("http://download.qt.io/community_releases/${pkgver%.*}/${_qtver}-final/qtwebkit-opensource-src-${_qtver}.tar.xz"
        qt5-webkit-icu59.patch
        qt5webkit-0002-Fix-QtWebKit-build-on-ARM-softfp.patch
        0001-Add-ARM-64-support.patch)
sha256sums=('8dad193b740055a998312e04a040f2e32a923c0823b2d239b24eab08276a4e04'
            '3bc9c7202f5cb055311ffb8a14145cef89060c00002f4cd5b4f4bf210bd56295'
            'f8a00464d786a0adaa840813256fcaa9885d5914c604ca66d3c750bb79161b46'
            'a1abdfd978198c5b3d76637131bd76793735f1d94f0eea04e1b223967e58bc6e')

prepare() {
  mkdir -p build

# Fix build with ICU 59 (PLD linux)
  cd ${_pkgfqn}
  patch -p1 -i ../qt5-webkit-icu59.patch

# ARM fixes
  patch -p1 -i ../qt5webkit-0002-Fix-QtWebKit-build-on-ARM-softfp.patch
  patch -p1 -i ../0001-Add-ARM-64-support.patch

  CFLAGS+=" -Wno-expansion-to-defined"
  CXXFLAGS+=" -Wno-expansion-to-defined"
}

build() {
  cd build  

  qmake ../${_pkgfqn}
  make
  make docs
}

package() {
  cd build
  make INSTALL_ROOT="$pkgdir" install install_docs

  # Drop QMAKE_PRL_BUILD_DIR because reference the build dir
  find "$pkgdir/usr/lib" -type f -name '*.prl' \
    -exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d' {} \;

  install -d "$pkgdir"/usr/share/licenses
  ln -s /usr/share/licenses/qt5-base "$pkgdir"/usr/share/licenses/${pkgname}
}
