# Packager = Tuxcore <dev@tuxcore.org> 
pkgbase=libdbusmenu
pkgname=("${pkgbase}-glib" "${pkgbase}-gtk"{2,3})
_bzrtag=16.04.0
_bzrrev=498
pkgver=${_bzrtag}.r${_bzrrev}
pkgrel=2
pkgdesc='Library for passing menus over DBus'
url='https://launchpad.net/libdbusmenu'
arch=('x86_64')
license=('GPL3' 'LGPL2.1' 'LGPL3')
makedepends=('breezy' 'gnome-common' 'gobject-introspection' 'gtk2' 'gtk3' 'intltool' 'vala')
options=('!emptydirs')
source=($pkgbase::bzr+https://code.launchpad.net/~dbusmenu-team/libdbusmenu/trunk.16.10#revision=$_bzrrev)
sha512sums=('SKIP')

prepare() {
  (cd ${pkgbase}
    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
    sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
    make
  )
}

package_libdbusmenu-glib() {
  depends=('glib2')

  cd ${pkgbase}
  make -j1 -C libdbusmenu-glib DESTDIR="${pkgdir}" install
  make -j1 -C docs/libdbusmenu-glib DESTDIR="${pkgdir}" install
}

package_libdbusmenu-gtk2() {
  pkgdesc+=" (GTK+ 2 library)"
  depends=("${pkgbase}-glib" 'gtk2')

  cd ${pkgbase}-gtk2
  make -j1 -C libdbusmenu-glib DESTDIR="${pkgdir}" install
  make -j1 -C libdbusmenu-gtk DESTDIR="${pkgdir}" install
  make -j1 -C libdbusmenu-glib DESTDIR="${pkgdir}" uninstall
}

package_libdbusmenu-gtk3() {
  pkgdesc+=" (GTK+ 3 library)"
  depends=("${pkgbase}-glib" 'gtk3')

  cd ${pkgbase}
  make -j1 -C libdbusmenu-glib DESTDIR="${pkgdir}" install
  make -j1 -C libdbusmenu-gtk DESTDIR="${pkgdir}" install
  make -j1 -C libdbusmenu-glib DESTDIR="${pkgdir}" uninstall
  make -j1 -C docs/libdbusmenu-gtk DESTDIR="${pkgdir}" install
}

# vim: ts=2 sw=2 et:
