# Maintainer: Pierre Schmitz <pierre@archlinux.de>
# Contributor: François Charette <firmicus@gmx.net>

pkgname=xz
pkgver=5.8.3
pkgrel=1
pkgdesc='Library and command line tools for XZ and LZMA compressed files'
arch=('x86_64')
url='https://tukaani.org/xz/'
license=('GPL' 'LGPL' 'custom')
depends=('sh')
makedepends=('git' 'po4a' 'doxygen')
provides=('liblzma.so')
validpgpkeys=('3690C240CE51B4670D30AD1C38EE757D69184620') # Lasse Collin <lasse.collin@tukaani.org>
source=("git+https://github.com/tukaani-project/xz#tag=v${pkgver}?signed"
        "add-pgo.patch")
sha256sums=('ac5336c53dfc666810582c21b22f89bab021d3afbe6cb365c80fbfcbe73a6c24'
            '25d2b7b9c6d356ed18df7802bd6dae82005310fa065f3703c39e4d9f5ea55a9f')
sha512sums=('47f7d0cdd200c0db0bee0cf5d1419993d02219ee7c52dc3ea017a9b6af5c2dc5c0d80eab485715f2eb7016829ad14963e836bf07b32b11b9743fd933df2476d0'
            'fb9a7ea934555fe3ab2fccc4bd125fb4711d54862082f3a5e68faa2e96abb7c18c48c9b5e7d6be2616861dd1f97b5b3d244736676ec48b3467e61caf4c02a2a5')

prepare() {
  cd ${pkgname}
  ## Patch make pgo-build in
  patch -Np1 < ../add-pgo.patch
  ./autogen.sh
}

build() {
  cd ${pkgname}

  ./configure \
    --prefix=/usr \
    --disable-rpath
  make pgo-build
}

check() {
  cd ${pkgname}

  make check
}

package() {
  cd ${pkgname}

  make DESTDIR="${pkgdir}" install

  install -d -m0755 "${pkgdir}/usr/share/licenses/xz/"
  ln -sf /usr/share/doc/xz/COPYING "${pkgdir}/usr/share/licenses/xz/"
}
