# Contributor: Mika Havela <mika.havela@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=fontconfig
pkgver=2.15.0
pkgrel=3
pkgdesc="Library for configuring and customizing font access"
url="https://www.freedesktop.org/wiki/Software/fontconfig"
arch="all"
license="MIT"
makedepends="freetype-dev expat-dev python3-dev gperf util-linux-dev docbook2x"
checkdepends="bash json-c-dev uuidgen curl"
triggers="$pkgname.trigger=/usr/share/fonts/*"
subpackages="$pkgname-static $pkgname-dev $pkgname-doc"
source="https://www.freedesktop.org/software/fontconfig/release/fontconfig-$pkgver.tar.gz
	fix-arithmetic.patch
	"

# For generation of man pages
export DOC2MAN=docbook2x-man

prepare() {
	default_prepare
	update_config_sub
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--localstatedir=/var \
		--enable-static \
		--enable-docs \
		--disable-nls
	make

	# test tries to download google fonts from internet
	# https://gitlab.freedesktop.org/fontconfig/fontconfig/-/blob/2.15.0/test/run-test.sh#L435
	chmod -x test/test-crbug1004254
}

check() {
	make -j1 check || (cat test/test-suite.log; false)
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
4feb02935d94002ed0aba5b9e44bab47c14bbc0ecfcdcdb14c9004681109cef51415cd2368e959f8c4bd2e67ff9e8fcf45102a4bd8728b2f50b3c56723fcb81c  fontconfig-2.15.0.tar.gz
9e0a010c8075085dedfe6bda1b26d8a7c693091e3ba5e823da8dd79468116c7b6e4a94b1173649999075cf9532bfc81adc97d0182bbff7635e9699bc44d6aa1c  fix-arithmetic.patch
"
