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

pkgname=('libpipeline' 'libpipeline-devel')
pkgver=1.5.3
pkgrel=2
pkgdesc="a C library for manipulating pipelines of subprocesses in a flexible and convenient way"
url="http://libpipeline.nongnu.org/"
groups=('libraries')
arch=('i686' 'x86_64')
license=('BSD')
makedepends=('openssl-devel' 'zlib-devel')
options=('!libtool')
source=(https://download.savannah.gnu.org/releases/libpipeline/libpipeline-$pkgver.tar.gz{,.asc}
        libpipeline-1.5.1-msys2.patch)
sha256sums=('5dbf08faf50fad853754293e57fd4e6c69bb8e486f176596d682c67e02a0adb0'
            'SKIP'
            'd3e18828f4918260329984139e890ab79f434ef601eec9cd3a69450d3b857621')
validpgpkeys=('AC0A4FF12611B6FCCF01C111393587D97D86500B') # Colin Watson <cjwatson@debian.org>

prepare() {
  cd "${pkgname}-${pkgver}"
  patch -p1 -i ${srcdir}/libpipeline-1.5.1-msys2.patch

  autoreconf -fi
}

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

  ./configure --build=${CHOST} --prefix=/usr
  make
  make DESTDIR="${srcdir}/dest" install
}

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

package_libpipeline() {
  depends=('gcc-libs')
  groups=('libraries')

  mkdir -p ${pkgdir}/usr/bin
  cp -f ${srcdir}/dest/usr/bin/*.dll ${pkgdir}/usr/bin/
  cp -rf ${srcdir}/dest/usr/share ${pkgdir}/usr/
}

package_libpipeline-devel() {
  pkgdesc="libpipeline headers and libraries"
  options=('staticlibs')
  depends=("libpipeline=${pkgver}")
  groups=('development')

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