# Packager = Tuxcore <dev@tuxcore.org> 
pkgbase=foot
pkgdesc='Fast, lightweight, and minimalistic Wayland terminal emulator'
pkgname=($pkgbase $pkgbase-terminfo)
pkgver=1.17.2
pkgrel=1
url="https://codeberg.org/dnkl/$pkgbase"
arch=(x86_64)
license=(MIT)
makedepends=(fcft
             fontconfig
             libutf8proc
             libxkbcommon
             llvm
             meson
             ncurses
             ninja
             pixman
             python
             scdoc
             sway
             tllist
             wayland
             wayland-protocols)
optdepends=('libutempter: utmp logging')
backup=(etc/xdg/foot/foot.ini)
source=("$pkgname-$pkgver.tar.gz::$url/archive/$pkgver.tar.gz")
sha256sums=('6b6c52f3e6d9ad357b9704996ce3039523c87df7b8e00a9250f8858d16495bf6')

build() {
	cd "$pkgbase"
	./pgo/pgo.sh \
		full-headless-sway \
		. build \
		-Dterminfo=disabled \
		--prefix=/usr \
		--wrap-mode=nodownload
	sed 's/@default_terminfo@/foot-extra/g' foot.info |
		tic -x -o build -e foot-extra,foot-extra-direct -
}

check() {
	cd "$pkgbase"
	ninja -C build test
}

package_foot() {
	optdepends=('foot-terminfo: extra non-standard features over terminfo included in ncurses'
	            'libnotify: desktop notifications'
	            'xdg-utils: URI launching')
	depends=(fcft
	         fontconfig
	         libfcft.so
	         libutf8proc
	         libxkbcommon
	         ncurses
	         pixman
	         wayland)
	cd "$pkgbase"
	DESTDIR="$pkgdir" ninja -C build install
	install -Dm0644 -t "$pkgdir/usr/share/licenses/$pkgname/" LICENSE
}

package_foot-terminfo() {
	pkgdesc="Extra non-standard terminfo files for $pkgbase, a Wayland terminal emulator"
	depends=(ncurses)
	cd "$pkgbase"
	install -Dm0644 -t "$pkgdir/usr/share/terminfo/f/" build/f/foot-extra*
	install -Dm0644 -t "$pkgdir/usr/share/licenses/$pkgname/" LICENSE
}
