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

pkgname=('lz4' 'liblz4' 'liblz4-devel')
pkgver=1.9.3
pkgrel=1
pkgdesc='Very fast lossless compression algorithm'
arch=('i686' 'x86_64')
url='https://lz4.github.io/lz4/'
license=('LGPL')
source=(lz4-${pkgver}.tar.gz::"https://github.com/lz4/lz4/archive/v${pkgver}.tar.gz")
sha256sums=('030644df4611007ff7dc962d981f390361e6c97a34e5cbc393ddfbe019ffe2c1')
options=(!libtool)

build() {
  cd ${srcdir}/lz4-${pkgver}
  make CC=/usr/bin/gcc CFLAGS="${CFLAGS}" all
  make DESTDIR=${srcdir}/dest PREFIX=/usr install
}

check() {
  cd ${srcdir}/lz4-${pkgver}
  make check || true
}

package_lz4() {
  groups=('libraries')
  depends=('gcc-libs' "lz4=${pkgver}")

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

package_liblz4() {
  depends=('gcc-libs')

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

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

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