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

_realname=shishi
pkgbase=mingw-w64-${_realname}-git
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-git"
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=r3591.ffe64562
pkgrel=1
pkgdesc="a GNU implementation of the Kerberos 5 network security system (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://www.gnu.org/software/shishi/"
license=("GPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-gettext"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "wget"
             "git"
             "gengetopt")
options=('strip' 'staticlibs')
depends=("${MINGW_PACKAGE_PREFIX}-gnutls"
         "${MINGW_PACKAGE_PREFIX}-libidn"
         "${MINGW_PACKAGE_PREFIX}-libgcrypt"
         "${MINGW_PACKAGE_PREFIX}-libgpg-error"
         "${MINGW_PACKAGE_PREFIX}-libtasn1"
        )
_commit="ffe645623b0f685e14b12a7a1939f708a5cf6039"
source=("${_realname}"::"git+https://git.savannah.gnu.org/git/shishi.git#commit=${_commit}"
        "003-no-shishid.patch"
        "004-fix-download-po.patch"
       )
sha256sums=('SKIP'
            'a5b17bb2840d95d90d591c170ca430726d2cac0e77523cb6e1b84925e8e1cf76'
            '329258931329937824fe37f09666e0b0fc2bd0140a50429e04e4ea40fbd2c411')

pkgver() {
  cd "${srcdir}/${_realname}"
  printf "r%s.%s" "$(git rev-list --count "${_commit}")" "$(git rev-parse --short "${_commit}")"
}

prepare() {
  cd ${_realname}
  patch -p1 -i ${srcdir}/003-no-shishid.patch
  patch -p1 -i ${srcdir}/004-fix-download-po.patch

  autoreconf -fi

  # gettext build is broken..
  echo "" > po/LINGUAS
}

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

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

  make -j1
}

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