# Maintainer: taozuhong <taozuhong@gmail.com>

_realname=tomlc17
_commit=e34eecb90bb7c673f5ccbcc6c1a31f4035e87d5b
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=250712.r7.ge34eecb
pkgrel=1
pkgdesc="TOML parser library in C17 (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/cktan/tomlc17"
license=('spdx:MIT')
makedepends=(
  "git"
  "${MINGW_PACKAGE_PREFIX}-cc")
source=("git+https://github.com/cktan/tomlc17.git#commit=$_commit"
        "0001-fix-prefix.patch")
sha256sums=('ae120a81a7d649ceadde9732dccc01741ecb66f3d4bb5c5b0eac0339d656fc44'
            'eb9879e3c1ef19019b5de6cc8bdc76d73521a677aee4b707958a5d90351f612f')

pkgver() {
  cd "${_realname}"
   git describe --long --tags "${_commit}" | sed 's/\([^-]*-g\)/r\1/;s/-/./g;s/^R//g'
}

prepare() {
  cd "${_realname}"

  patch -p1 -i "${srcdir}/0001-fix-prefix.patch"
}

build() {
  cd "${_realname}"
  make
}

package() {
  cd "${_realname}"
  DESTDIR=${pkgdir} make install prefix=${MINGW_PREFIX}
  install -Dm644 "${srcdir}/${_realname}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
