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

pkgbase=neon
pkgname=("lib${pkgbase}" "lib${pkgbase}-devel")
pkgver=0.33.0
pkgrel=1
pkgdesc="HTTP and WebDAV client library with a C interface"
arch=('i686' 'x86_64')
url="https://notroj.github.io/neon/"
license=('GPL' 'LGPL')
depends=('libexpat' 'openssl' 'ca-certificates' 'libintl')
makedepends=('libexpat-devel' 'openssl-devel' 'autotools' 'gcc' 'gettext-devel')
options=('libtool') # FS#16067
source=(https://notroj.github.io/neon/${pkgbase}-${pkgver}.tar.gz)
sha256sums=('659a5cc9cea05e6e7864094f1e13a77abbbdbab452f04d751a8c16a9447cf4b8')

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

  ./autogen.sh
}

build() {
  cd "${srcdir}"/${pkgbase}-${pkgver}

  export MSYSTEM=CYGWIN
  local CYGWIN_CHOST="${CHOST/-msys/-cygwin}"
  ./configure --build=${CYGWIN_CHOST} \
    --prefix=/usr \
    --with-expat \
    --enable-shared \
    --disable-static \
    --with-ssl=openssl \
    --with-ca-bundle=/usr/ssl/certs/ca-bundle.crt
  make

  make DESTDIR="${srcdir}/dest" install
}

package_libneon() {
  groups=('libraries')

  mkdir -p ${pkgdir}/usr/bin
  cp -f ${srcdir}/dest/usr/bin/*.dll ${pkgdir}/usr/bin/
  cp -rf ${srcdir}/dest/usr/share ${pkgdir}/usr/
}

package_libneon-devel() {
  pkgdesc="Libneon headers and libraries"
  groups=('development')
  options=('staticlibs')
  depends=("libneon=${pkgver}" 'libexpat-devel' 'openssl-devel')

  mkdir -p ${pkgdir}/usr/bin
  cp -f ${srcdir}/dest/usr/bin/*-config ${pkgdir}/usr/bin/
  cp -rf ${srcdir}/dest/usr/include ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/lib ${pkgdir}/usr/
}
