pkgname=graphite2
pkgver=1.3.14
arch=('x86_64')
homepage="https://graphite.sil.org/"
pkgdesc="a \"smart font\" system to handle the complexities of lesser-known languages of the world"
license=('LGPL-2.1-or-later OR MPL-2.0 OR GPL-2.0-or-later')
depends=('gcc' 'glibc')
_patches=("graphite2-1.3.14-fix-cmake-files-libdir.patch"
  "graphite2-1.3.14-no-libtool-file.patch"
  "graphite2-1.3.14-fix-nodefaultlibs-deux.patch"
  "graphite2-1.3.14-fix-nodefaultlibs.patch"
  "graphite2-1.3.5-fix-gcc-linking.patch"
  "graphite2-1.3.14-gcc15.patch"
  "graphite2-1.3.14_p20210810-cmake-findpython3.patch"
  "graphite2-1.3.14_p20210810-cmake-minreqver-3.16.patch"
)
_patch_sums=("63419840415e7df9c9d8fd257d6ad85a"
  "91c6f43f2f61f3f1427485e6898da562"
  "1d4ac3863efc426f3df269ff063fdd84"
  "e22b5e6306d042e03b6180636e45c857"
  "487a20652b53a9af76e8fefe180d87e2"
  "494ea9f8d0e3ee094d18d507225a25c0"
  "6790fdb031c855fb959499f3a4b55991"
  "9d4999373dd822fe4b1b8550073f2fa8"
)
sources=("${pkgname}-${pkgver}.tgz"
  ${_patches[@]}
)
urls=("https://github.com/silnrsi/graphite/releases/download/${pkgver}/${sources[0]}"
  ${_patches[@]}
)
md5sums=("1bccb985a7da01092bfb53bb5041e836"
  ${_patch_sums[@]}
)

src_prepare() {
  tar -xzf ${distdir}/${sources[0]} --strip-components=1
  for _patch in ${_patches[@]}; do
    patch -p1 -i ${filedir}/${_patch}
  done
}

src_build() {
  local cmake_args=(
    -DCMAKE_BUILD_TYPE=None
    -DCMAKE_INSTALL_PREFIX=/usr
    -DCMAKE_SKIP_INSTALL_RPATH=ON
    -DGRAPHITE2_COMPARE_RENDERER=OFF
  )
  cmake -B build "${cmake_args[@]}"
  cmake --build build
}

src_install() {
  DESTDIR="$pkgdir" cmake --install build
  install -Dm644 COPYING -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim:ft=sh syn=sh et sw=2:
