# Maintainer: Alexander F. Rødseth <xyproto@archlinux.org>
# Contributor: Lukas Fleischer <lfleischer@archlinux.org>
# Contributor: Allan McRae <allan@archlinux.org>
# Contributor: bekks <eduard.warkentin@gmail.com>
# Contributor: Daniel J Griffiths <ghost1227@archlinux.us>

pkgname=upx
pkgver=3.96
pkgrel=2
pkgdesc='Extendable, high-performance executable packer for several executable formats'
arch=(x86_64)
url='https://github.com/upx/upx'
license=(custom GPL2)
depends=(ucl)
makedepends=(git perl)
source=("git+$url#commit=d7ba31cab8ce8d95d2c10e88d2ec787ac52005ef") # v3.96
sha256sums=('SKIP')

prepare() {
  cd $pkgname
  git submodule update --init --recursive
  # Disable a warning. upx believes this is not a release version if the git revision is set.
  sed -i 's/bool warn = true/bool warn = false/' src/main.cpp
}

build() {
  make -C $pkgname \
    CHECK_WHITESPACE=/bin/true \
    UPX_LZMA_VERSION=0x465 \
    UPX_LZMADIR="$srcdir" \
    all
}

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

# vim: ts=2 sw=2 et:
