# Packager = Tuxcore <dev@tuxcore.org> 
pkgbase=libappindicator
pkgname=("${pkgbase}-gtk"{2,3})
_bzrtag=12.10.0
_bzrrev=298
pkgver=${_bzrtag}.r${_bzrrev}
pkgrel=4
pkgdesc='Allow applications to extend a menu via Ayatana indicators in Unity, KDE or Systray'
url='https://launchpad.net/libappindicator'
arch=('x86_64')
license=('GPL-3.0-only AND LGPL-2.1-only AND LGPL-3.0-only')
makedepends=('breezy' 'dbus-glib' 'glib2-devel' 'gnome-common' 'gobject-introspection' 'gtk-doc' 'libdbusmenu-gtk'{2,3} 'vala')
options=('!emptydirs')
source=($pkgbase::bzr+https://code.launchpad.net/~indicator-applet-developers/libappindicator/trunk#revision=$_bzrrev
        libappindicator-fix-unfallback.patch)
sha512sums=('023cb633e9750e279b19a6dc2d42d37bfc15d6c992017be3a6b71881579654578e9da3058d44ab400752f86411a362e676abb217ca47f14d24e43e6c26107f4d'
            'ace190fea1b0e21fb164ff531788ce8c2ad9fc00c23227a75d844b1c89f78e8da705f35dac09677f92f053561f89a9c0a73b23af07cb22f9fdaa28afbd10a516')

prepare() {
  (cd ${pkgbase}
    # Fix unfallback from status icon
    patch -Np0 -i ../libappindicator-fix-unfallback.patch

    NOCONFIGURE=1 ./autogen.sh
  )
  cp -ra ${pkgbase}{,-gtk2}
}

build() {
  msg2 'Building gtk3...'
  (cd ${pkgbase}
    ./configure --prefix=/usr \
      --sysconfdir=/etc \
      --localstatedir=/var \
      --with-gtk=3 \
      --enable-gtk-doc
    sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
    make
  )

  msg2 'Building gtk2...'
  (cd ${pkgbase}-gtk2
    ./configure --prefix=/usr \
      --sysconfdir=/etc \
      --localstatedir=/var \
      --with-gtk=2 \
      --disable-introspection
    sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
    make
  )
}

package_libappindicator-gtk2() {
  pkgdesc+=' (GTK+ 2 library)'
  depends=('glib2' 'glibc' 'gtk2' 'libdbusmenu-glib' 'libdbusmenu-gtk2')

  cd ${pkgbase}-gtk2
  make -j1 DESTDIR="${pkgdir}" install
}

package_libappindicator-gtk3() {
  pkgdesc+=' (GTK+ 3 library)'
  depends=('glib2' 'glibc' 'gtk3' 'libdbusmenu-glib' 'libdbusmenu-gtk3')

  cd ${pkgbase}
  make -j1 DESTDIR="${pkgdir}" install
}

# vim: ts=2 sw=2 et:
