# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: Renato Silva <br.renatosilva@gmail.com>

_realname=pango
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.40.1
pkgrel=1
pkgdesc="A library for layout and rendering of text (mingw-w64)"
arch=('any')
url="http://www.pango.org"

# TODO: what is the license for the package as a whole? The README file says
# that most of the code is LGPL but some parts are "GPL/FreeType". However this
# non-LGPL note makes reference to non-existing files, so would LGPL apply to
# the whole code? If this note is still correct, are the GPL/FreeType parts
# under either or both of these licenses, and which versions? What license is
# compatible with the answers?
license=(partial:'LGPL2')

makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
            "${MINGW_PACKAGE_PREFIX}-pkg-config"
            "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
            "gtk-doc")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-cairo"
         "${MINGW_PACKAGE_PREFIX}-freetype"
         "${MINGW_PACKAGE_PREFIX}-fontconfig"
         "${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-harfbuzz")
options=('staticlibs' 'strip' 'emptydirs')
source=("https://download.gnome.org/sources/pango/${pkgver:0:4}/${_realname}-${pkgver}.tar.xz"
        0001-no-unconditional-xft-please.all.patch
        0002-msvc-is-impotent-but-not.mingw.patch)
sha256sums=('e27af54172c72b3ac6be53c9a4c67053e16c905e02addcf3a603ceb2005c1a40'
            'eccc044bbd156b252f5a13f7894c3a6cd1efc6ea80eaee57a5865895b192616d'
            '240d21474157c0deabc2660593ac0414565ddf30c304b08b74a09072c910b34d')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i ${srcdir}/0001-no-unconditional-xft-please.all.patch
  patch -p1 -i ${srcdir}/0002-msvc-is-impotent-but-not.mingw.patch

  autoreconf -fi
  sed -i 's/have_libthai=true/have_libthai=false/' configure
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p ${srcdir}/build-${MINGW_CHOST} && cd ${srcdir}/build-${MINGW_CHOST}
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-introspection \
    --disable-debug \
    --enable-shared \
    --enable-static
  make
}

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

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