# $Id: PKGBUILD 200098 2016-12-18 10:27:54Z arojas $
# Maintainer (arch): Balló György <ballogyor+arch at gmail dot com>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Maxim Vuets <maxim.vuets@gmail.com>
# Contributor: André Silva <emulatorman@hyperbola.info>
# Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>

pkgname=cuneiform
pkgver=1.1.0
pkgrel=19.parabola1
pkgdesc="GNU/Linux port of an OCR system developed in Russia. Supports more than 20 languages, without nonfree data files"
arch=('i686' 'x86_64' 'armv7h')
url="https://launchpad.net/cuneiform-linux"
license=('BSD')
depends=('libmagick')
makedepends=('cmake')
mksource=(https://launchpad.net/cuneiform-linux/${pkgver%.*}/${pkgver%.*}/+download/$pkgname-linux-$pkgver.tar.bz2)
source=("https://repo.parabola.nu/other/${pkgname}-libre/${pkgname}-libre-${pkgver}.tar.bz2"
        'build-fix.patch'
        'libre.patch')
mksha256sums=('577e0d054de72086c33b4e8ae15033657776509b9a7af6eb272888eefcbdbbad')
sha256sums=('714b740d79c4799ec1bd340e3721d17f6d0e09ae54cd5667a01eddc8c4b758b4'
            '3d9f4d923ec6ca5555550819096b7d66e364a8aeb74a9d1f0d961784d267642b'
            '9db29dcd11faf92ed68d4af35c659b6f5e96b0864c15342be8e014817af8be2d')

mksource() {
  mv "$srcdir/$pkgname-linux-$pkgver" "$srcdir/$pkgname-$pkgver"
  cd "$srcdir/$pkgname-$pkgver"
  rm -rv datafiles
}

prepare() {
  cd $pkgname-$pkgver
  patch -Np1 -i ../build-fix.patch
  sed -i 's/lib64/lib/' install_files.cmake
  patch -p1 -i ../libre.patch
}

build() {
  cd $pkgname-$pkgver
  [[ -d build ]] || mkdir build
  cd build
  cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release
  make
}

package() {
  cd $pkgname-$pkgver/build
  make DESTDIR="$pkgdir" install
  install -Dm644 ../cuneiform_src/Kern/license.txt "$pkgdir/usr/share/licenses/cuneiform/license.txt"
}
