# Template file for 'lua51-luasocket'
pkgname=lua51-luasocket
version=3.1.0
revision=3
build_style=meta
hostmakedepends="luarocks-lua54"
depends="lua51"
_desc="Network support for the Lua language"
short_desc="${_desc} (5.1.x)"
maintainer="Orphaned <orphan@voidlinux.org>"
license="MIT"
homepage="https://lunarmodules.github.io/luasocket/"
distfiles="https://github.com/lunarmodules/luasocket/archive/refs/tags/v${version}.tar.gz"
checksum=bf033aeb9e62bcaa8d007df68c119c966418e8c9ef7e4f2d7e96bddeca9cca6e

_lua_versions="lua5.1 lua5.2 lua5.3 lua5.4"
for _lua_version in $_lua_versions; do
	hostmakedepends+=" ${_lua_version/./}"
	makedepends+=" ${_lua_version/./}-devel"
done

_rockname=${pkgname#lua51-}
_rocksrel=1
_package() {
	luarocks --lua-version="$1" --tree="${PKGDESTDIR}/usr/" LUA_INCDIR="${XBPS_CROSS_BASE}/usr/include/lua$1" \
		make --deps-mode=none --no-manifest "rockspecs/${_rockname}-${version}-${_rocksrel}.rockspec"
}

do_install() {
	_package 5.1
	vlicense LICENSE
}

luasocket_package() {
	depends="lua51-luasocket>=${version}_${revision}"
	short_desc+=" (transitional dummy package)"
	build_style=meta
}

lua52-luasocket_package() {
	depends="lua52"
	short_desc="${_desc} (5.2.x)"
	pkg_install() {
		_package 5.2
		vlicense LICENSE
	}
}

lua53-luasocket_package() {
	depends="lua53"
	short_desc="${_desc} (5.3.x)"
	pkg_install() {
		_package 5.3
		vlicense LICENSE
	}
}

lua54-luasocket_package() {
	depends="lua54"
	short_desc="${_desc} (5.4.x)"
	pkg_install() {
		_package 5.4
		vlicense LICENSE
	}
}
