# Contributor: Jim Killingsworth <jkillingsworth@gmail.com>

_realname=ttfautohint
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.8.3
pkgrel=2
pkgdesc="Automated hinting tools for TrueType fonts (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://www.freetype.org/ttfautohint/"
license=(GPL2+ custom:FreeType)
depends=("${MINGW_PACKAGE_PREFIX}-freetype"
         "${MINGW_PACKAGE_PREFIX}-harfbuzz"
         "${MINGW_PACKAGE_PREFIX}-qt5")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config")
options=('strip' '!libtool' 'staticlibs')
source=(https://downloads.sourceforge.net/sourceforge/freetype/${_realname}-${pkgver}.tar.gz)
sha256sums=('87bb4932571ad57536a7cc20b31fd15bc68cb5429977eb43d903fa61617cf87e')

build() {
  [[ -d "${srcdir}/build-${CARCH}" ]] && rm -rf "${srcdir}/build-${CARCH}"
  mv "${srcdir}/${_realname}-${pkgver}" "${srcdir}/build-${CARCH}"
  cd "${srcdir}/build-${CARCH}"

  ./configure \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --enable-static \
    --enable-shared

  make
}

package() {
  cd "${srcdir}/build-${CARCH}"
  make DESTDIR="${pkgdir}" install

  # Licenses
  install -Dm644 "${srcdir}/build-${CARCH}/COPYING"   "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
  install -Dm644 "${srcdir}/build-${CARCH}/GPLv2.TXT" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/GPLv2.TXT"
  install -Dm644 "${srcdir}/build-${CARCH}/FTL.TXT"   "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/FTL.TXT"
}
