_realname=epstool
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.09
pkgrel=1
pkgdesc="utility to create or extract preview images in EPS files, fix bounding boxes and convert to bitmaps (mingw-w64)"
license=("GPL2")
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
depends=("${MINGW_PACKAGE_PREFIX}-ghostscript")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc")
url="http://www.ghostgum.com.au/software/epstool.htm"
source=(http://www.ghostgum.com.au/download/${_realname}-${pkgver}.tar.gz
        "0001-mingw-buildrule.patch"
        "0002-buildorder.patch")
sha256sums=('e3538857e0c8c21a5a6cbd28fba75d71825318daea6525a4d20e385d758ca847'
            '11d587e3733b34cc3f4ba776cc3e8a02e431df7060b0461986d80fb9cebfdad2'
            '5203a48cb6d4ea444e3865327bcedb143085aba900cb3a00d499c606da005853')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}

  # patch from https://hg.octave.org/mxe-octave/file/c30da1cd5e3b/src/mingw-epstool-1-fixes.patch
  rm -rf src/mingwcom.mak && patch -p1 -i "${srcdir}/0001-mingw-buildrule.patch"

  patch -p1 -i "${srcdir}/0002-buildorder.patch"
}

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

  make prefix="${pkgdir}/${MINGW_PREFIX}"
}

package() {
  cd "${srcdir}"/${_realname}-${pkgver}

  make prefix="${pkgdir}/${MINGW_PREFIX}" install
}
