# Maintainer: Ricky Wu <rickleaf.wu@gmail.com>
# Contributor: ImperatorS79 <fevrier.simon@gmail.com>
# Contributoor: Ray Donnelly <mingw.android@gmail.com>

_realname=luarocks
pkgbase=mingw-w64-lua-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-lua-${_realname}")
pkgver=3.5.0
pkgrel=1
pkgdesc="the package manager for Lua modules (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://luarocks.org"
license=("MIT")
depends=("${MINGW_PACKAGE_PREFIX}-lua")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "unzip")
options=('staticlibs' 'strip')
source=("https://luarocks.org/releases/${_realname}-${pkgver}.tar.gz")
sha256sums=('701d0cc0c7e97cc2cf2c2f4068fce45e52a8854f5dc6c9e49e2014202eec9a4f')

prepare() {
  plain 'No Step'
}

build() {
  cd "${srcdir}/${_realname}-${pkgver}"
  ./configure --prefix=${MINGW_PREFIX} --lua-version=5.4 --with-lua-interpreter=lua.exe
  make ./build/luarocks ./build/luarocks-admin ./build/config-5.4.lua
  make LUA_VERSION=5.1 LUA_INTERPRETER=lua5.1.exe LUA_INCDIR=${MINGW_PREFIX}/include/lua5.1 ./build/config-5.1.lua
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
  make DESTDIR="$pkgdir" LUA_VERSION=5.1 install-config
}
