# Contributor: rubicon <rubicon@mailo.com>
# Maintainer: rubicon <rubicon@mailo.com>
pkgname=es-shell
pkgver=0.9.2_git20250510
_gitrev=cc6937f39133c1d8b5f6c31c3de939db147cd816
pkgrel=0
pkgdesc="Shell with higher-order functions"
url="https://wryun.github.io/es-shell/"
arch="all"
license="Public-Domain"
makedepends="autoconf automake byacc libtool readline-dev"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/wryun/es-shell/archive/$_gitrev.tar.gz"
builddir="$srcdir/$pkgname-$_gitrev"

prepare() {
	default_prepare

	autoreconf -fvi
}

build() {
	./configure \
		--build="$CBUILD" \
		--host="$CHOST" \
		--prefix=/usr \
		--with-readline
	make
}

check() {
	make test
}

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

	sed -i 's|#! /bin/es|#!/usr/bin/es|' esdebug

	install -Dvm644 README.md CHANGES COPYING esdebug \
		initial.es doc/usenix-w93.ps \
		doc/ERRATA doc/TODO doc/es-list.gz \
		-t "$pkgdir"/usr/share/doc/$pkgname

	cp -vr examples "$pkgdir"/usr/share/doc/$pkgname/
}

sha512sums="
ed8b6202bf24e14b082ea3bcf124d6f04eba01bf41937692b73ec327c4d4b60b98c0ce622886a1063c5df6aefd0a8c1b64d7618c9aa6bd482d64671573624169  es-shell-0.9.2_git20250510.tar.gz
"
