# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=fungw
pkgver=1.2.1
pkgrel=0
pkgdesc="C function gateway for different programming languages"
url="http://www.repo.hu/projects/fungw/"
arch="all"
license="LGPL-2.1-or-later"
makedepends="
	duktape-dev
	lua5.1-dev
	mujs-dev
	perl-dev
	python3-dev
	tcl-dev
	"
checkdepends="dash-binsh"
subpackages="
	$pkgname-c:_plugin
	$pkgname-cli:_plugin
	$pkgname-duktape:_plugin
	$pkgname-fawk:_plugin
	$pkgname-lua:_plugin
	$pkgname-mujs:_plugin
	$pkgname-perl:_plugin
	$pkgname-python3:_plugin
	$pkgname-tcl:_plugin
	$pkgname-dev
	$pkgname-doc
	"
source="http://www.repo.hu/projects/fungw/releases/fungw-$pkgver.tar.gz
	gcc14.patch
	"

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

check() {
	cd regression
	local l; for l in bas fawk js lua pas pl py3 sh tcl; do
		SCRIPT=../doc/example/00_hello/hello.$l ./test_script 
	done
}

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

_plugin() {
	local name=${subpkgname#"$pkgname"-}
	pkgdesc="$pkgdesc ($name plugin)"
	depends="$pkgname=$pkgver-r$pkgrel"

	case "$name" in
		cli|fawk) install_if="$pkgname=$pkgver-r$pkgrel" ;;
	esac

	amove \
		usr/lib/libfungw_${name}.* \
		usr/lib/puplug/fungw_${name}.*
}

sha512sums="
252cfb6a21d6df60f4c43345b3a4bc34b4592497748fda23a6c8f03400bfc6202793f565fe7087eb1427ad3866817a06e38e3d69ec99bfc12be75ab5f9ff4d5a  fungw-1.2.1.tar.gz
0de5d5cfd3bdd4164a906ca793d7b389708693ffe1f1202a7b6a4a089ec39397cbb4116cb9b801306c28cac0d6bd10d6a8dd1f052311dc79509cdb7d1f8124d3  gcc14.patch
"
