# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

pkgbase=libinih
pkgname=(libinih libinih-devel)
pkgver=61
pkgrel=1
pkgdesc='A simple .INI file parser written in C'
license=('spdx:BSD-3-Clause')
url='https://github.com/benhoyt/inih'
msys2_references=(
  'archlinux: libinih'
  'cygwin: inih'
)
arch=('i686' 'x86_64')
makedepends=('gcc' 'pkgconf' 'python' 'meson' 'ninja')
source=(https://github.com/benhoyt/inih/archive/refs/tags/r${pkgver}.tar.gz)
sha256sums=('7caf26a2202a4ca689df3fe4175dfa74e0faa18fcca07331bba934fd0ecb8f12')

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

build() {
  mkdir "${srcdir}"/build && cd "${srcdir}"/build

  /usr/bin/meson setup \
    --wrap-mode=nodownload \
    --auto-features=enabled \
    --buildtype=plain \
    --prefix=/usr \
    -Ddefault_library=shared \
    -Ddistro_install=true \
    -Dwith_INIReader=true \
    "../inih-r${pkgver}"

  /usr/bin/meson compile

  DESTDIR="${srcdir}/dest" /usr/bin/meson install
}

package_libinih() {
  depends=('gcc-libs')
  groups=('libraries')

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

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

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