# Maintainer: Ray Griffin <rorgoroth-dev@outlook.com>

_realname=jpegoptim
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.5.6
pkgrel=1
pkgdesc="Utility to optimize jpeg files (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/tjko/jpegoptim/"
msys2_references=(
  "archlinux: jpegoptim"
  "cpe: cpe:/a:jpegoptim_project:jpegoptim"
  "cygwin: jpegoptim"
  "gentoo: media-gfx/jpegoptim"
)
license=('spdx:GPL-3.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-libjpeg-turbo")
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-cc")
source=(https://github.com/tjko/jpegoptim/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz)
sha256sums=('661a808dfffa933d78c6beb47a2937d572b9f03e94cbaaab3d4c0d72f410e9be')
validpgpkeys=('9168CD7A2F0AAB0679D09BBA9D08A80CED908D6A') # Timo Kokkonen <tjko@iki.fi>

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

  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST}

  make
}

package() {
  cd "${_realname}-${pkgver}"
  make install DESTDIR="${pkgdir}"

  install -Dm644 "${srcdir}"/${_realname}-${pkgver}/LICENSE \
    "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}
