# Maintainer (AUR): lantw44 (at) gmail (dot) com
# Maintainer `echo V29qdGVrIEtvc2lvciA8a3dvanR1c0Bwcm90b25tYWlsLmNvbT4K | base64 -d`
# Modified from https://git.parabola.nu/abslibre.git/tree/pcr/guile-ssh/PKGBUILD?id=819e924800722d4866955bda48654f0e2a6e0204

pkgname=guile-ssh
pkgver=0.11.2
pkgrel=2
pkgdesc='SSH module for Guile based on libssh'
arch=(i686 x86_64)
url="https://github.com/artyom-poptsov/guile-ssh"
license=('GPL3')
depends=(
  'guile>=2.0.9'
  'libssh>=0.7.3')
options=(!strip)
source=("https://github.com/artyom-poptsov/${pkgname}/archive/v${pkgver}.tar.gz")

sha512sums=('f61ef956e06c9b40fef2c636450d54e81fc6f3718b6819c8de3d770489a3cf9ef1f4a1bb6767e56e88ad0e729d058b8c5e06ff8f79a34e32924d5c294c4763b4')

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  autoreconf -fi
  ./configure --prefix=/usr --disable-rpath
  make
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  # make check # Tests unexpectedly fail
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install

  # The default makepkg strip option cannot be used here becaues .go
  # binaries installed elswhere must not be stripped.
  # To keep user-defined 'strip' and 'debug' options useful, we still
  # depend on 'tidy_strip' function provided by makepkg to do the stripping
  # work. To make the function useful, we have to temporarily remove the
  # '!strip' option from 'options' array. However, assignments to 'options'
  # cause mksrcinfo to insert wrong lines to .SRCINFO, so they have to be
  # put in eval.
  eval 'options=()'
  cd "${pkgdir}/usr/lib"
  mv ./guile/ ../tmpguile
  tidy_strip
  eval 'options=("!strip")'
  mv ../tmpguile ./guile
}
