# Contributor: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Jan de Groot <jgc@archlinux.org>

_pkgname=fontconfig
pkgname=$_pkgname-static
pkgver=2.13.91+48+gfcb0420
pkgrel=2
epoch=2
pkgdesc="Library for configuring and customizing font access"
url="https://www.freedesktop.org/wiki/Software/fontconfig/"
arch=(x86_64)
license=(custom)
depends=(expat-static freetype2-static)
makedepends=(git autoconf-archive gperf python-lxml python-six docbook-utils)
checkdepends=(unzip)
_commit=fcb042028126d79ea5a5fa015b2b034b98656e73  # master
options=(!emptydirs !docs staticlibs)
source=("git+https://gitlab.freedesktop.org/fontconfig/fontconfig.git#commit=$_commit")
sha256sums=('SKIP')

# a nice page to test font matching:
# http://zipcon.net/~swhite/docs/computers/browsers/fonttest.html
# http://getemoji.com/

pkgver() {
  cd fontconfig
  git describe --tags | sed 's/-/+/g'
}

prepare() {
  cd fontconfig
  NOCONFIGURE=1 ./autogen.sh
}

build() {
  cd fontconfig
  export PKG_CONFIG_PATH=/usr/static/lib/pkgconfig:/usr/lib/pkgconfig
  export PATH=$PWD:$PATH
  printf '#!/usr/bin/bash\nexec /usr/bin/pkg-config --static "$@"\n' > pkg-config
  chmod +x pkg-config
  ./configure --prefix=/usr/static \
    --sysconfdir=/etc \
    --with-templatedir=/etc/fonts/conf.avail \
    --localstatedir=/var \
    --disable-shared \
    --enable-static \
    --disable-docs
  make
}

check() {
  cd fontconfig
  make -k check
}

package() {
  cd fontconfig
  make DESTDIR="$pkgdir" install

  rm -r "$pkgdir/usr/static/bin" "$pkgdir/etc" "$pkgdir/var"
  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 COPYING
}

# vim:set sw=2 et:
