# Contributor: Celeste <cielesti@protonmail.com>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=nsf
pkgver=2.4.0
pkgrel=0
pkgdesc="Next Scripting Framework for Tcl"
url="https://next-scripting.org/"
arch="all"
license="MIT"
depends="tcl"
makedepends="tcl-dev"
subpackages="
	$pkgname-dev
	$pkgname-doc
	$pkgname-tk::noarch
	"
source="$pkgname-$pkgver.tar.gz::https://downloads.sourceforge.net/next-scripting/nsf$pkgver.tar.gz
	fix-symlink.patch
	"
builddir="$srcdir/nsf$pkgver"

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var
	make
}

check() {
	make test
}

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

	mkdir -p "$pkgdir"/usr/share/licenses/$pkgname
	mv -v "$pkgdir"/usr/lib/nsf$pkgver/COPYRIGHT \
		"$pkgdir"/usr/share/licenses/$pkgname/

	# Rename manpages to avoid conflicting file names
	find "$pkgdir"/usr/share/man/man3 -type f \
		-name '*.3' -exec mv -v '{}' '{}nx' ';'
}

dev() {
	default_dev

	amove usr/lib/nsfConfig.sh
}

tk() {
	pkgdesc="$pkgdesc (graphical shells)"
	depends="$pkgname=$pkgver-r$pkgrel tk"

	amove usr/bin/*wish
}

sha512sums="
1e1b8b0d919e19c21512d92d45a271988769f793f4a7482accb10e4c022b46603b173103a02b25374cce615d4687e49314c93b085e608e2cff74c10ff8bf88dd  nsf-2.4.0.tar.gz
6e688577683b3c30e7b97725ecda8f842c9a2785ab48c45123964a9a0b1d75523076888a1d15d38d5e48c4ab4ab9084a002c946778a49efc1335a5cf05e95715  fix-symlink.patch
"
