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

_rockname=abletonlink
pkgbase=lua-$_rockname
pkgname=("lua-$_rockname" "lua54-$_rockname" "lua53-$_rockname" "lua52-$_rockname" "lua51-$_rockname")
pkgver=1.1.0
_rockrel=2
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#tag=Link-3.1.5"
        "git+https://github.com/chriskohlhoff/asio.git")
sha256sums=('26774a0493820047f1257abe967b05abe344a85ad925c84078d05d1477d34e79'
            '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.5
	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)
}

package_lua54-abletonlink() {
	_package 5.4
	depends+=(lua54)
}
