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

pkgname=('libunistring' 'libunistring-devel')
pkgver=0.9.10
pkgrel=1
pkgdesc="Library for manipulating Unicode strings and C strings."
url="https://www.gnu.org/software/libunistring/"
arch=('i686' 'x86_64')
license=('GPL')
depends=('libiconv')
makedepends=('libiconv-devel')
source=(https://ftp.gnu.org/gnu/${pkgname}/${pkgname}-${pkgver}.tar.gz
        libunistring-0.9.3-2.src.patch
        libunistring-0.9.3-msys2.patch)
sha256sums=('a82e5b333339a88ea4608e4635479a1cfb2e01aafb925e1290b65710d43f610b'
            '8b00b7960b3e2f2e0db1f65bd2b2fea8eb36de98f48a40c8520d8fb00b57f249'
            'abdbb2f4394b3957d7f7c8dd9994e8f06aa0d9b43db21f4da428cd65d9624e5d')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p2 -i ${srcdir}/libunistring-0.9.3-2.src.patch
  patch -p1 -i ${srcdir}/libunistring-0.9.3-msys2.patch

  autoreconf -fi
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure --build=${CHOST} --prefix=/usr
  make
  make DESTDIR="${srcdir}/dest" install
}

package_libunistring() {
  install=${pkgname}.install
  groups=('libraries')

  mkdir -p ${pkgdir}/usr
  cp -rf ${srcdir}/dest/usr/bin ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/share ${pkgdir}/usr/
}

package_libunistring-devel() {
  pkgdesc="libunistring headers and libraries"
  groups=('development')
  options=('staticlibs')
  depends=("libunistring=${pkgver}" "libiconv-devel")

  mkdir -p ${pkgdir}/usr
  cp -rf ${srcdir}/dest/usr/include ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/lib ${pkgdir}/usr/
}
