# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor:  Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Andrzej Giniewicz <gginiu@gmail.com>
# Contributor: Johan Förberg <johan@forberg.se>

_pkgname=zstd
pkgname=lib32-zstd
pkgver=1.4.3
pkgrel=1
pkgdesc='Zstandard - Fast real-time compression algorithm (32-bit)'
url='https://www.zstd.net/'
arch=('x86_64')
license=('BSD' 'GPL2')
depends=('zstd' 'lib32-zlib' 'lib32-xz' 'lib32-lz4')
makedepends=('gtest')
source=(https://github.com/facebook/zstd/releases/download/v${pkgver}/zstd-${pkgver}.tar.gz)
sha256sums=('e88ec8d420ff228610b77fba4fbf22b9f8b9d3f223a40ef59c9c075fcdad5767')
sha512sums=('cb36772a59f79922e65c0f869384dca4ef2948c1d1440abcddecc7e3838efee5b547dad97b9023cdcf17bf10a32412b8f3b20a5e16b79314e61074987edecfab')

build() {
  cd ${_pkgname}-${pkgver}
  export CC="gcc -m32"
  export CXX="g++ -m32"
  export PKG_CONFIG_PATH="/usr/lib32/pkgconfig"
  make
  make zstdmt
  make -C contrib/pzstd
}

check() {
  cd ${_pkgname}-${pkgver}
  make check
  make -C contrib/pzstd test
}

package() {
  cd ${_pkgname}-${pkgver}
  make \
    PREFIX=/usr \
    LIBDIR=/usr/lib32 \
    PKGCONFIGDIR=/usr/lib32/pkgconfig \
    DESTDIR="${pkgdir}" \
    install
  rm -rf "${pkgdir}"/usr/{share,include,bin}
  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
