# Maintainer: Peter Budai <peterbudai at hotmail dot com>

_realname=flickcurl
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.26
pkgrel=9
pkgdesc="Flickcurl is a C library for the Flickr API (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://librdf.org/flickcurl/"
license=("LGPL2")
depends=("${MINGW_PACKAGE_PREFIX}-curl"
         "${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-libwinpthread")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-pkgconf"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc")
source=("http://download.dajobe.org/flickcurl/flickcurl-${pkgver}.tar.gz"
        flickcurl-1.26-build.patch)
sha256sums=('ff42a36c7c1c7d368246f6bc9b7d792ed298348e5f0f5d432e49f6803562f5a3'
            'e4c9dcedf4752e4fcaa623f13e0e8f2632854e2bf365b72a772023118613b059')

prepare() {
  cd "${srcdir}"/flickcurl-${pkgver}
  patch -p1 -i "${srcdir}"/flickcurl-1.26-build.patch

  NOCONFIGURE=1 ./autogen.sh --enable-gtk-doc=yes
}

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

  case ${MSYSTEM} in
    CLANG*)
      # use nanosleep from libpthread on Clang
      ac_cv_search_nanosleep=yes
      CFLAGS="$CFLAGS -pthread"
    ;;
  esac

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

  make
}

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