# Maintainer (MSYS2): Michael Hansen <zrax0111@gmail@com>

_realname=editorconfig-core-c
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.12.5
pkgrel=1
pkgdesc='EditorConfig core code written in C (mingw-w64)'
url='https://github.com/editorconfig/editorconfig-core-c'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-pcre2")
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-doxygen")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/editorconfig/${_realname}/archive/v${pkgver}.tar.gz")
sha256sums=('b2b212e52e7ea6245e21eaf818ee458ba1c16117811a41e4998f3f2a1df298d2')

prepare() {
  mkdir -p build-${MINGW_CHOST}
}

build() {
  cd build-${MINGW_CHOST}

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
    -DCMAKE_BUILD_TYPE=Release \
    ../${_realname}-${pkgver}

  make
}

package() {
  cd build-${MINGW_CHOST}

  make DESTDIR="${pkgdir}" install
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE" "${pkgdir}/${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
