# Maintainer: Storm Dragon <storm_dragon@stormux.org>
# Included in Slint by Didier Spaier <didier~at~slint~dot~fr>

pkgname="barnard"
pkgrel=1slint
pkgver=2026.02.09
url="https://git.stormux.org/storm/barnard"
source=(https://git.stormux.org/storm/barnard/archive/${pkgver}.tar.gz)
options=('nosrcpack')
license=('GPL2')
depends=('openal' 'opus' 'opusfile')
optdepends=('dialog: for barnard-ui')
makedepends=('google-go-lang' 'git')
startdir=$(pwd)
slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"barnard (Accessible command line mumble client.)"
"This copy of Barnard and it's associated Gumble library have been"
"modified to support usage by blind users."
"The original version from Tim Cooper is available at"
"https://github.com/layeh/barnard"
"This version has been modified by Storm Dragon and is"
"available at https://git.stormux.org/storm/barnard"
)
build() {
  if [ -d "$SRC/$pkgname" ]; then
    cd "$SRC/$pkgname"
  elif [ -d "$SRC/$pkgname-$pkgver" ]; then
    cd "$SRC/$pkgname-$pkgver"
  else
    echo "Source directory for $pkgname not found." >&2
    return 1
  fi

  export GOCACHE="${GOCACHE:-"$SRC/go-cache"}"
  export GOMODCACHE="${GOMODCACHE:-"$SRC/go"}"
  export GOTMPDIR="${GOTMPDIR:-"$SRC"}"
  export GO111MODULE=on
  export CGO_ENABLED=1

  go build -v -o barnard .
  install -Dm755 barnard "$PKG/usr/bin/barnard"
  if [ -f barnard-ui ]; then
    install -Dm755 barnard-ui "$PKG/usr/bin/barnard-ui"
  fi


  if [ -f "extras/$pkgname-sound.sh" ]; then
    install -Dm755 "extras/$pkgname-sound.sh" \
      "$PKG/usr/share/$pkgname/$pkgname-sound.sh"
  fi

  mkdir -p "$PKG/usr/doc/$pkgname-$pkgver"
  if [ -f README.md ]; then
    cp -a README.md "$PKG/usr/doc/$pkgname-$pkgver/"
  fi
  if [ -f LICENSE ]; then
    cp -a LICENSE "$PKG/usr/doc/$pkgname-$pkgver/"
  fi
  if [ -f COPYING ]; then
    cp -a COPYING "$PKG/usr/doc/$pkgname-$pkgver/"
  fi
  cp "$startdir/SLKBUILD" "$PKG/usr/doc/$pkgname-$pkgver/SLKBUILD"
}
