# Maintainer: Balló György <ballogyor+arch at gmail dot com>

pkgname=sugar-toolkit-gtk3
pkgver=0.114
pkgrel=2
pkgdesc="Sugar GTK library"
arch=('x86_64')
url="https://sugarlabs.org/"
license=('LGPL')
depends=('alsa-lib' 'gtk3' 'libsm' 'python2-cairo' 'python2-dateutil' 'python2-decorator'
         'python2-six' 'python2-telepathy' 'sugar-artwork' 'sugar-datastore'
         'telepathy-mission-control' 'unzip')
makedepends=('intltool' 'gobject-introspection')
optdepends=('webkit2gtk: run sugar-activity-web')
source=(https://download.sugarlabs.org/sources/sucrose/glucose/$pkgname/$pkgname-$pkgver.tar.xz)
sha256sums=('4b8ca467b85b6273fdb3ae86b1afa5071f4c0c6e11a27e9166a394620c2c77e5')

prepare() {
  cd $pkgname-$pkgver
  # Don't use incomplete python3 port
  sed -i 's/exec sugar-activity3/exec sugar-activity/' bin/sugar-activity-web
  sed -i '/dist_bin_SCRIPTS/ s/ sugar-activity3//' bin/Makefile.{am,in}
}

build() {
  cd $pkgname-$pkgver
  # Disable hardened build until fixed upstream
  # https://bugs.sugarlabs.org/ticket/4886
  export CFLAGS=${CFLAGS/ -fno-plt}
  export LDFLAGS=${LDFLAGS/,-z,now}

  ./configure --prefix=/usr PYTHON=python2
  sed -i 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make -j1
}

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