# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=ftgl
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.4.0
pkgrel=1
pkgdesc="OpenGL library to use arbitrary fonts (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://github.com/frankheckenbach/ftgl"
license=("MIT")
makedepends=("${MINGW_PACKAGE_PREFIX}-cppunit"
             "${MINGW_PACKAGE_PREFIX}-doxygen"
             "${MINGW_PACKAGE_PREFIX}-graphviz"
             "${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-freetype")
options=('staticlibs' 'strip')
source=(${_realname}-${pkgver}.tar.gz::"https://github.com/frankheckenbach/ftgl/archive/v${pkgver}.tar.gz")
sha256sums=('aa97da1c3442a8fd3941037655df18016d70b5266381c81d81e8b5335f196ea8')

prepare () {
  cd "${srcdir}/${_realname}-${pkgver}"
  sed -i "s|SUBDIRS = src test demo docs|SUBDIRS = src|g" Makefile.am

  printf '%s\n' >>docs/doxygen.cfg.in \
    HAVE_DOT=yes DOT_IMAGE_FORMAT=svg INTERACTIVE_SVG=yes
  ./autogen.sh
}

build() {
  rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ../"${_realname}-${pkgver}"/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-static \
    --enable-shared \
    --without-x
  make ECHO=echo
}

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

  # FS#23283: install missing headers for OpenCascade
  install -Dm644 "${srcdir}/${_realname}-${pkgver}"/src/FT{Face,Size}.h "${pkgdir}${MINGW_PREFIX}/include/FTGL/"

  install -Dm644 "${srcdir}/${_realname}-${pkgver}"/COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
