# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

_realname=libiptcdata
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.0.5
pkgrel=1
pkgdesc="Library for manipulating the IPTC metadata (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://libiptcdata.sourceforge.io/"
msys2_repository_url='https://github.com/ianw/libiptcdata'
license=('spdx:LGPL-2.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc" "${MINGW_PACKAGE_PREFIX}-autotools")
source=("https://github.com/ianw/libiptcdata/releases/download/release_${pkgver//./_}/libiptcdata-$pkgver.tar.gz"
        "0001-libiptcdata-automake-remove-iptc-docs.patch")
sha512sums=('64ef44b1e639890004f31d5d42844ba25ed558f0a118f1dad9bc3f4dcad2457e51b825a13df849659b0e15afc78f528f330b03be94cdf156bd95b62dc419494a'
            '63a8789952aacea3e39d5697f84a1c588fc8cf0c3c225ca11d37217b9eed65276a523d6eb749228122fdda84826aec3b5777c2b45934a000504dbf1be87bd538')

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

  # Source: https://rawpedia.rawtherapee.com/Windows#Download_and_build_libiptcdata
  patch -Np1 -i "${srcdir}/0001-libiptcdata-automake-remove-iptc-docs.patch"
}

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  ../${_realname}-${pkgver}/configure \
      --prefix=${MINGW_PREFIX} \
      --build=${MINGW_CHOST} \
      --host=${MINGW_CHOST} \
      --disable-shared

  make
}

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

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/README" "${pkgdir}${MINGW_PREFIX}/share/doc/${_realname}/README"
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
