# Maintainer: Peter Lewis <plewis@aur.archlinux.org>
# Contributor: Jan de Groot <jgc@archlinux.org>
# 2010-03-11  Modified by catweazle for poppler 0.12.4
# 2010-06-23  Modified by catweazle for poppler 0.14.0
# 2010-10-16  Modified by rankin for poppler 0.14.4
# 2010-10-16  Modified by rankin for poppler 0.14.5

pkgbase=trinity
pkgname=trinity-poppler-qt3
pkgver=0.16.4
pkgrel=3
pkgdesc="Trinity - Poppler Qt3 bindings"
arch=(i686 x86_64)
license=('GPL')
depends=('trinity-qt3' "poppler>=${pkgver}")
makedepends=('pkgconfig')
provides=('trinity-poppler-qt3' 'poppler-qt3')
conflicts=('poppler-qt3')
replaces=('poppler-qt3')
options=('libtool' '!strip')
url="http://poppler.freedesktop.org/"
source=(http://poppler.freedesktop.org/poppler-${pkgver/trinity-/}.tar.gz
	poppler-bindings.patch)
sha256sums=('0e48e54d6e6d7269f049cf9d060e3ed078cad69808bda8a6da285a7b41c3a2a6'
            '0f9fa33dca271c6c0e31d66cce1847099b63c1443a002aa9bde99a8cb20ad770')

build() {

  # set default Qt dir
  _qtdir=/opt/qt

  # source qt3 profile.d/qt3.sh
  if [[ -r /etc/profile.d/qt3.sh ]]; then
    . /etc/profile.d/qt3.sh
    [[ -n $QTDIR ]] && _qtdir=$QTDIR
  else
    [[ ${PATH%%:*} =~ ${_qtdir}/bin ]] || export PATH=${_qtdir}/bin:$PATH
  fi

  cd "${srcdir}/poppler-${pkgver}"

  patch -Np2 -i ../poppler-bindings.patch

  libtoolize --force --copy
  AT_M4DIR="m4" autoreconf -i
  ./configure --prefix=${_qtdir} --sysconfdir=/etc \
              --localstatedir=/var --disable-static \
              --enable-zlib \
              --enable-libjpeg \
              --enable-cairo-output \
              --enable-poppler-qt \
              --disable-poppler-glib \
              --disable-gtk-test \
              --disable-poppler-qt4
  sed -i -e 's|^LDFLAGS =|LDFLAGS = -L${_qtdir}/lib -lqt-mt|' qt/Makefile
  pushd poppler
  make libpoppler-cairo.la
  popd
  make
}

package() {
  cd "${srcdir}/poppler-${pkgver}"
 make DESTDIR="${pkgdir}" install
}