# Contributor (Fluke): Ricky Wu <rickleaf.wu@gmail.com>

_realname=lsqlite3
pkgbase=mingw-w64-lua-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-lua51-${_realname}")
pkgver=0.9.6
pkgrel=2
pkgdesc="LuaSQLite is a Lua 5 binding to allow users/developers to manipulate SQLite 2 and SQLite 3 databases (through different implementations) from lua (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="http://lua.sqlite.org"
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-lua51"
         "${MINGW_PACKAGE_PREFIX}-sqlite3")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc")
source=("lsqlite3_${pkgver}.zip::http://lua.sqlite.org/index.cgi/zip/lsqlite3_v${pkgver//./}.zip?uuid=v${pkgver}"
        "installpath.lua"
        "lunit.lua"
        "Makefile.mingw")
sha256sums=('11aed1f9622ae43f8c1473cfddc7cd841c534cbb3bfa27d41d99e2fa8f8c7a48'
            'd9b058b10d1d6e0fc1ac9338193c8b8b25e808e00955ce13ef1c91c6af0c9d3a'
            'ae756636ed73147259cb55e13768d88bef5e7fa3373209c886ab46e8ea89b92f'
            '0f8e44da73038683dfb21430bec2beda97b070adb7c4b4f84402717e1474193e')

prepare() {
  cd "${srcdir}/${_realname}_v${pkgver//./}"
  cp ../installpath.lua .
  cp ../lunit.lua .
  cp ../Makefile.mingw .
  mkdir -p tmp
}

build() {
  cd "${srcdir}/${_realname}_v${pkgver//./}"

  make -f Makefile.mingw
}

package() {
  cd "${srcdir}/${_realname}_v${pkgver//./}"
  install -Dm755 lsqlite3.dll "${pkgdir}${MINGW_PREFIX}/lib/lua/5.1/lsqlite3.dll"
}
