# Maintainer: Geoffrey Frogeye <geoffrey+aur@frogeye.fr>
# Contributor: George Rawlinson <grawlinson@archlinux.org>

pkgname=check-sieve
pkgver=0.6
pkgrel=2
pkgdesc="Syntax checker for Sieve scripts"
arch=('i686' 'x86_64')
url="https://github.com/dburkart/check-sieve"
license=('MIT')
depends=('gcc-libs')
checkdepends=('python')
source=("$url/archive/$pkgname-$pkgver.tar.gz")
b2sums=('ceb747f94385f4f5ed883e6503aab1bde82ece472cf41c16f8bdfb039d72068ec80cc2f1f3b3c0374947d2e785504295dbcda252d1d9df165c354eff509ae3ff')

prepare() {
  # rename extracted folder for convenience
  mv "$pkgname-$pkgname-$pkgver" "$pkgname-$pkgver"

  # ensure LDFLAGS are passed to compiler
  sed -i '/\t$(CXX).*/s/$/ $(LDFLAGS)/' "$pkgname-$pkgver/Makefile"
}


build() {
  cd "$pkgname-$pkgver"
  make
}

check() {
  cd "$pkgname-$pkgver"
  make test
}

package() {
  cd "$pkgname-$pkgver"

  make INSTALL_PREFIX="$pkgdir/usr" install

  # license
  install -Dm644 -t "$pkgdir/usr/share/licenses/$pkgname" COPYING

  # fix incorrect permissions on library
  chmod 644 "$pkgdir/usr/lib/libchecksieve.a"
}