# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Matt Harrison <matt@harrison.us.com>
# Contributor: Erik van der Kolk <developer at smerik dot nl>
# Contributor: Hong Xu

pkgname=editorconfig-core-c
pkgver=0.12.10
pkgrel=1
pkgdesc='EditorConfig core code written in C (for use by plugins supporting EditorConfig parsing)'
arch=(x86_64 aarch64)
url='https://github.com/editorconfig/editorconfig-core-c'
license=(BSD-3-Clause)
depends=(glibc
         pcre2)
makedepends=(cmake
             doxygen
             git)
source=(git+https://github.com/editorconfig/$pkgname#tag=v$pkgver)
sha256sums=('ecbf28494e61fbf9e4cb70bf4af4ee38a5e4a3d1fb7e81e5a3b6d777cae3a9ac')

prepare() {
  sed -e 's|-Werror||' -i $pkgname/src/CMakeLists.txt
}

build() {
  cmake -B build -S $pkgname \
      -DCMAKE_INSTALL_PREFIX=/usr \
      -DCMAKE_C_FLAGS="$CFLAGS -ffat-lto-objects"
  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build

  install -Dm644 $pkgname/LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname
}
