# Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>

pkgname=tktreectrl
pkgver=2.4.1
pkgrel=2
_tkver=8.6.0
pkgdesc="A flexible listbox widget for Tk."
arch=('i686' 'x86_64')
url="http://tktreectrl.sourceforge.net/"
license=('custom')
depends=('tcl' 'tk' 'libx11')
source=("http://downloads.sourceforge.net/project/$pkgname/$pkgname/$pkgname-$pkgver/$pkgname-$pkgver.tar.gz")
sha256sums=('c2d19cfc7ce8b150cb50a6b63dc6327c91fb71f76b4f2947e0334a15d5f869d3')

build() {
  cd ${srcdir}/${pkgname}-${pkgver}

  export CFLAGS="$CFLAGS -I/usr/include/tk-private/generic -I/usr/include/tk-private/unix"

  if [ "$CARCH" = "x86_64" ]; then
    ./configure --prefix=/usr --enable-threads --enable-64bit
  else
    ./configure --prefix=/usr --enable-threads --disable-64bit
  fi

  #sed -i \
  #"s#-I\"/usr/include\" -I\"/usr/include\"#\
  #-I\"/usr/include\" -I\"../tk${_tkver}/generic\" -I\"../tk${_tkver}/unix\"#\
  #g" Makefile

  make
}

package() {
  cd ${srcdir}/${pkgname}-${pkgver}

  make DESTDIR=${pkgdir} install

  mkdir -p ${pkgdir}/usr/share/doc/tktreectrl
  mv ${pkgdir}/usr/lib/treectrl${pkgver}/htmldoc ${pkgdir}/usr/share/doc/tktreectrl/

  # install license
  install -Dm644 license.terms ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE
}
