# Contributor: rubicon <rubicon@mailo.com>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=txr
pkgver=299
pkgrel=0
pkgdesc="Programming language for convenient data munging"
url="https://www.nongnu.org/txr/"
# s390x: ftbfs (struct jmp in unwind.h not ported)
# riscv64: tests/006/freeform-5.txr segfaults
arch="all !s390x !riscv64"
license="BSD-2-Clause"
makedepends="libffi-dev zlib-dev"
subpackages="$pkgname-doc $pkgname-vim::noarch"
source="https://www.kylheku.com/cgit/txr/snapshot/txr-$pkgver.tar.gz"

build() {
	./configure --prefix=/usr
	make
}

check() {
	case "$CARCH" in
	aarch64)
		msg "Disabling IPv6 test for aarch64 in 014/dgram-stream.tl"
		sed -i 's/,\*maybe-ipv6//' tests/014/dgram-stream.tl
		;;
	x86)
		msg "Disabling 012/cont.tl and 012/compile.tl tests on x86"
		rm -v tests/012/cont.tl tests/012/compile.tl
		;;
	esac

	make tests
}

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

	install -Dvm644 LICENSE METALICENSE \
		-t "$pkgdir"/usr/share/licenses/$pkgname/

	install -Dvm644 ./*.vim \
		-t "$pkgdir"/usr/share/vim/vimfiles/syntax/
}

vim() {
	pkgdesc="Vim syntax for $pkgname"
	depends=
	install_if="$pkgname=$pkgver-r$pkgrel vim"

	amove usr/share/vim/vimfiles/syntax
}

sha512sums="
1b693fbc8f9592566a47bfb440b91fb526ba1f78f6787ba756e81d4b41945841054f1d7d0344e454a84b7b9778260c45783756bc08057007b817d3c0a5c8dfdc  txr-299.tar.gz
"
