# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=pixman
pkgver=0.46.0
pkgrel=0
pkgdesc="Low-level pixel manipulation library"
url="https://gitlab.freedesktop.org/pixman"
arch="all"
license="MIT"
makedepends="meson libpng-dev linux-headers"
subpackages="$pkgname-static $pkgname-dev $pkgname-dbg"
source="https://xorg.freedesktop.org/releases/individual/lib/pixman-$pkgver.tar.xz"

case "$CARCH" in
	# segfault in multiple tests
	riscv64) options="!check" ;;
esac


build() {
	case "$CARCH" in
	armhf|riscv64)
		# target-specific builtin not available
		local lto=false
		;;
	*)
		local lto=true
		;;
	esac
	# We need to increase the stacksize here: https://gitlab.gnome.org/GNOME/librsvg/-/issues/595
	LDFLAGS="$LDFLAGS -Wl,-z,stack-size=2097152" \
	# auto-features=auto: a lot of features are architecture dependent
	abuild-meson \
		--auto-features=auto \
		-Db_lto=$lto \
		-Ddefault_library=both \
		-Dlibpng=enabled \
		-Ddemos=disabled \
		-Dtests="$(want_check && echo enabled || echo disabled)" \
		. output
	meson compile -C output
}

check() {
	meson test --print-errorlogs -C output -t 10
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

sha512sums="
c7ef987b7db89c58278c537f862bc9eb17c19f8288a3b7e88f8501a0486662f1e2cb6a2c0b81d4bf0464310475192428d6e29d05a6ae3cfc1d2c0941fbb0b9a3  pixman-0.46.0.tar.xz
"