app=zstd
version=1.4.4
build=1sml
homepage="http://zstd.net"
desc="Real-time compression algorithm providing high compression ratios"
requires="gcc-libs zlib xz lz4"

build() {
  mkandenterbuilddir
  rm -rf $app-$version

  tar xf $srcdir/$app-$version.tar.?z*
  cd $app-$version 
  fixbuilddirpermissions

  applypatch  $srcdir/zstd.dont.link.pzstd.to.static.libzstd.a.diff

  make 
  make -C contrib/pzstd

  make \
    prefix="" \
    libdir="/lib" \
    mandir="/share/man" \
    DESTDIR=$pkg install

  install -Dm 755 contrib/pzstd/pzstd $pkg/bin/pzstd

  # Remove any static libs
  rm $pkg/lib/*.a

  # zstdmt and zstd are the same, so symlink them
  ( cd $pkg/bin ; ln -sf zstd zstdmt )

  cp -a COPYING* LICENSE $pkgdocs/

  mkfinalpkg
}

sha512sums="
f12b6f38bd322a0538179ef90e4c83d2cba29e1fef391a8e8e964785e5761e7ba685f62e9a5a1d6b66171fd64e4fd6374e607569531e2f4c05c470cff2294454  zstd-1.4.4.tar.gz
356a47ea676262c70d0a22c20aedc98a4d1070972ec8910b2bb063c35e32b9beadb09ecab51beab36df24fd678e8948ace3efe485af5208d635dcc7c02d22948  zstd.dont.link.pzstd.to.static.libzstd.a.diff
"
