# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libidn2
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.0.4
pkgrel=1
pkgdesc="Implementation of the Stringprep, Punycode and IDNA specifications (mingw-w64)"
arch=('any')
url="https://www.gnu.org/software/libidn"
license=("GPL3, LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config" "gtk-doc")
depends=("${MINGW_PACKAGE_PREFIX}-gettext" "${MINGW_PACKAGE_PREFIX}-libunistring")
options=('staticlibs' 'strip')
source=("https://ftp.gnu.org/gnu/libidn/${_realname}-${pkgver}.tar.gz")
sha256sums=('644b6b03b285fb0ace02d241d59483d98bc462729d8bb3608d5cad5532f3d2f0')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
  autopoint --force
  autoreconf -i
}

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}\
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared \
    --disable-doc \
    --disable-rpath

  make
}

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