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

pkgname=('libunistring' 'libunistring-devel')
pkgver=1.3
pkgrel=1
pkgdesc="Library for manipulating Unicode strings and C strings."
url="https://www.gnu.org/software/libunistring/"
msys2_repository_url="https://git.savannah.gnu.org/gitweb/?p=libunistring.git"
msys2_references=(
  "cpe: cpe:/a:gnu:libunistring"
)
arch=('i686' 'x86_64')
license=('spdx:LGPL-3.0-or-later OR GPL-2.0-or-later')
depends=('libiconv')
makedepends=('libiconv-devel' 'autotools' 'gcc')
source=(https://ftp.gnu.org/gnu/${pkgname}/${pkgname}-${pkgver}.tar.xz{,.sig}
        libunistring-0.9.3-2.src.patch)
sha256sums=('f245786c831d25150f3dfb4317cda1acc5e3f79a5da4ad073ddca58886569527'
            'SKIP'
            'e30aff2bd1b6b31977308a531fb445a8550295666d7eae60ee65f0ebd70280c8')
validpgpkeys=('462225C3B46F34879FC8496CD605848ED7E69871'  # Daiki Ueno <ueno@unixuser.org>
              '9001B85AF9E1B83DF1BDA942F5BE8B267C6A406D') # Bruno Haible (Open Source Development) <bruno@clisp.org>

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

  autoreconf -fi
}

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

  export gl_cv_have_weak=no
  ./configure \
    --build=${CHOST} \
    --prefix=/usr

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

package_libunistring() {
  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/
}
