# $Id$
# Maintainer: Jan de Groot <jgc@archlinux.org>

pkgname=fontconfig
pkgver=2.12.1
pkgrel=4
pkgdesc="A library for configuring and customizing font access"
arch=(i686 x86_64)
url="https://www.freedesktop.org/wiki/Software/fontconfig/"
license=('custom')
depends=('expat' 'freetype2')
makedepends=('python2' 'docbook2x')
install=fontconfig.install
source=(https://www.freedesktop.org/software/$pkgname/release/$pkgname-$pkgver.tar.bz2
        fontconfig.hook
        0001-fix-test-with-freetype2-2.7.1.patch)
sha256sums=('b449a3e10c47e1d1c7a6ec6e2016cca73d3bd68fbbd4f0ae5cc6b573f7d6c7f3'
            '672f6a1c5e164671955ce807e670306194142a1794ce88df653aa717a972e274'
            'b4992aab4e2b4ddae01f7565486752fa877edb6cd5ed435e15938ed21dfe22c8')

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

prepare() {
  cd $pkgname-$pkgver
  patch -Np1 -i ../0001-fix-test-with-freetype2-2.7.1.patch
}

build() {
  cd $pkgname-$pkgver
  ./configure --prefix=/usr \
    --sysconfdir=/etc \
    --with-templatedir=/etc/fonts/conf.avail \
    --with-xmldir=/etc/fonts \
    --localstatedir=/var \
    --disable-static \
    --with-default-fonts=/usr/share/fonts \
    --with-add-fonts=/usr/share/fonts
  make
}

check() {
  cd $pkgname-$pkgver
  make -k check
}

_install_conf() {
  install -m644 "$1" "$pkgdir/etc/fonts/conf.avail"
  ln -s "../conf.avail/${1##*/}" "$pkgdir/etc/fonts/conf.d"
}

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install
  install -Dm644 COPYING "$pkgdir/usr/share/licenses/$pkgname/COPYING"
  install -Dm644 ../fontconfig.hook "$pkgdir/usr/share/libalpm/hooks/fontconfig.hook"
}