# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
_luaversions="5.1 5.2 5.3"
pkgname=lua-lunix
_pkgname=lunix
pkgver=20190403
pkgrel=0
pkgdesc="Comprehensive Unix API Module for Lua"
url="https://github.com/wahern/lunix"
arch="all"
license="MIT"
for _v in $_luaversions; do
	makedepends="$makedepends lua$_v-dev"
	subpackages="$subpackages lua$_v-$_pkgname:_package"
done
source="https://github.com/wahern/lunix/archive/rel-$pkgver/$pkgname-$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-rel-$pkgver"

build() {
	local lver; for lver in $_luaversions; do
		msg "Building for Lua $lver..."
		make all$lver
	done
}

package() {
	mkdir -p "$pkgdir"
}

_package() {
	local lver="${subpkgname:3:3}"
	pkgdesc="$pkgdesc $lver"
	install_if="lua$lver $pkgname=$pkgver-r$pkgrel"
	local rockdir="$subpkgdir/usr/lib/luarocks/rocks-$lver/$_pkgname/$pkgver-1"

	cd "$builddir"
	make prefix="/usr" DESTDIR="$subpkgdir" install$lver

	mkdir -p "$rockdir"
	echo 'rock_manifest = {}' > "$rockdir"/rock_manifest
}

sha512sums="f432284896f00c787993bbe79da871b3a903518641adba2d36e7ebdbdadcf2fa18acda0b7c0823d994a9e012436955f8feed6901bc03aed1f090a67ffd555772  lua-lunix-20190403.tar.gz"
