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

_realname=libgadu
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.12.2
pkgrel=2
pkgdesc="This library implements the client side of the Gadu-Gadu protocol (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://libgadu.net/"
license=("LGPL2.1")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
depends=("${MINGW_PACKAGE_PREFIX}-gnutls" "${MINGW_PACKAGE_PREFIX}-protobuf-c")
options=('staticlibs' 'strip')
source=("https://github.com/wojtekka/libgadu/releases/download/${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('28e70fb3d56ed01c01eb3a4c099cc84315d2255869ecf08e9af32c41d4cbbf5d')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  # autoreconf to get updated libtool files with clang support
  autoreconf -fiv
}

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-shared \
      --enable-static \
      --disable-tests
  make
}

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

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