# Maintainer: Ray Donnelly <mingw.android@gmail.com>

_realname=ideviceinstaller
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.1.1
pkgrel=2
pkgdesc='Manage apps of iOS devices (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://www.libimobiledevice.org/'
msys2_repository_url="https://github.com/libimobiledevice/ideviceinstaller"
license=('spdx:GPL-2.0-or-later')
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools" "${MINGW_PACKAGE_PREFIX}-cc")
source=(https://github.com/libimobiledevice/ideviceinstaller/archive/${pkgver}/${_realname}-${pkgver}.tar.gz)
depends=("${MINGW_PACKAGE_PREFIX}-libplist"
         "${MINGW_PACKAGE_PREFIX}-libimobiledevice"
         "${MINGW_PACKAGE_PREFIX}-libzip")
sha256sums=('b1401678a61f28c4aca95375c100b5a83ccc2cdfa0222c0de7ad0a2cfb4e3c9f')

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

  NOCONFIGURE=1 ./autogen.sh
}

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

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

  make
}

check() {
  cd "${srcdir}"/build-${MSYSTEM}
  make check
}

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