# Contributor: Nick Black <dankamongmen@gmail.com>
# Maintainer: Nick Black <dankamongmen@gmail.com>
pkgname=notcurses
pkgver=3.0.13
pkgrel=0
pkgdesc="blingful character graphics and TUI library"
url="https://nick-black.com/dankwiki/index.php/Notcurses"
arch="all"
license="Apache-2.0"
# FIXME gpm-libs is still in testing. once it moves to community, dep on it,
# and add -DUSE_GPM=on to build().
makedepends="cmake doctest-dev ffmpeg-dev libdeflate-dev libunistring-dev
	linux-headers ncurses-dev ncurses-terminfo samurai"
subpackages="$pkgname-dbg $pkgname-static $pkgname-dev $pkgname-doc
	$pkgname-libs $pkgname-demo ncneofetch ncls $pkgname-view $pkgname-tetris"
source="https://github.com/dankamongmen/notcurses/archive/v$pkgver/notcurses-$pkgver.tar.gz
	https://github.com/dankamongmen/notcurses/releases/download/v$pkgver/notcurses-doc-$pkgver.tar.gz
	"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DUSE_PANDOC=off \
		-DUSE_QRCODEGEN=off \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	TERM=vt100 \
	ctest -V --test-dir build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	for i in 1 3 ; do
		find "$srcdir" -maxdepth 1 -type f -iname \*.$i -exec echo "$pkgdir"/usr/share/man/man$i {} \;
		find "$srcdir" -maxdepth 1 -type f -iname \*.$i -exec install -Dm644 -t "$pkgdir"/usr/share/man/man$i {} \;
	done
}

libs() {
	amove usr/lib/libnotcurses*.so.*
}

demo() {
	amove usr/bin/notcurses-demo
	amove usr/bin/notcurses-tester
	amove usr/bin/notcurses-info
	amove usr/share/notcurses
}

ncneofetch() {
	amove usr/bin/ncneofetch
}

ncls() {
	amove usr/bin/ncls
}

view() {
	amove usr/bin/ncplayer
}

tetris() {
	amove usr/bin/nctetris
}

sha512sums="
8194c72a4e8907d017a3c6069c573c97a2896b17756c4b0e813814f94437d42b34e3d648d591d5851c894207a705ef3d76895031ec73c27b5dc85c6b71bbf4c7  notcurses-3.0.13.tar.gz
30c6d741b8512adb1ff21d04f8d22a4f7d0a4a86e3f2e5d2dbc4d7fabf22da4460901dbd21a084996e782553b7236ea6d57d0b22b537b9bf45612e6fb7cef487  notcurses-doc-3.0.13.tar.gz
"
