# Maintainer: Andreas Grapentin <andreas@grapentin.org>
# Maintainer (Arch): Ronald van Haren <ronald.archlinux.org>
# Contributor: Michał Masłowski <mtjm@mtjm.eu>
# Contributor: André Silva <emulatorman@hyperbola.info>
# Contributor (Arch): Damir Perisa <damir.perisa@bluewin.ch>

pkgname=kile

pkgver=2.9.91
pkgrel=3.parabola1
arch=(i686 x86_64 armv7h)

pkgdesc="A user friendly TeX/LaTeX frontend for KDE, without nonfree Adobe Reader recommendation"
url="http://kile.sourceforge.net/"
license=(GPL2)

makedepends=(extra-cmake-modules kdoctools)
depends=(ktexteditor kinit okular khtml texlive-core)
optdepends=('konsole: embedded terminal')
conflicts=(kile-libre)
replaces=(kile-libre)

source=("http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.bz2"
        "kile-local-url.patch"
        "libre.patch")
sha256sums=('08cb54cddc54c851d98b339f386d9aa20b3d71ff98ef078242fd52f684712d93'
            '2cea79a285fe8b481d64088a87b0e6bccd1091a9ac08c934cdead7dcb7bd1fa3'
            '254eb9ef48c53d67eac107c6b99f7a10c69d88327f860543d35c4240cec9a2ed')

prepare() {
  mkdir build

  cd $pkgname-$pkgver

  # Fix opening local URLs
  patch -p1 -i $srcdir/kile-local-url.patch

  # Remove nonfree Adobe Reader recommendation
  patch -Np1 -i $srcdir/libre.patch
}

build() {
  cd build
  cmake ../$pkgname-$pkgver \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=lib
  make
}

package() {
  cd build
  make DESTDIR="$pkgdir" install
}
