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

pkgbase=neon
pkgname=("lib${pkgbase}" "lib${pkgbase}-devel")
pkgver=0.31.2
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')
makedepends=('libexpat-devel' 'openssl-devel')
options=('libtool') # FS#16067
source=(https://notroj.github.io/neon/${pkgbase}-${pkgver}.tar.gz
        neon-0.30.2-msys2.patch)
sha256sums=('cf1ee3ac27a215814a9c80803fcee4f0ede8466ebead40267a9bd115e16a8678'
            '37a3f2650a9c05360b4d353cfc0401ea1eb6446846a8b62b080483b730d93db2')

prepare() {
  cd "${srcdir}"/${pkgbase}-${pkgver}
  patch -p1 -i ${srcdir}/neon-0.30.2-msys2.patch
  ./autogen.sh
}

build() {
  cd "${srcdir}"/${pkgbase}-${pkgver}
  ./configure --build=${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/
}
