# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>

setvar _luaversions = ""5.1 5.2 5.3""
setvar pkgname = 'lua-ossl'
setvar _pkgname = 'luaossl'
setvar pkgver = '20161214'
setvar _ver = ${pkgver%_git*}
setvar pkgrel = '1'
setvar pkgdesc = ""A comprehensive OpenSSL Lua module""
setvar url = ""http://25thandclement.com/~william/projects/luaossl.html""
setvar arch = ""all""
setvar license = ""MIT""
setvar depends = """"
setvar makedepends = ""libressl-dev""
setvar subpackages = """"
for _v in $_luaversions {
	setvar makedepends = ""$makedepends lua$_v-dev""
	setvar subpackages = ""$subpackages lua$_v-${pkgname#lua-}:_package""
}
setvar source = ""luaossl-$_ver.tar.gz::https://github.com/wahern/$_pkgname/archive/rel-$pkgver.tar.gz""
setvar builddir = ""$srcdir/$_pkgname-rel-$pkgver""

proc build {
	cd $builddir

	make config prefix=/usr || return 1
	local lver; for lver in $_luaversions {
		make openssl$lver || return 1
	}
}

proc package {
	mkdir -p $pkgdir
}

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

	cd $builddir
	make DESTDIR="$subpkgdir" install$lver

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

setvar sha512sums = ""4fd0685ae80fc6f999d806adb9e67016ddca5175e8ee0fedeaae3dace709157bfd87cdbeb6d808a0539c53be60193e1ac805358a7ea2f21246c19a8b6a7d7264  luaossl-20161214.tar.gz""