# Contributor (MSYS2): David Macek <david.macek.0@gmail.com>
# Maintainer (Arch Linux): Lukas Fleischer <archlinux at cryptocrack dot de>
# Contributor (Arch Linux): Allan McRae <allan@archlinux.org>
# Contributor (Arch Linux): bekks <eduard.warkentin@gmail.com>
# Contributor (Arch Linux): Daniel J Griffiths <ghost1227@archlinux.us>

pkgname=upx
pkgver=3.96
pkgrel=1
pkgdesc='Ultimate executable compressor.'
arch=('i686' 'x86_64')
url='https://upx.github.io/'
license=('GPL')
depends=('ucl' 'zlib')
makedepends=('ucl-devel' 'zlib-devel')
source=("https://github.com/${pkgname}/${pkgname}/archive/v${pkgver}.tar.gz"
        "lzma-sdk-${pkgver}.tar.gz::https://github.com/${pkgname}/${pkgname}-lzma-sdk/archive/v${pkgver}.tar.gz")
sha256sums=('6882b4ea89c7a0ed74b86d3c0f1d07814b492eaf649b43ab8b4dfefa9e2d7387'
            'e465670abe0900a0995f7e6166bff86caed06b253f6ff02d6490df6263aecc67')

prepare() {
  cp -rf upx-lzma-sdk-${pkgver}/* "${pkgname}-${pkgver}/src/lzma-sdk"
  cd "${pkgname}-${pkgver}"
}

build() {
  cd "${pkgname}-${pkgver}"
  CPPFLAGS+=" -DUCL_NO_ASM"
  #make UPX_LZMA_VERSION=0x465 UPX_LZMADIR="${srcdir}" all
  make all
}

package() {
  cd "${pkgname}-${pkgver}"
  install -Dm0755 src/upx.out "${pkgdir}/usr/bin/upx"
  install -Dm0644 doc/upx.1 "${pkgdir}/usr/share/man/man1/upx.1"
  install -Dm0644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
