# Maintainer: Johannes Schindelin <johannes.schindelin@gmx.de>

pkgbase=msgpack-c
pkgname=('msgpack-c' 'msgpack-c-devel')
pkgver=6.1.0
pkgrel=2
pkgdesc="MessagePack implementation for C"
arch=('i686' 'x86_64')
url="https://msgpack.org"
msys2_repository_url="https://github.com/msgpack/msgpack-c"
license=('Boost')
makedepends=('cmake' 'gcc' 'ninja')
source=("https://github.com/msgpack/msgpack-c/releases/download/c-${pkgver}/${pkgbase}-${pkgver}.tar.gz")
sha256sums=('674119f1a85b5f2ecc4c7d5c2859edf50c0b05e0c10aa0df85eefa2c8c14b796')

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

  cmake -GNinja -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=None \
    -DBUILD_SHARED_LIBS=ON \
    -DMSGPACK_ENABLE_STATIC=OFF \
    -DMSGPACK_BUILD_EXAMPLES=OFF \
    .

  cmake --build .
  DESTDIR="${srcdir}/dest" cmake --install .
}

package_msgpack-c() {
  pkgdesc="MessagePack implementation for C (runtime)"
  depends=('zlib')
  groups=('libraries')

  install -d -m755 ${pkgdir}/usr/bin
  install -m755 ${srcdir}/dest/usr/bin/*.dll ${pkgdir}/usr/bin/

  # license
  install -d -m755 ${pkgdir}/usr/share/licenses/${pkgname}/
  install -m644 ${srcdir}/${pkgbase}-${pkgver}/{COPYING,LICENSE*} ${pkgdir}/usr/share/licenses/${pkgname}/
}

package_msgpack-c-devel() {
  pkgdesc="MessagePack implementation for C (headers & libraries)"
  depends=('zlib-devel')
  groups=('development')

  install -d -m755 ${pkgdir}/usr/include
  cp -rf ${srcdir}/dest/usr/include/* ${pkgdir}/usr/include/

  install -d -m755 ${pkgdir}/usr/lib
  cp -rf ${srcdir}/dest/usr/lib/* ${pkgdir}/usr/lib/
}
