# Maintainer: Sol Bekic <s+aur at s-ol dot nu>

_rockname=abletonlink
pkgbase=lua-$_rockname
pkgname=("lua-$_rockname" "lua53-$_rockname" "lua52-$_rockname" "lua51-$_rockname")
pkgver=1.0.1
_rockrel=1
pkgrel=1
pkgdesc='Lightweight wrapper of the Ableton Link C API (abl_link)'
arch=(x86_64)
url="https://git.s-ol.nu/lua-abletonlink/-/"
license=(MIT)
depends=()
makedepends=(lua
             lua51
             lua52
             lua53
             luarocks)
source=("git+https://git.s-ol.nu/lua-$_rockname.git#tag=v$pkgver"
        "git+https://github.com/Ableton/link.git"
        "git+https://github.com/chriskohlhoff/asio.git")
sha256sums=('39c57ef04036e60467fc1c62d1a85c8951b08929574770a574853aba7599c921'
            'SKIP'
            'SKIP')

prepare() {
  cd "$srcdir/lua-$_rockname"
  git submodule init
  git config submodule.link.url "$srcdir/link"

  cd link
  git submodule init
  git config submodule.modules/asio-standalone.url "$srcdir/asio"

  cd ..
  git -c protocol.file.allow=always submodule update --recursive
}

_package() {
	cd "$srcdir/lua-$_rockname"
	luarocks --lua-version="$1" --tree="$pkgdir/usr/" \
		make --deps-mode=none --no-manifest "$_rockname-$pkgver-$_rockrel.rockspec"
}

package_lua-abletonlink() {
	_package 5.4
	depends+=(lua)
}

package_lua51-abletonlink() {
	_package 5.1
	depends+=(lua51)
}

package_lua52-abletonlink() {
	_package 5.2
	depends+=(lua52)
}

package_lua53-abletonlink() {
	_package 5.3
	depends+=(lua53)
}
