# Template file for 'lua54-cjson'
pkgname=lua54-cjson
version=2.1.0
revision=3
create_wrksrc=yes
hostmakedepends="lua51 lua52 lua53 lua54"
makedepends="lua51-devel lua52-devel lua53-devel lua54-devel"
depends="lua54"
_desc="JSON support for Lua"
short_desc="${_desc} (5.4.x)"
maintainer="Orphaned <orphan@voidlinux.org>"
license="MIT"
homepage="http://www.kyne.com.au/~mark/software/lua-cjson.php"
distfiles="http://www.kyne.com.au/~mark/software/download/lua-cjson-${version}.tar.gz"
checksum=51bc69cd55931e0cba2ceae39e9efa2483f4292da3a88a1ed470eda829f6c778

post_extract() {
	mv "lua-cjson-${version}" lua51
	cp -a lua51 lua52
	cp -a lua51 lua53
	cp -a lua51 lua54
}
do_build() {
	for x in lua51 lua52 lua53 lua54; do
		make -C "$x" \
			CC=$CC CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \
			LUA_VERSION="5.${x#lua5}" USE_INTERNAL_FPCONV=1 \
			LUA_INCLUDE_DIR="${XBPS_CROSS_BASE}/usr/include/lua5.${x#lua5}"
	done
}
do_install() {
	for x in lua51 lua52 lua53 lua54; do
		vinstall "$x/cjson.so" 755 "usr/lib/lua/5.${x#lua5}"
	done
	vlicense lua53/LICENSE
}

lua51-cjson_package() {
	depends="lua51"
	short_desc="${_desc} (5.1.x)"
	pkg_install() {
		vmove usr/lib/lua/5.1
		vlicense ${wrksrc}/lua51/LICENSE
	}
}

lua52-cjson_package() {
	depends="lua52"
	short_desc="${_desc} (5.2.x)"
	pkg_install() {
		vmove usr/lib/lua/5.2
		vlicense ${wrksrc}/lua52/LICENSE
	}
}

lua53-cjson_package() {
	depends="lua53"
	short_desc="${_desc} (5.3.x)"
	pkg_install() {
		vmove usr/lib/lua/5.3
		vlicense ${wrksrc}/lua53/LICENSE
	}
}

lua-cjson_package() {
	depends="lua53-cjson>=${version}_${revision}"
	short_desc="${_desc} (5.3.x) (transitional dummy package)"
	metapackage=yes
}
