# Maintainer: Erich Eckner <arch at eckner dot net>
# Contributor: Alec Mev <alec@mev.earth>

pkgname=asdf-vm
pkgver=0.10.0
pkgrel=1
pkgdesc='Extendable version manager with support for Ruby, Node.js, Elixir, Erlang & more'
arch=('any')
url='https://asdf-vm.com'
license=('MIT')
depends=(
  'autoconf'
  'automake'
  'libffi'
  'libtool'
  'libxslt'
  'libyaml'
  'ncurses'
  'openssl'
  'readline'
  'unixodbc'
)
optdepends=(
  'bash-completion: For completions to work in Bash'
  'unzip: Needed by some plugins, like Elixir'
)
install=asdf-vm.install
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/asdf-vm/asdf/archive/v${pkgver}.tar.gz")
sha512sums=('ba680bf388d78f26c3cb930e2741d5c5bd7d9e2aa40edf45d27f23598237e94fdc09b4d9e8e9c4b66acbb442adbb378b34bfa5c02420f82e85c392b2d50cbc45')

package() {
  cd "asdf-${pkgver}"

  local dst="${pkgdir}/opt/${pkgname}"
  mkdir -p "${dst}"

  cp -r bin       "${dst}"
  cp -r lib       "${dst}"
  cp    asdf.fish "${dst}"
  cp    asdf.sh   "${dst}"
  cp    defaults  "${dst}"
  cp    help.txt  "${dst}"
  cp    LICENSE   "${dst}"

  local usrshare="${pkgdir}/usr/share"
  local docdir="${usrshare}/doc/${pkgname}"
  mkdir -p "${docdir}"

  cp docs/[^_]*.md "${docdir}"
  cp help.txt      "${docdir}"
  cp README.md     "${docdir}"

  install -Dm644 -t "${usrshare}/licenses/${pkgname}/" LICENSE

  cd completions

  install -Dm644 asdf.bash "${usrshare}/bash-completion/completions/asdf"
  install -Dm644 asdf.fish "${usrshare}/fish/vendor_completions.d/asdf.fish"
  install -Dm644 _asdf     "${usrshare}/zsh/site-functions/_asdf"
}