# $Id: PKGBUILD 240297 2015-06-03 10:22:03Z fyan $
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>
# Contributor: Michael Hansen <zrax0111 gmail com>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - patch for chromium GN

pkgname=qt5-doc
_qtver=5.9.2
pkgver=${_qtver/-/}
pkgrel=1
arch=('any')
url='http://qt-project.org/'
license=('GPL3' 'LGPL3' 'FDL' 'custom')
pkgdesc='A cross-platform application and UI framework (Documentation)'
depends=('qt5-base')
makedepends=('qt5-tools' 'python2' 'pciutils' 'libxtst' 'libxcursor' 'libxrandr' 'libxss' 'libxcomposite' 'git')
groups=('qt' 'qt5')
_pkgfqn="qt-everywhere-opensource-src-${_qtver}"
source=("http://download.qt.io/official_releases/qt/${pkgver%.*}/${_qtver}/single/${_pkgfqn}.tar.xz"
        '0001-ARM-toolchain-fixes.patch')
sha256sums=('6c6171a4d1ea3fbd4212d6a04899650218583df3ec583a8a6a4a589fe18620ff'
            '8202b09a1caa82538a2eacd79b62b61d8661c65cdfb275560d231aa31a362b12')

prepare() {
  cd ${_pkgfqn}

  ln -s /usr/bin qttools/
  ln -s /usr/bin/{rcc,uic,moc} qtbase/bin/

  # Hack to force using python2
  cd "$srcdir"
  mkdir -p bin
  ln -s /usr/bin/python2 bin/python

  cd ${_pkgfqn}/qtwebengine/src/3rdparty
  patch -p1 -i ${srcdir}/0001-ARM-toolchain-fixes.patch
}

build() {
  cd ${_pkgfqn}

  export PATH="$srcdir/bin:$PATH"
  PYTHON=/usr/bin/python2 ./configure -confirm-license -opensource \
    -prefix /usr \
    -docdir /usr/share/doc/qt \
    -headerdir /usr/include/qt \
    -archdatadir /usr/lib/qt \
    -datadir /usr/share/qt \
    -sysconfdir /etc/xdg \
    -examplesdir /usr/share/doc/qt/examples
  make docs
}

package() {
  cd ${_pkgfqn}
  make -j1 INSTALL_ROOT="$pkgdir" install_docs

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

# Fix conflicts with qt5-examples
  rm -r "$pkgdir"/usr/share/doc/qt/examples
}