# vim: syn=sh ft=sh et sw=2 sts=2 ts=2 tw=0:
#Packager: Cyrille Pontvieux <jrd~at~salixos~dot~org>

pkgname=snack
pkgver=2.2.10
pkgrel=3cp

source=(http://www.speech.kth.se/snack/dist/${pkgname}${pkgver}.tar.gz http://aur.archlinux.org/packages/sn/snack/snack.tar.gz)
sourcetemplate=http://people.salixos.org/jrd/salix/$pkgname/$pkgver-\$arch-$pkgrel/
docs=("readme" "install" "copying" "changelog" "authors" "news" "todo" "changes" "bsd.txt")
url=http://www.speech.kth.se/snack/

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"$pkgname (Sound toolkit for scripts)"
"The Snack Sound Toolkit is designed to be used with a scripting"
"language such as Tcl/Tk or Python."
"Using Snack you can create powerful multi-platform audio applications"
"with just a few lines of code."
"Snack has commands for basic sound handling, such as playback,"
"recording, file and socket I/O."
"Snack also provides primitives for sound visualization, e.g. waveforms"
"and spectrograms. Snack has also successfully been applied to other"
"one-dimensional signals."
)

build() {
  cd $SRC/${pkgname}${pkgver}/unix || return 1
  # already defined by glibc
  sed -i 's:#define roundf.*:/* \0 */:' ../generic/jkFormatMP3.c || return 1
  # patch for Alsa (borrow from Arch, same patch you can find everywhere)
  patch -p0 -i $SRC/snack/alsa.patch || return 1
  # some CLFAGS are missing from the tlcConfig.sh
  sed -i 's:CFLAGS=\$TCL_SHLIB_CFLAGS:CFLAGS="$TCL_SHLIB_CFLAGS $TCL_EXTRA_CFLAGS":' configure.in || return 1
  # tcl.m4 is missing in the unix directory but is present in the win directory
  cp ../win/tcl.m4 . || return 1
  autoconf || return 1
  ./configure \
    --prefix=/usr \
    --libdir=/usr/lib${LIBDIRSUFFIX} \
    --localstatedir=/var \
    --sysconfdir=/etc \
    --build=$arch-slackware-linux \
    --enable-alsa \
    --with-tcl=/usr/lib${LIBDIRSUFFIX} \
    --with-tk=/usr/lib${LIBDIRSUFFIX} \
    || return 1
  make -j $numjobs || return 1
  make install DESTDIR=$PKG || return 1
  # install the python/tk gui
  cd ../python
  python setup.py install --prefix=/usr --root=$PKG || return 1
  mkdir -p $PKG/usr/bin
  cat <<EOF > $PKG/usr/bin/tkSnack
#!/bin/sh
python /usr/lib${LIBDIRSUFFIX}/python*/site-packages/tkSnack.py
EOF
  chmod +x $PKG/usr/bin/tkSnack
  # copy the documentation and examples
  mkdir -p $PKG/usr/doc/$pkgname-$pkgver
  cp -r ../demos ../doc ../ext $PKG/usr/doc/$pkgname-$pkgver/
}