# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgbase=gamin
pkgname=("gamin" "gamin-devel")
pkgver=0.1.10
pkgrel=4
pkgdesc="File and directory monitoring system defined to be a subset of the FAM (File Alteration Monitor)"
arch=('i686' 'x86_64')
url="https://people.gnome.org/~veillard/gamin/"
license=('LGPL')
groups=('libraries')
makedepends=('gcc' 'gtk-doc' 'glib2-devel' 'pcre-devel')
source=("https://download.gnome.org/sources/$pkgname/${pkgver%.*}/$pkgname-$pkgver.tar.bz2"
        001-no-undefined.patch
        002-fix-deprecated-const.patch
        003-python-link.patch)
sha256sums=('a59948b20ce2f14136c013f155abb8c8d51db2ea167c063ff33461e453fec10a'
            'ab3d63b9ec568fbfe597216135b1e210b92299da0d2556be70fa7c01b3600e06'
            '33af6c9a94b459506fc48892c169d89cb4ad7c68e160f0c4bc74475f19ce5a2f'
            '1f11906d4d4dc5159ca647167899ccfb5efec4648ea77b6e96397142293bbab7')

prepare() {
  cd "$srcdir/$pkgname-$pkgver"
  patch -p1 -i ${srcdir}/001-no-undefined.patch
  patch -p1 -i ${srcdir}/002-fix-deprecated-const.patch
  patch -p1 -i ${srcdir}/003-python-link.patch
  autoreconf -ivf
}

build() {
  cd "$srcdir/$pkgname-$pkgver"
  ./configure \
    --prefix=/usr \
    --libexecdir=/usr/lib/gamin \
    --disable-server \
    --without-python
  make
  make DESTDIR="$srcdir/dest" install
}

check() {
  cd "$srcdir/$pkgname-$pkgver"
  make -k check
}

package_gamin() {
  mkdir -p $pkgdir/usr/bin
  cp -rf $srcdir/dest/usr/bin $pkgdir/usr/
}

package_gamin-devel() {
  pkgdesc="Gamin headers and libraries (development)"
  groups=('development')
  depends=("gamin=${pkgver}")

  mkdir -p $pkgdir/usr
  cp -rf $srcdir/dest/usr/include $pkgdir/usr/

  mkdir -p $pkgdir/usr/lib
  cp -rf $srcdir/dest/usr/lib/pkgconfig $pkgdir/usr/lib/
  cp -f $srcdir/dest/usr/lib/*.a $pkgdir/usr/lib/
}