# Maintainer: 3mb3dw0rk5 <3mb3dw0rk5 at gmail dot com>
# PKGBUILD derived from original AUR PKGBUILD
# Contributor: SpepS <dreamspepser at yahoo dot it>, eric <eric@archlinux.org>

pkgname=hexcurse
pkgver=1.60.0
pkgrel=1
pkgdesc="Versatile ncurses-based hex editor."
arch=('i686' 'x86_64')
#url="http://directory.fsf.org/project/HexCurse/"
url="https://github.com/LonnyGomes/hexcurse"
license=('GPL')
depends=('ncurses')
options=('!makeflags')
source=("${pkgname}-${pkgver}.tgz::https://github.com/LonnyGomes/hexcurse/archive/v${pkgver}.tar.gz"
        hexcurse-1.60.0-msys2-automake-version.diff
        hexcurse-1.60.0-msys2-getopt.diff
        hexcurse-1.60.0-gcc7.patch)
md5sums=('cb24b564bea21a615a5c6a2ee30d6cad'
         '255adfe8f653b4c9f31c3120e42e77d3'
         '6f2ee1e8a72493c08db0a7e49ac4d630'
         '588e41b5a760d07d2f26619a68e88359')

# Helper macros to help make tasks easier #
apply_patch_with_msg() {
  for _fname in "$@"
  do
    msg2 "Applying ${_fname}"
    patch -Nbp1 -i "${srcdir}"/${_fname}
  done
}

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  
  apply_patch_with_msg \
    hexcurse-1.60.0-msys2-automake-version.diff \
    hexcurse-1.60.0-msys2-getopt.diff \
    hexcurse-1.60.0-gcc7.patch
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  ./configure \
    --build=${CHOST} \
    --host=${CHOST} \
    --target=${CHOST} \
    --prefix=/usr \
    --mandir=/usr/share/man

  make
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}/" install
}
