# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=icoutils
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.32.3
pkgrel=1
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
pkgdesc="Create and extract MS Windows icons and cursors (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-libpng")
options=('strip' 'staticlibs')
license=("GPL 2")
url="https://www.nongnu.org/icoutils/"
source=(https://savannah.nongnu.org/download/${_realname}/${_realname}-${pkgver}.tar.bz2)
sha256sums=('17abe02d043a253b68b47e3af69c9fc755b895db68fdc8811786125df564c6e0')

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

build() {
  [[ -d "${srcdir}"/build-${MINGW_CHOST} ]] && rm -rf "${srcdir}"/build-${MINGW_CHOST}
  mkdir -p "${srcdir}"/build-${MINGW_CHOST} && cd "${srcdir}"/build-${MINGW_CHOST}

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST}

  make
}

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